From 7f42d61161ae010e5a970934d9f827ddafa0d586 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Sat, 31 Mar 2018 15:47:05 +0200 Subject: Initial commit --- .gitignore | 1 + index.html | 36 ++++++++++++++++++++ license.md | 9 +++++ pics/00.svg | 1 + pics/01.svg | 1 + pics/02.svg | 1 + pics/03.svg | 1 + pics/04.svg | 1 + pics/05.svg | 1 + pics/06.svg | 1 + rsrc/main.css | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ rsrc/main.js | 61 +++++++++++++++++++++++++++++++++ 12 files changed, 221 insertions(+) create mode 100644 .gitignore create mode 100644 index.html create mode 100644 license.md create mode 100644 pics/00.svg create mode 100644 pics/01.svg create mode 100644 pics/02.svg create mode 100644 pics/03.svg create mode 100644 pics/04.svg create mode 100644 pics/05.svg create mode 100644 pics/06.svg create mode 100644 rsrc/main.css create mode 100644 rsrc/main.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..62c8935 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..9322e47 --- /dev/null +++ b/index.html @@ -0,0 +1,36 @@ + + + + + + + + + + Slideshow + + +
+
+ +
    + +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
+ +
+
+ + \ No newline at end of file diff --git a/license.md b/license.md new file mode 100644 index 0000000..b388286 --- /dev/null +++ b/license.md @@ -0,0 +1,9 @@ +The MIT License (MIT) + +Copyright (c) 2018 Thomas Lange [] + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/pics/00.svg b/pics/00.svg new file mode 100644 index 0000000..bb8c3ee --- /dev/null +++ b/pics/00.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/pics/01.svg b/pics/01.svg new file mode 100644 index 0000000..6637407 --- /dev/null +++ b/pics/01.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/pics/02.svg b/pics/02.svg new file mode 100644 index 0000000..77cb635 --- /dev/null +++ b/pics/02.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/pics/03.svg b/pics/03.svg new file mode 100644 index 0000000..c921bf3 --- /dev/null +++ b/pics/03.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/pics/04.svg b/pics/04.svg new file mode 100644 index 0000000..3d9b049 --- /dev/null +++ b/pics/04.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/pics/05.svg b/pics/05.svg new file mode 100644 index 0000000..526b7c2 --- /dev/null +++ b/pics/05.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/pics/06.svg b/pics/06.svg new file mode 100644 index 0000000..7fa1bae --- /dev/null +++ b/pics/06.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/rsrc/main.css b/rsrc/main.css new file mode 100644 index 0000000..65de888 --- /dev/null +++ b/rsrc/main.css @@ -0,0 +1,107 @@ +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* Main +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +html{margin:0;padding:0;height:100%;font-size:1.25rem;background:#DDD;} +body{margin:0;padding:0;height:100%;font-size:1.00rem;display:flex;} + +main{margin:auto;padding:1rem;background:#FFF;width:60rem;border:0.05rem solid #AAA;} + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* Slideshow +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +.slideshow { + display:flex; + width:100%; + height:30rem; + border:0.05rem solid #AAA; +} + +.slideshow > ul, +.slideshow > div { + display:flex; + box-sizing:border-box; + align-items:center; +} + +.slideshow > div { + width:5%; + background:#DDD; + justify-content:center; + cursor:pointer; + font-weight:600; + padding:0.25rem; +} + +.slideshow > ul { + list-style:none; + margin:0; + padding:0; + width:90%; + border:0.05rem solid #AAA; + border-top:none; + border-bottom:none; + box-sizing:border-box; + z-index:0; + position:relative; + overflow:hidden; +} + +.slideshow > ul > li { + transition:visibility 0.5s linear, opacity 0.5s linear; + position:absolute; + top:0; + padding:0.5rem; + box-sizing:border-box; +} + +.slideshow > ul > li.show { + visibility:visible; + opacity:1; +} + +.slideshow > ul > li.show img { + animation-name:animation; + animation-duration:0.5s; + animation-fill-mode:both; +} + +.slideshow > ul > li.show.next img{ + animation-name:nextAnimation; +} + +.slideshow > ul > li.show.prev img{ + animation-name:prevAnimation; +} + +.slideshow > ul > li.hide { + visibility:hidden; + opacity:0; +} + +/* The "object-fit" attribute is equivalent to "background-size". */ +.slideshow > ul, +.slideshow > ul > li, +.slideshow > ul > li > img { + width:100%; + height:100%; + object-fit:contain; + background:#DDD; +} + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* Animation +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +@keyframes animation { + 0% {transform:translateY(-50rem);} + 100%{transform:translateY(0);} +} + +@keyframes prevAnimation { + 0% {transform:translateX(-50rem);} + 100%{transform:translateX(0);} +} + +@keyframes nextAnimation { + 0% {transform:translateX(50rem);} + 100%{transform:translateX(0);} +} \ No newline at end of file diff --git a/rsrc/main.js b/rsrc/main.js new file mode 100644 index 0000000..c35f983 --- /dev/null +++ b/rsrc/main.js @@ -0,0 +1,61 @@ +class Slideshow { + constructor(node) { + let prev, next, time; + + this.autostop = false; + this.timeout = false; + this.current = 0; + this.list = node.getElementsByTagName("ul")[0].getElementsByTagName("li"); + + if(prev = node.getElementsByClassName("prev")[0]) { + prev.onclick = () => { + this.initializeTimeout(); + this.changeDirection("prev") + }; + } + + if(next = node.getElementsByClassName("next")[0]) { + next.onclick = () => { + this.initializeTimeout(); + this.changeDirection("next"); + }; + } + + if(time = node.getAttribute("data-time")) { + setInterval(() => { + !this.autostop && this.changeDirection("next"); + }, time); + } + } + + initializeTimeout() { + if(this.timeout) { + clearTimeout(this.timeout); + } + + this.autostop = true; + this.timeout = setTimeout(() => { + this.autostop = false; + }, 15000); + } + + changeDirection(direction) { + (direction === "prev" && --this.current); + (direction === "next" && ++this.current); + + if(this.list[this.current] === undefined) { + switch(direction) { + case "prev": this.current = this.list.length - 1; break; + case "next": this.current = 0; + } + } + + for(let i = 0; i < this.list.length; ++i) { + if(this.current === i) { + this.list[i].getAttribute("class") !== "show" && this.list[i].setAttribute("class", "show " + direction); + } else { + this.list[i].getAttribute("class") !== "hide" && this.list[i].setAttribute("class", "hide"); + } + } + } +} \ No newline at end of file -- cgit v1.2.3