js carrousel study case (WIP)

master
Juan 3 years ago
parent db527a4ef4
commit 8bafe4ab90

@ -0,0 +1,7 @@
## howto :
uses sass to generate style.css in root dir :
```
sass .\scss\common.scss .\style.css
```

@ -0,0 +1,21 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
<svg xmlns="http://www.w3.org/2000/svg">
<metadata>Generated by IcoMoon</metadata>
<defs>
<font id="icomoon" horiz-adv-x="1024">
<font-face units-per-em="1024" ascent="960" descent="-64" />
<missing-glyph horiz-adv-x="1024" />
<glyph unicode="&#x20;" horiz-adv-x="512" d="" />
<glyph unicode="&#xea0d;" glyph-name="close-circle" d="M512 960c-282.77 0-512-229.23-512-512s229.23-512 512-512 512 229.23 512 512-229.23 512-512 512zM512 32c-229.75 0-416 186.25-416 416s186.25 416 416 416 416-186.25 416-416-186.25-416-416-416zM672 704l-160-160-160 160-96-96 160-160-160-160 96-96 160 160 160-160 96 96-160 160 160 160z" />
<glyph unicode="&#xea0f;" glyph-name="close" d="M1014.662 137.34c-0.004 0.004-0.008 0.008-0.012 0.010l-310.644 310.65 310.644 310.65c0.004 0.004 0.008 0.006 0.012 0.010 3.344 3.346 5.762 7.254 7.312 11.416 4.246 11.376 1.824 24.682-7.324 33.83l-146.746 146.746c-9.148 9.146-22.45 11.566-33.828 7.32-4.16-1.55-8.070-3.968-11.418-7.31 0-0.004-0.004-0.006-0.008-0.010l-310.648-310.652-310.648 310.65c-0.004 0.004-0.006 0.006-0.010 0.010-3.346 3.342-7.254 5.76-11.414 7.31-11.38 4.248-24.682 1.826-33.83-7.32l-146.748-146.748c-9.148-9.148-11.568-22.452-7.322-33.828 1.552-4.16 3.97-8.072 7.312-11.416 0.004-0.002 0.006-0.006 0.010-0.010l310.65-310.648-310.65-310.652c-0.002-0.004-0.006-0.006-0.008-0.010-3.342-3.346-5.76-7.254-7.314-11.414-4.248-11.376-1.826-24.682 7.322-33.83l146.748-146.746c9.15-9.148 22.452-11.568 33.83-7.322 4.16 1.552 8.070 3.97 11.416 7.312 0.002 0.004 0.006 0.006 0.010 0.010l310.648 310.65 310.648-310.65c0.004-0.002 0.008-0.006 0.012-0.008 3.348-3.344 7.254-5.762 11.414-7.314 11.378-4.246 24.684-1.826 33.828 7.322l146.746 146.748c9.148 9.148 11.57 22.454 7.324 33.83-1.552 4.16-3.97 8.068-7.314 11.414z" />
<glyph unicode="&#xea1c;" glyph-name="play3" d="M192 832l640-384-640-384z" />
<glyph unicode="&#xea1d;" glyph-name="pause2" d="M128 832h320v-768h-320zM576 832h320v-768h-320z" />
<glyph unicode="&#xea41;" glyph-name="circle-up" d="M0 448c0-282.77 229.23-512 512-512s512 229.23 512 512-229.23 512-512 512-512-229.23-512-512zM928 448c0-229.75-186.25-416-416-416s-416 186.25-416 416 186.25 416 416 416 416-186.25 416-416zM706.744 290.744l90.512 90.512-285.256 285.254-285.254-285.256 90.508-90.508 194.746 194.744z" />
<glyph unicode="&#xea42;" glyph-name="circle-right" d="M512 960c-282.77 0-512-229.23-512-512s229.23-512 512-512 512 229.23 512 512-229.23 512-512 512zM512 32c-229.75 0-416 186.25-416 416s186.25 416 416 416 416-186.25 416-416-186.25-416-416-416zM354.744 253.256l90.512-90.512 285.254 285.256-285.256 285.254-90.508-90.508 194.744-194.746z" />
<glyph unicode="&#xea43;" glyph-name="circle-down" d="M1024 448c0 282.77-229.23 512-512 512s-512-229.23-512-512 229.23-512 512-512 512 229.23 512 512zM96 448c0 229.75 186.25 416 416 416s416-186.25 416-416-186.25-416-416-416-416 186.25-416 416zM317.256 605.256l-90.512-90.512 285.256-285.254 285.254 285.256-90.508 90.508-194.746-194.744z" />
<glyph unicode="&#xea44;" glyph-name="circle-left" d="M512-64c282.77 0 512 229.23 512 512s-229.23 512-512 512-512-229.23-512-512 229.23-512 512-512zM512 864c229.75 0 416-186.25 416-416s-186.25-416-416-416-416 186.25-416 416 186.25 416 416 416zM669.256 642.744l-90.512 90.512-285.254-285.256 285.256-285.254 90.508 90.508-194.744 194.746z" />
<glyph unicode="&#xea54;" glyph-name="radio-checked" d="M512 960c-282.77 0-512-229.23-512-512s229.23-512 512-512 512 229.23 512 512-229.23 512-512 512zM512 64c-212.078 0-384 171.922-384 384s171.922 384 384 384c212.078 0 384-171.922 384-384s-171.922-384-384-384zM320 448c0 106.039 85.961 192 192 192s192-85.961 192-192c0-106.039-85.961-192-192-192s-192 85.961-192 192z" />
<glyph unicode="&#xea55;" glyph-name="radio-checked2" d="M512 960c-282.77 0-512-229.23-512-512s229.23-512 512-512 512 229.23 512 512-229.23 512-512 512zM512 320c-70.692 0-128 57.306-128 128 0 70.692 57.308 128 128 128 70.694 0 128-57.308 128-128 0-70.694-57.306-128-128-128z" />
<glyph unicode="&#xea56;" glyph-name="radio-unchecked" d="M512 960c-282.77 0-512-229.23-512-512s229.23-512 512-512 512 229.23 512 512-229.23 512-512 512zM512 64c-212.078 0-384 171.922-384 384s171.922 384 384 384c212.078 0 384-171.922 384-384s-171.922-384-384-384z" />
</font></defs></svg>

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 832 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 827 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1021 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 283 KiB

@ -0,0 +1,50 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Welcome to the forest</title>
<link rel="stylesheet" href="style.css" />
<script type="text/javascript" src="scripts/slider.js" async></script>
</head>
<body>
<header id="top-slider" aria-hidden="true">
<div class="slider">
<div id="slide-1" class="slide img-wrap">
<picture>
<source media="(max-width: 480px)" srcset="./imgs/mobile/forest-river.jpg">
<source media="(orientation: landscape) and (min-width: 481px) and (max-width: 989px)" srcset="./imgs/tablet/forest-river.jpg">
<source media="(min-width: 990px)" srcset="./imgs/full/forest-river.jpg">
<img src="./imgs/tablet/forest-river.jpg" alt="">
</picture>
</div>
<div id="slide-2" class="slide img-wrap" aria-hidden="true">
<picture>
<source media="(max-width: 480px)" srcset="./imgs/mobile/forest-moss.jpg">
<source media="(orientation: landscape) and (min-width: 481px) and (max-width: 989px)" srcset="./imgs/tablet/forest-moss.jpg">
<source media="(min-width: 990px)" srcset="./imgs/full/forest-moss.jpg">
<img src="./imgs/tablet/forest-moss.jpg" alt="">
</picture>
</div>
<div id="slide-3" class="slide img-wrap" aria-hidden="true">
<picture>
<source media="(max-width: 480px)" srcset="./imgs/mobile/forest-autumn.jpg">
<source media="(orientation: landscape) and (min-width: 481px) and (max-width: 989px)" srcset="./imgs/tablet/forest-autumn.jpg">
<source media="(min-width: 990px)" srcset="./imgs/full/forest-autumn.jpg">
<img src="./imgs/tablet/forest-autumn.jpg" alt="">
</picture>
</div>
<nav class="slider-nav">
<span class="prev"><i class="ico-circle-left"></i></span>
<span class="pause"><i class="ico-pause2"></i></span>
<span class="next"><i class="ico-circle-right"></i></span>
</nav>
</div>
</header>
<div id="slider-position">
<i class="on"></i>
<i class="ico-radio-unchecked"></i>
<i class="ico-radio-unchecked"></i>
</div>
<h1>Welcome to the forest</h1>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

@ -0,0 +1,40 @@
console.log('scripts loaded');
document.onreadystatechange = function(event) {
if (document.readyState === "complete") {
console.log('document loaded');
document.addEventListener("click",function (event) {
console.log(event.target);
curpos=1;
if(document.getElementById("top-slider").getAttribute("data-position"))
{
curpos = document.getElementById("top-slider").getAttribute("data-position");
}
nextposition = get_next_pos(curpos);
prevposition = get_prev_pos(curpos);
/*
if(event.target.matches('.prev'))
{
document.getElementById("slider").setAttribute("data-position",$prevposition);
}
if(event.target.matches('.pause'))
{
document.getElementById("slider").setAttribute("data-paused","true");
}
if(event.target.matches('.next'))
{
document.getElementById("slider").setAttribute("data-position",$nextposition);
}
*/
});
}
}
function get_next_pos()
{
}
function get_prev_pos()
{
}

@ -0,0 +1,59 @@
@font-face {
font-family: 'icomoon';
src:
url('fonts/icomoon.ttf?e3ejhb') format('truetype'),
url('fonts/icomoon.woff?e3ejhb') format('woff'),
url('fonts/icomoon.svg?e3ejhb#icomoon') format('svg');
font-weight: normal;
font-style: normal;
font-display: block;
}
i {
/* use !important to prevent issues with browser extensions that change fonts */
font-family: 'icomoon' !important;
speak: never;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
/* Better Font Rendering =========== */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.ico-close-circle:before {
content: "\ea0d";
}
.ico-close:before {
content: "\ea0f";
}
.ico-play3:before {
content: "\ea1c";
}
.ico-pause2:before {
content: "\ea1d";
}
.ico-circle-up:before {
content: "\ea41";
}
.ico-circle-right:before {
content: "\ea42";
}
.ico-circle-down:before {
content: "\ea43";
}
.ico-circle-left:before {
content: "\ea44";
}
.ico-radio-checked:before {
content: "\ea54";
}
.ico-radio-checked2:before {
content: "\ea55";
}
.ico-radio-unchecked:before {
content: "\ea56";
}

@ -0,0 +1,349 @@
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
/* Document
========================================================================== */
/**
* 1. Correct the line height in all browsers.
* 2. Prevent adjustments of font size after orientation changes in iOS.
*/
html {
line-height: 1.15; /* 1 */
-webkit-text-size-adjust: 100%; /* 2 */
}
/* Sections
========================================================================== */
/**
* Remove the margin in all browsers.
*/
body {
margin: 0;
}
/**
* Render the `main` element consistently in IE.
*/
main {
display: block;
}
/**
* Correct the font size and margin on `h1` elements within `section` and
* `article` contexts in Chrome, Firefox, and Safari.
*/
h1 {
font-size: 2em;
margin: 0.67em 0;
}
/* Grouping content
========================================================================== */
/**
* 1. Add the correct box sizing in Firefox.
* 2. Show the overflow in Edge and IE.
*/
hr {
box-sizing: content-box; /* 1 */
height: 0; /* 1 */
overflow: visible; /* 2 */
}
/**
* 1. Correct the inheritance and scaling of font size in all browsers.
* 2. Correct the odd `em` font sizing in all browsers.
*/
pre {
font-family: monospace, monospace; /* 1 */
font-size: 1em; /* 2 */
}
/* Text-level semantics
========================================================================== */
/**
* Remove the gray background on active links in IE 10.
*/
a {
background-color: transparent;
}
/**
* 1. Remove the bottom border in Chrome 57-
* 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
*/
abbr[title] {
border-bottom: none; /* 1 */
text-decoration: underline; /* 2 */
text-decoration: underline dotted; /* 2 */
}
/**
* Add the correct font weight in Chrome, Edge, and Safari.
*/
b,
strong {
font-weight: bolder;
}
/**
* 1. Correct the inheritance and scaling of font size in all browsers.
* 2. Correct the odd `em` font sizing in all browsers.
*/
code,
kbd,
samp {
font-family: monospace, monospace; /* 1 */
font-size: 1em; /* 2 */
}
/**
* Add the correct font size in all browsers.
*/
small {
font-size: 80%;
}
/**
* Prevent `sub` and `sup` elements from affecting the line height in
* all browsers.
*/
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sub {
bottom: -0.25em;
}
sup {
top: -0.5em;
}
/* Embedded content
========================================================================== */
/**
* Remove the border on images inside links in IE 10.
*/
img {
border-style: none;
}
/* Forms
========================================================================== */
/**
* 1. Change the font styles in all browsers.
* 2. Remove the margin in Firefox and Safari.
*/
button,
input,
optgroup,
select,
textarea {
font-family: inherit; /* 1 */
font-size: 100%; /* 1 */
line-height: 1.15; /* 1 */
margin: 0; /* 2 */
}
/**
* Show the overflow in IE.
* 1. Show the overflow in Edge.
*/
button,
input { /* 1 */
overflow: visible;
}
/**
* Remove the inheritance of text transform in Edge, Firefox, and IE.
* 1. Remove the inheritance of text transform in Firefox.
*/
button,
select { /* 1 */
text-transform: none;
}
/**
* Correct the inability to style clickable types in iOS and Safari.
*/
button,
[type="button"],
[type="reset"],
[type="submit"] {
-webkit-appearance: button;
}
/**
* Remove the inner border and padding in Firefox.
*/
button::-moz-focus-inner,
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner {
border-style: none;
padding: 0;
}
/**
* Restore the focus styles unset by the previous rule.
*/
button:-moz-focusring,
[type="button"]:-moz-focusring,
[type="reset"]:-moz-focusring,
[type="submit"]:-moz-focusring {
outline: 1px dotted ButtonText;
}
/**
* Correct the padding in Firefox.
*/
fieldset {
padding: 0.35em 0.75em 0.625em;
}
/**
* 1. Correct the text wrapping in Edge and IE.
* 2. Correct the color inheritance from `fieldset` elements in IE.
* 3. Remove the padding so developers are not caught out when they zero out
* `fieldset` elements in all browsers.
*/
legend {
box-sizing: border-box; /* 1 */
color: inherit; /* 2 */
display: table; /* 1 */
max-width: 100%; /* 1 */
padding: 0; /* 3 */
white-space: normal; /* 1 */
}
/**
* Add the correct vertical alignment in Chrome, Firefox, and Opera.
*/
progress {
vertical-align: baseline;
}
/**
* Remove the default vertical scrollbar in IE 10+.
*/
textarea {
overflow: auto;
}
/**
* 1. Add the correct box sizing in IE 10.
* 2. Remove the padding in IE 10.
*/
[type="checkbox"],
[type="radio"] {
box-sizing: border-box; /* 1 */
padding: 0; /* 2 */
}
/**
* Correct the cursor style of increment and decrement buttons in Chrome.
*/
[type="number"]::-webkit-inner-spin-button,
[type="number"]::-webkit-outer-spin-button {
height: auto;
}
/**
* 1. Correct the odd appearance in Chrome and Safari.
* 2. Correct the outline style in Safari.
*/
[type="search"] {
-webkit-appearance: textfield; /* 1 */
outline-offset: -2px; /* 2 */
}
/**
* Remove the inner padding in Chrome and Safari on macOS.
*/
[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
/**
* 1. Correct the inability to style clickable types in iOS and Safari.
* 2. Change font properties to `inherit` in Safari.
*/
::-webkit-file-upload-button {
-webkit-appearance: button; /* 1 */
font: inherit; /* 2 */
}
/* Interactive
========================================================================== */
/*
* Add the correct display in Edge, IE 10+, and Firefox.
*/
details {
display: block;
}
/*
* Add the correct display in all browsers.
*/
summary {
display: list-item;
}
/* Misc
========================================================================== */
/**
* Add the correct display in IE 10+.
*/
template {
display: none;
}
/**
* Add the correct display in IE 10.
*/
[hidden] {
display: none;
}

@ -0,0 +1,104 @@
@import "icons";
@import "normalize";
h1
{
font-weight:700;
font-size:24px;
text-align: center;
color:#666;
font-family: Arial, Helvetica, sans-serif;
}
#top-slider
{
position: relative;
max-width: 100vh;
width: 100vw;
height: 50vh;
overflow: hidden;
}
#slider-position
{
width: 100vw;
height: 30px;
line-height: 30px;
text-align: center;
i
{
content:"\00a0";
display: inline-block;
height: 20px;
width: 20px;
border-radius: 20px;
font-size: 20px;
line-height: 1;
vertical-align: middle;
color:lightseagreen;
&.on
{
background-color:lightseagreen;
}
}
}
.slider
{
position:absolute;
top:0;
left:0;
bottom:0;
right:0;
.slide
{
width:100vw;
float:left;
}
.slider-nav
{
position:absolute;
top:50%;
left:0;
right:0;
height:15vh;
//background-color:red;
transform: translateY(-50%);
display: inline-block;
line-height: 15vh;
i
{
color:rgba(255,255,255,0.75);
font-size:9vh;
line-height: 1;
display: inline-block;
vertical-align: middle;
}
span
{
display: block;
position: absolute;
opacity:0;
&:hover
{
opacity: 1;
}
}
.pause
{
width:34%;
left:33%;
text-align: center;
}
.next
{
width:33%;
left:67%;
text-align:right;
}
.prev
{
width:33%;
text-align:left;
}
}
}
Loading…
Cancel
Save