diff --git a/CHANGELOG.md b/CHANGELOG.md index 2939881..198b56e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,39 @@ # Changelog -#### v0.0.1 +> The changelog just includes breaking changes along with its migration instructions. + +## v0.7.0 + + + +List of new features: + +- Added video support +- Added support for mounting HTML node fragments as slides (now you can add everything as a slide) +- Added download feature +- Added support for adaptive responsive images (by viewport size, pixel ratio and available internet bandwidth) +- Added support for a customizable button in the footer section of a slide +- Added support for additional callbacks `onclick` (for the footer button), `onshow` and `onclose` +- Added new feature `fit` which can autofit the image as "cover" or as "contain" +- Added support for adding and removing custom controls via `addControl` and `removeControl` + +List of improvements: + +- Greatly improves performance, this lib is definitely the web's most performant gallery library. +- Improve rendering, style recalculations and layout reflow +- Improve memory usage and listener bindings +- Improve event flow +- Improve event delegation for touchable pointers +- Improve animation handler +- Improve options and group options inheritance +- Improve prevention of css class collision +- Improve initialization and build-up +- Improve markup declaration and parsing +- Improve the history handler to catch the "back" button +- Improve scheduling of the menu auto-hide +- Improve handling of custom themes +- Fixed a lot of bugs + +## v0.0.1 - Initial Release diff --git a/README.md b/README.md index 35fc9c7..6b5542e 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,14 @@ -

Spotlight.js: Modern HTML5 Gallery for Images, Videos and Media

+

+

Spotlight.js: Modern HTML5 Gallery for Images, Videos and Media

Web's most easy to integrate lightbox gallery library. Super-lightweight, outstanding performance, no dependencies.

-Demo  •  Getting Started  •  Gallery Groups  •  Options  •  Styling  •  API  •  Custom Builds +Demo  •  Getting Started  •  Gallery Groups  •  Options  •  Styling  •  API  •  Custom Builds  •  Changelog + +

Live Demo:

https://nextapps-de.github.io/spotlight/

Spotlight runs out of the box: @@ -15,13 +18,15 @@ Spotlight runs out of the box: - No additional icons/assets - No additional handling of dynamic content and event listener -Show Demo - Alternatively you can: 1. use the non-bundled version of this library (classically contains css files, image files, js files) 2. use the source files (compatible for the ES6 module system) +## Whats new in 0.7.1? + +The new version includes tons of fixes, new features and improvements which was collected over the last two years. Read the Changelog to get all new features. + ## Features @@ -103,8 +108,8 @@ __Get Latest Build (Stable):__ spotlight.bundle.js - Download - https://rawcdn.githack.com/nextapps-de/spotlight/0.7.0/dist/spotlight.bundle.js + Download + https://rawcdn.githack.com/nextapps-de/spotlight/0.7.1/dist/spotlight.bundle.js @@ -113,8 +118,8 @@ __Get Latest Build (Stable):__ spotlight.cdn.js - Download - https://rawcdn.githack.com/nextapps-de/spotlight/0.7.0/dist/spotlight.cdn.js + Download + https://rawcdn.githack.com/nextapps-de/spotlight/0.7.1/dist/spotlight.cdn.js @@ -123,19 +128,19 @@ __Get Latest Build (Stable):__ spotlight.min.js - Download - https://rawcdn.githack.com/nextapps-de/spotlight/0.7.0/dist/js/spotlight.min.js + Download + https://rawcdn.githack.com/nextapps-de/spotlight/0.7.1/dist/js/spotlight.min.js spotlight.css - Download - https://rawcdn.githack.com/nextapps-de/spotlight/0.7.0/dist/css/spotlight.css + Download + https://rawcdn.githack.com/nextapps-de/spotlight/0.7.1/dist/css/spotlight.css img.zip - Download + Download Alternatively when using non-bundled version you can download icons from /dist/img/. @@ -145,14 +150,14 @@ __Get Latest Build (Stable):__ src.zip - Download + Download The folder "src" of this Github repository. __Get Latest Build (Nightly):__ -Just exchange the version number from the URLs above with "master", e.g.: "/spotlight/0.7.0/dist/" into "/spotlight/__master__/dist". +Just exchange the version number from the URLs above with "master", e.g.: "/spotlight/0.7.1/dist/" into "/spotlight/__master__/dist". __Get Latest (NPM):__ diff --git a/demo/style.css b/demo/style.css index fd507e4..7f54bf3 100644 --- a/demo/style.css +++ b/demo/style.css @@ -7,6 +7,12 @@ html, body{ font-family: Aral, Helvetica, sans-serif; text-align: center; -webkit-tap-highlight-color: rgba(0,0,0,0); + background: #f8f9fa; +} +main{ + position: relative; + max-width: 800px; + margin: auto; } a, b{ display: inline-block; @@ -51,22 +57,76 @@ hr{ padding-top: 20px; } h1 img{ - width: 400px; - max-width: 61.8vw; + width: 500px; + max-width: 70vw; } -label{ +label, button{ display: inline-block; padding: 5px 10px; margin-bottom: 5px; border: 1px solid #ddd; - background: #f5f5f5; + background: #e9ecef; font-size: 12px; line-height: 20px; vertical-align: middle; cursor: pointer; border-radius: 5px; } +button{ + border:0; + outline: 0; + padding: 10px 15px; + font-weight: 500; + background-color: #6c757d; + color: #fff; +} label input{ float: left; margin-right: 10px; -} \ No newline at end of file +} + +pre{ + display: inline-block; + margin: auto; + text-align: left; + width: 100%; + max-width: calc(100vw - 1.7em); +} +pre code.hljs{ + background: #fff; + padding: 1em 1.5em; + border-radius: 10px; + width: 100%; + max-width: calc(100vw - 1.7em); +} + +.hljs{ + color: #000; +} +.hljs-attr { + color:#79c0ff +} +.hljs-name, +.hljs-built_in { + color: #ffa657; +} +.hljs-attribute{ + color: #e0e7ff +} +.hljs-selector-class { + color: #79c0ff +} + +.hljs-keyword, +.hljs-selector-tag { + color: #f92672 +} + +.hljs-bullet, +.hljs-link, +.hljs-literal, +.hljs-number, +.hljs-quote, +.hljs-regexp { + color: #d2a8ff +} diff --git a/dist/js/spotlight.min.js b/dist/js/spotlight.min.js index 74cd3e0..3e09a29 100644 --- a/dist/js/spotlight.min.js +++ b/dist/js/spotlight.min.js @@ -1,29 +1,30 @@ /** - * Spotlight.js v0.7.0 + * Spotlight.js v0.7.1 * Copyright 2019 Nextapps GmbH * Author: Thomas Wilkerling * Licence: Apache-2.0 * https://github.com/nextapps-de/spotlight */ -(function(){'use strict';Object.assign||(Object.assign=function(a,b){console.log("assign",a,b);for(var d=Object.keys(b),e=0,f;e
";/* +(function(){'use strict';Object.assign||(Object.assign=function(a,b){console.log("assign",a,b);for(var c=Object.keys(b),e=0,f;e
";/* toggle_autofit &&*/ -var m="theme download play page close autofit zoom-in zoom-out arrow-left arrow-right fullscreen".split(" "),ea={page:1,close:1,autofit:1,"zoom-in":1,"zoom-out":1,"arrow-left":1,"arrow-right":1,fullscreen:1},fa={},ha=document.createElement("video"),ia={},n,p,ja,ka,r,la,t,u,v,ma,na,oa,w,x,y,z,A,pa,B,qa,ra,sa,ta,C,D,ua,va,wa,xa,ya,E,F,G,H,I,za,Aa,Ba,Ca,Da,Ea,J,Fa,Ga,K,L,M,Ha,N,O,Ia,P,Ja;h(document,"click",Ka); -function La(){function a(d){return fa[d]=(l||document).getElementsByClassName("spl-"+d)[0]}N=document.body;I=a("scene");za=a("footer");Aa=a("title");Ba=a("description");Ca=a("button");Da=a("arrow-left");Ea=a("arrow-right");J=a("fullscreen");Fa=a("page");Ga=a("play");K=a("progress");G=[a("pane")];N[P="requestFullscreen"]||N[P="msRequestFullscreen"]||N[P="webkitRequestFullscreen"]||N[P="mozRequestFullscreen"]||(P="");P?Ja=P.replace("request","exit").replace("mozRequest","mozCancel").replace("Request", -"Exit"):(m.pop(),Q(J,!1));var b=a("track");h(b,"mousedown",Ma);h(b,"mousemove",Na);h(b,"mouseleave",Oa);h(b,"mouseup",Oa);h(b,"touchstart",Ma,{passive:!1});h(b,"touchmove",Na,{passive:!0});h(b,"touchend",Oa);h(J,"click",Pa);h(Da,"click",Qa);h(Ea,"click",R);h(Ga,"click",S);h(a("autofit"),"click",T);h(a("zoom-in"),"click",Ra);h(a("zoom-out"),"click",Sa);h(a("close"),"click",Ta);h(a("download"),"click",Ua);h(a("theme"),"click",Va)} -function Ka(a){var b=a.target.closest(".spotlight");if(b){k(a,!0);a=b.closest(".spotlight-group");z=(a||document).getElementsByClassName("spotlight");for(var d=0;d.5*(0>a?1:a?-1:0)?Sa():Ra())}function S(a){("boolean"===typeof a?a:!L)?L||(L=setInterval(R,1E3*va),Ga.classList.add("on"),qa&&hb(!0)):L&&(L=clearInterval(L),c(Ga,"on"),qa&&hb())} -function hb(a){ca(K,function(){g(K,"transition-duration","");g(K,"transform","")});a&&(g(K,"transition-duration",va+"s"),g(K,"transform","translateX(0)"))}function V(){ta&&(Ha=Date.now()+1E3*ta-50,M||(l.classList.add("menu"),ib(1E3*ta)))}function ib(a){M=setTimeout(function(){var b=Date.now();b>=Ha?(c(l,"menu"),M=0):ib(Ha-b)},a)}function jb(a){"boolean"===typeof a&&(M=a?M:0);M?(M=clearTimeout(M),c(l,"menu")):V()} -function Ma(a){k(a,!0);ma=!0;na=!1;var b=a.touches;b&&(b=b[0])&&(a=b);oa=t*v<=r;ja=a.pageX;ka=a.pageY;U(F)}function Oa(a){k(a);if(ma){if(na){if(oa&&na){var b=(a=n<-(r/7)&&(xr/7&&(1b?n=b:n<-b&&(n=-b),u*v>la&&(b=(u*v-la)/2,p-=ka-(ka=a.pageY),p>b?p=b:p<-b&&(p=-b)));na=!0;X(n,p)}else V()} -function Pa(a){("boolean"===typeof a?a:document.fullscreen||document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement)?(document[Ja](),c(J,"on")):(l[P](),J.classList.add("on"))}function Va(a){"object"===typeof a&&(a=D?"":"white");D!==a&&(D&&c(l,D),a&&l.classList.add(a),D=a)}function T(a){"boolean"===typeof a&&(w=!a);(w=1===v&&!w)?H.classList.add("autofit"):c(H,"autofit");g(H,"transform","");t=H.width;u=H.height;v=1;p=n=0;U(F);X();V()} -function Ra(a){var b=v/.65;50>=b&&(w&&T(),n/=.65,p/=.65,X(n,p),kb(b));a||V()}function Sa(a){var b=.65*v;w&&T();1<=b&&(1===b?n=p=0:(n*=.65,p*=.65),X(n,p),kb(b));a||V()}function kb(a){v=a||1;g(H,"transform","translate(-50%, -50%) scale("+v+")")}function Ua(){var a=document.createElement("a");a.href=H.src;a.download=H.src.substring(H.src.lastIndexOf("/")+1);N.appendChild(a);a.click();N.removeChild(a)} -function Ta(a){setTimeout(function(){N.removeChild(l);F=H=O=A=pa=z=ra=null},200);c(N,"hide-scrollbars");c(l,"show");$a();history.go(!0===a?-1:-2);L&&S(!1);H&&H.parentNode&&H.parentNode.removeChild(H)}function Qa(a){a&&V();if(1x;x=a;Ya(b);return!0}} -var lb=navigator.connection,mb=window.devicePixelRatio||1;function nb(a,b,d){var e;if("video"===H||!(e=d.src||d.href||a.src||a.href)){a=Object.keys(d);for(var f=0,q;f.5*(0>a?1:a?-1:0)?Va():Ua())}function S(a){("boolean"===typeof a?a:!N)?N||(N=setInterval(T,1E3*za),Ma.classList.add("on"),qa&&nb(!0)):N&&(N=clearInterval(N),d(Ma,"on"),qa&&nb())} +function nb(a){ca(L,function(){g(L,"transition-duration","");g(L,"transform","")});a&&(g(L,"transition-duration",za+"s"),g(L,"transform","translateX(0)"))}function V(){va&&(Oa=Date.now()+1E3*va-50,O||(k.classList.add("menu"),ob(1E3*va)))}function ob(a){O=setTimeout(function(){var b=Date.now();b>=Oa?(d(k,"menu"),O=0):ob(Oa-b)},a)}function pb(a){"boolean"===typeof a&&(O=a?O:0);O?(O=clearTimeout(O),d(k,"menu")):V()} +function Za(a){ea(a,!0);na=!0;oa=!1;var b=a.touches;b&&(b=b[0])&&(a=b);pa=t*v<=r;ka=a.pageX;la=a.pageY;U(H)}function ab(a){ea(a);if(na){if(oa){if(pa&&oa){var b=(a=n<-(r/7)&&(xr/7&&(1b?n=b:n<-b&&(n=-b),u*v>ma&&(b=(u*v-ma)/2,p-=la-(la=a.pageY),p>b?p=b:p<-b&&(p=-b)));oa=!0;X(n,p)}else V()} +function Ta(a){("boolean"===typeof a?a:document.fullscreen||document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement)?(document[Pa](),d(Ka,"on")):(k[P](),Ka.classList.add("on"))}function Wa(a){"object"===typeof a&&(a=E?"":"white");E!==a&&(E&&d(k,E),a&&k.classList.add(a),E=a)}function R(a){"boolean"===typeof a&&(w=!a);(w=1===v&&!w)?J.classList.add("autofit"):d(J,"autofit");g(J,"transform","");t=J.width;u=J.height;v=1;p=n=0;U(H);X();V()} +function Ua(a){var b=v/.65;50>=b&&(w&&R(),n/=.65,p/=.65,X(n,p),qb(b));a||V()}function Va(a){var b=.65*v;w&&R();1<=b&&(1===b?n=p=0:(n*=.65,p*=.65),X(n,p),qb(b));a||V()}function qb(a){v=a||1;g(J,"transform","translate(-50%, -50%) scale("+v+")")}function Xa(){var a=document.createElement("a");a.href=J.src;a.download=J.src.substring(J.src.lastIndexOf("/")+1);G.appendChild(a);a.click();G.removeChild(a)} +function Sa(a){setTimeout(function(){G.removeChild(k);H=J=M=A=B=z=ra=sa=ta=ya=null},200);d(G,"hide-scrollbars");d(k,"show");fb();history.go(!0===a?-1:-2);N&&S(!1);J&&rb(J);ta&&ta()}function rb(a){if(a.g)a.g.appendChild(a),a.g=null;else{var b=a.parentNode;b&&b.removeChild(a)}}function Ya(a){a&&V();if(1x;x=a;db(b);return!0}}var sb=navigator.connection,tb=window.devicePixelRatio||1; +function ub(a,b,c){var e;if("video"===J||!(e=c.src||c.href||a.src||a.href)){a=Object.keys(c);for(var f=0,q;f*{position:absolute;width:auto;height:auto;max-width:100%;max-height:100%;left:50%;top:50%;margin:0;padding:0;border:0;transform:translate(-50%,-50%) scale(1);transition:transform .65s cubic-bezier(.3,1,.3,1),opacity .65s ease;contain:layout style;will-change:transform,opacity;visibility:hidden}.spl-header,.spl-pane{width:100%;position:absolute}.spl-pane{top:0;transition:transform .65s cubic-bezier(.3,1,.3,1);will-change:transform}.spl-header{top:0;height:50px;text-align:right;background-color:rgba(0,0,0,.45);transform:translateY(-100px);transition:transform .35s ease;overflow:hidden}#spotlight.menu .spl-header,.spl-header:hover{transform:translateY(0)}.spl-header div{display:inline-block;vertical-align:middle;white-space:nowrap;width:50px;height:50px;opacity:.5}.spl-progress{position:absolute;top:0;width:100%;height:3px;background-color:rgba(255,255,255,.45);transform:translateX(-100%);transition:transform linear}.spl-footer{position:absolute;left:0;right:0;bottom:0;background-color:rgba(0,0,0,.45);line-height:20px;padding:20px 20px 0;padding-bottom:env(safe-area-inset-bottom,0);text-align:left;font-size:15px;font-weight:400}.spl-title{font-size:22px}.spl-button,.spl-description,.spl-title{margin-bottom:20px}.spl-button{display:inline-block;background:#fff;color:#000;border-radius:5px;padding:10px 20px;cursor:pointer}.spl-arrow-left,.spl-arrow-right,.spl-page~*{background-position:center;background-repeat:no-repeat}.spl-page{float:left;width:auto;line-height:50px}.spl-page~*{background-size:21px;float:right}.spl-fullscreen{background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIj8+PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjI0IiBzdHJva2U9IiNmZmYiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgc3Ryb2tlLXdpZHRoPSIyLjUiIHZpZXdCb3g9Ii0xIC0xIDI2IDI2IiB3aWR0aD0iMjQiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTggM0g1YTIgMiAwIDAgMC0yIDJ2M20xOCAwVjVhMiAyIDAgMCAwLTItMmgtM20wIDE4aDNhMiAyIDAgMCAwIDItMnYtM00zIDE2djNhMiAyIDAgMCAwIDIgMmgzIi8+PC9zdmc+)}.spl-fullscreen.on{background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIj8+PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjI0IiBzdHJva2U9IiNmZmYiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgc3Ryb2tlLXdpZHRoPSIyLjUiIHZpZXdCb3g9IjAgMCAyNCAyNCIgd2lkdGg9IjI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik04IDN2M2EyIDIgMCAwIDEtMiAySDNtMTggMGgtM2EyIDIgMCAwIDEtMi0yVjNtMCAxOHYtM2EyIDIgMCAwIDEgMi0yaDNNMyAxNmgzYTIgMiAwIDAgMSAyIDJ2MyIvPjwvc3ZnPg==)}.spl-autofit{background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIj8+PHN2ZyBoZWlnaHQ9Ijk2cHgiIHZpZXdCb3g9IjAgMCA5NiA5NiIgd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pbmUgeDE9IjgiIHgyPSIxNCIgeTE9IjExIiB5Mj0iMTEiLz48L3N2Zz4=);background-size:22px}.spl-zoom-in{background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIj8+PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjI0IiBzdHJva2U9IiNmZmYiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgc3Ryb2tlLXdpZHRoPSIyIiB2aWV3Qm94PSIwIDAgMjQgMjQiIHdpZHRoPSIyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48Y2lyY2xlIGN4PSIxMSIgY3k9IjExIiByPSI4Ii8+PGxpbmUgeDE9IjIxIiB4Mj0iMTYuNjUiIHkxPSIyMSIgeTI9IjE2LjY1Ii8+PGxpbmUgeDE9IjExIiB4Mj0iMTEiIHkxPSI4IiB5Mj0iMTQiLz48bGluZSB4MT0iOCIgeDI9IjE0IiB5MT0iMTEiIHkyPSIxMSIvPjwvc3ZnPg==)}.spl-download{background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjxzdmcgaGVpZ2h0PSIxNDEuNzMycHgiIHZlcnNpb249IjEuMSIgdmlld0JveD0iMCAwIDE0MS43MzIgMTQxLjczMiIgd2lkdGg9IjE0MS43MzJweCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjZmZmIj48cGF0aCBkPSJNMTIwLjY3NCwxMjUuMTM4SDIwLjc5M3YxNi41OTRoOTkuODgxVjEyNS4xMzh6IE0xMTkuMDE5LDU4Ljc3NmMtMi41NjEtMi41NjItNi43MTYtMi41NjItOS4yNzUsMEw3Ny4yMSw5MS4zMTJWNi41NjIgICBDNzcuMjEsMi45MzYsNzQuMjY5LDAsNzAuNjQ4LDBjLTMuNjI0LDAtNi41NiwyLjkzNy02LjU2LDY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d6Ii8+PC9nPjwvc3ZnPg==)}.spl-play{background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIj8+PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjI0IiBzdHJva2U9IiNmZmYiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgc3Ryb2tlLXdpZHRoPSIyIiB2aWV3Qm94PSItMC41IC0wLjUgMjUgMjUiIHdpZHRoPSIyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48Y2lyY2xlIGN4PSIxMiIgY3k9IjEyIiByPSIxMCIvPjxwb2x5Z29uIGZpbGw9IiNmZmYiIHBvaW50cz0iMTAgOCAxNiAxMiAxMCAxNiAxMCA4Ii8+PC9zdmc+)}.spl-play.on{background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIj8+PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjI0IiBzdHJva2U9IiNmZmYiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgc3Ryb2tlLXdpZHRoPSIyIiB2aWV3Qm94PSItMC41IC0wLjUgMjUgMjUiIHdpZHRoPSIyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48Y2lyY2xlIGN4PSIxMiIgY3k9IjEyIiByPSIxMCIvPjxsaW5lIHgxPSIxMCIgeDI9IjEwIiB5MT0iMTUiIHkyPSI5Ii8+PGxpbmUgeDE9IjE0IiB4Mj0iMTQiIHkxPSIxNSIgeTI9IjkiLz48L3N2Zz4=);animation:pulsate 1s ease infinite}.spl-close{background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIj8+PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjI0IiBzdHJva2U9IiNmZmYiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgc3Ryb2tlLXdpZHRoPSIyIiB2aWV3Qm94PSIyIDIgMjAgMjAiIHdpZHRoPSIyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48bGluZSB4MT0iMTgiIHgyPSI2IiB5MT0iNiIgeTI9IjE4Ii8+PGxpbmUgeDE9IjYiIHgyPSIxOCIgeTE9IjYiIHkyPSIxOCIvPjwvc3ZnPg==)}.spl-arrow-left,.spl-arrow-right{position:absolute;top:50%;left:20px;width:50px;height:50px;opacity:.65;background-color:rgba(0,0,0,.45);border-radius:100%;cursor:pointer;margin-top:-25px;transform:translateX(-100px);transition:transform .35s ease;background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIj8+PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjI0IiBzdHJva2U9IiNmZmYiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgc3Ryb2tlLXdpZHRoPSIyIiB2aWV3Qm94PSIwIDAgMjQgMjQiIHdpZHRoPSIyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cG9seWxpbmUgcG9pbnRzPSIxNSAxOCA5IDEyIDE1IDYiLz48L3N2Zz4=);background-size:30px}.spl-arrow-right{left:auto;right:20px;transform:translateX(100px) scaleX(-1)}#spotlight.menu .spl-arrow-left{transform:translateX(0)}#spotlight.menu .spl-arrow-right{transform:translateX(0) scaleX(-1)}@media (hover:hover){.spl-page~div{cursor:pointer;transition:opacity .2s ease}.spl-arrow-left:hover,.spl-arrow-right:hover,.spl-page~div:hover{opacity:1}}@media (max-width:500px){.spl-header div{width:44px}.spl-footer .spl-title{font-size:20px}.spl-footer{font-size:14px}.spl-arrow-left,.spl-arrow-right{width:35px;height:35px;margin-top:-17.5px;background-size:15px 15px}.spl-spinner{background-size:30px 30px}}.hide-scrollbars{overflow:-moz-hidden-unscrollable;-ms-overflow-style:none}.hide-scrollbars::-webkit-scrollbar{width:0}"; -var ca=document.getElementsByTagName("head")[0];ca.firstChild?ca.insertBefore(ba,ca.firstChild):ca.appendChild(ba);Object.assign||(Object.assign=function(a,b){console.log("assign",a,b);for(var d=Object.keys(b),e=0,f;e
";/* +var ca=document.getElementsByTagName("head")[0];ca.firstChild?ca.insertBefore(ba,ca.firstChild):ca.appendChild(ba);Object.assign||(Object.assign=function(a,b){console.log("assign",a,b);for(var c=Object.keys(b),e=0,f;e
";/* toggle_autofit &&*/ -var m="theme download play page close autofit zoom-in zoom-out arrow-left arrow-right fullscreen".split(" "),ha={page:1,close:1,autofit:1,"zoom-in":1,"zoom-out":1,"arrow-left":1,"arrow-right":1,fullscreen:1},ia={},ja=document.createElement("video"),ka={},n,p,la,ma,r,na,t,u,v,oa,pa,qa,w,x,y,z,A,ra,B,sa,ta,ua,va,C,D,wa,xa,ya,za,Aa,E,F,G,H,I,Ba,Ca,Da,Ea,Fa,Ga,J,Ha,Ia,K,L,M,Ja,N,O,Ka,P,La;h(document,"click",Ma); -function Na(){function a(d){return ia[d]=(l||document).getElementsByClassName("spl-"+d)[0]}N=document.body;I=a("scene");Ba=a("footer");Ca=a("title");Da=a("description");Ea=a("button");Fa=a("arrow-left");Ga=a("arrow-right");J=a("fullscreen");Ha=a("page");Ia=a("play");K=a("progress");G=[a("pane")];N[P="requestFullscreen"]||N[P="msRequestFullscreen"]||N[P="webkitRequestFullscreen"]||N[P="mozRequestFullscreen"]||(P="");P?La=P.replace("request","exit").replace("mozRequest","mozCancel").replace("Request", -"Exit"):(m.pop(),Q(J,!1));var b=a("track");h(b,"mousedown",Oa);h(b,"mousemove",Pa);h(b,"mouseleave",Qa);h(b,"mouseup",Qa);h(b,"touchstart",Oa,{passive:!1});h(b,"touchmove",Pa,{passive:!0});h(b,"touchend",Qa);h(J,"click",Ra);h(Fa,"click",Sa);h(Ga,"click",R);h(Ia,"click",S);h(a("autofit"),"click",T);h(a("zoom-in"),"click",Ta);h(a("zoom-out"),"click",Ua);h(a("close"),"click",Va);h(a("download"),"click",Wa);h(a("theme"),"click",Xa)} -function Ma(a){var b=a.target.closest(".spotlight");if(b){k(a,!0);a=b.closest(".spotlight-group");z=(a||document).getElementsByClassName("spotlight");for(var d=0;d.5*(0>a?1:a?-1:0)?Ua():Ta())}function S(a){("boolean"===typeof a?a:!L)?L||(L=setInterval(R,1E3*xa),Ia.classList.add("on"),sa&&jb(!0)):L&&(L=clearInterval(L),c(Ia,"on"),sa&&jb())} -function jb(a){ea(K,function(){g(K,"transition-duration","");g(K,"transform","")});a&&(g(K,"transition-duration",xa+"s"),g(K,"transform","translateX(0)"))}function V(){va&&(Ja=Date.now()+1E3*va-50,M||(l.classList.add("menu"),kb(1E3*va)))}function kb(a){M=setTimeout(function(){var b=Date.now();b>=Ja?(c(l,"menu"),M=0):kb(Ja-b)},a)}function lb(a){"boolean"===typeof a&&(M=a?M:0);M?(M=clearTimeout(M),c(l,"menu")):V()} -function Oa(a){k(a,!0);oa=!0;pa=!1;var b=a.touches;b&&(b=b[0])&&(a=b);qa=t*v<=r;la=a.pageX;ma=a.pageY;U(F)}function Qa(a){k(a);if(oa){if(pa){if(qa&&pa){var b=(a=n<-(r/7)&&(xr/7&&(1b?n=b:n<-b&&(n=-b),u*v>na&&(b=(u*v-na)/2,p-=ma-(ma=a.pageY),p>b?p=b:p<-b&&(p=-b)));pa=!0;X(n,p)}else V()} -function Ra(a){("boolean"===typeof a?a:document.fullscreen||document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement)?(document[La](),c(J,"on")):(l[P](),J.classList.add("on"))}function Xa(a){"object"===typeof a&&(a=D?"":"white");D!==a&&(D&&c(l,D),a&&l.classList.add(a),D=a)}function T(a){"boolean"===typeof a&&(w=!a);(w=1===v&&!w)?H.classList.add("autofit"):c(H,"autofit");g(H,"transform","");t=H.width;u=H.height;v=1;p=n=0;U(F);X();V()} -function Ta(a){var b=v/.65;50>=b&&(w&&T(),n/=.65,p/=.65,X(n,p),mb(b));a||V()}function Ua(a){var b=.65*v;w&&T();1<=b&&(1===b?n=p=0:(n*=.65,p*=.65),X(n,p),mb(b));a||V()}function mb(a){v=a||1;g(H,"transform","translate(-50%, -50%) scale("+v+")")}function Wa(){var a=document.createElement("a");a.href=H.src;a.download=H.src.substring(H.src.lastIndexOf("/")+1);N.appendChild(a);a.click();N.removeChild(a)} -function Va(a){setTimeout(function(){N.removeChild(l);F=H=O=A=ra=z=ta=null},200);c(N,"hide-scrollbars");c(l,"show");bb();history.go(!0===a?-1:-2);L&&S(!1);H&&H.parentNode&&H.parentNode.removeChild(H)}function Sa(a){a&&V();if(1x;x=a;$a(b);return!0}} -var nb=navigator.connection,ob=window.devicePixelRatio||1;function pb(a,b,d){var e;if("video"===H||!(e=d.src||d.href||a.src||a.href)){a=Object.keys(d);for(var f=0,q;f.5*(0>a?1:a?-1:0)?Xa():Wa())}function S(a){("boolean"===typeof a?a:!N)?N||(N=setInterval(T,1E3*Ba),Oa.classList.add("on"),sa&&pb(!0)):N&&(N=clearInterval(N),d(Oa,"on"),sa&&pb())} +function pb(a){ea(L,function(){g(L,"transition-duration","");g(L,"transform","")});a&&(g(L,"transition-duration",Ba+"s"),g(L,"transform","translateX(0)"))}function V(){xa&&(Qa=Date.now()+1E3*xa-50,O||(k.classList.add("menu"),qb(1E3*xa)))}function qb(a){O=setTimeout(function(){var b=Date.now();b>=Qa?(d(k,"menu"),O=0):qb(Qa-b)},a)}function rb(a){"boolean"===typeof a&&(O=a?O:0);O?(O=clearTimeout(O),d(k,"menu")):V()} +function ab(a){ha(a,!0);pa=!0;qa=!1;var b=a.touches;b&&(b=b[0])&&(a=b);ra=t*v<=r;ma=a.pageX;na=a.pageY;U(H)}function cb(a){ha(a);if(pa){if(qa){if(ra&&qa){var b=(a=n<-(r/7)&&(xr/7&&(1b?n=b:n<-b&&(n=-b),u*v>oa&&(b=(u*v-oa)/2,p-=na-(na=a.pageY),p>b?p=b:p<-b&&(p=-b)));qa=!0;X(n,p)}else V()} +function Va(a){("boolean"===typeof a?a:document.fullscreen||document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement)?(document[Ra](),d(Ma,"on")):(k[P](),Ma.classList.add("on"))}function Ya(a){"object"===typeof a&&(a=E?"":"white");E!==a&&(E&&d(k,E),a&&k.classList.add(a),E=a)}function R(a){"boolean"===typeof a&&(w=!a);(w=1===v&&!w)?J.classList.add("autofit"):d(J,"autofit");g(J,"transform","");t=J.width;u=J.height;v=1;p=n=0;U(H);X();V()} +function Wa(a){var b=v/.65;50>=b&&(w&&R(),n/=.65,p/=.65,X(n,p),sb(b));a||V()}function Xa(a){var b=.65*v;w&&R();1<=b&&(1===b?n=p=0:(n*=.65,p*=.65),X(n,p),sb(b));a||V()}function sb(a){v=a||1;g(J,"transform","translate(-50%, -50%) scale("+v+")")}function Za(){var a=document.createElement("a");a.href=J.src;a.download=J.src.substring(J.src.lastIndexOf("/")+1);G.appendChild(a);a.click();G.removeChild(a)} +function Ua(a){setTimeout(function(){G.removeChild(k);H=J=M=A=B=z=ta=ua=va=Aa=null},200);d(G,"hide-scrollbars");d(k,"show");hb();history.go(!0===a?-1:-2);N&&S(!1);J&&tb(J);va&&va()}function tb(a){if(a.g)a.g.appendChild(a),a.g=null;else{var b=a.parentNode;b&&b.removeChild(a)}}function $a(a){a&&V();if(1x;x=a;fb(b);return!0}}var ub=navigator.connection,vb=window.devicePixelRatio||1; +function wb(a,b,c){var e;if("video"===J||!(e=c.src||c.href||a.src||a.href)){a=Object.keys(c);for(var f=0,q;f--> - + + + + + + + + + + + + + +
@@ -25,11 +38,11 @@

Spotlight.js: Modern HTML5 Image Gallery

Goto Github
-

+
+
Anchors & Images
API Call
- Choose Features:

- - - - - - -
- - - - - - -
- - - - - -

+ Choose Controls (Toolbar):

+
+ + + + + + +
+ + + + +
+
+ Choose Modifier:

+
+ + +
+ + + + + +
+
Choose Animation:

- - - - +
+ + + + +


-
+
-
+
-
+
@@ -120,58 +135,33 @@



\ No newline at end of file diff --git a/package.json b/package.json index 43bb1de..5f71877 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,28 @@ { "name": "spotlight.js", - "version": "0.7.0", + "version": "0.7.1", "description": "Modern HTML5 Image Gallery", "homepage": "https://github.com/nextapps-de/spotlight/", "author": "Thomas Wilkerling", "copyright": "Nextapps GmbH", "license": "Apache-2.0", - "keywords": [], + "keywords": [ + "gallery", + "lightbox", + "photo-gallery", + "javascript-library", + "image-viewer", + "image-gallery", + "lightbox-gallery-plugin", + "gallery-plugin", + "gallery-extension", + "gallery-widget", + "lightbox-gallery", + "gallery-template", + "gallery-viewer", + "gallery-simple", + "lightbox-plugin" + ], "bugs": { "url": "https://github.com/nextapps-de/spotlight/issues", "email": "info@nextapps.de" diff --git a/src/css/spotlight.less b/src/css/spotlight.less index 8fba2bc..7504edf 100644 --- a/src/css/spotlight.less +++ b/src/css/spotlight.less @@ -192,6 +192,7 @@ } .spl-button{ display: inline-block; + //text-decoration: none; background: #fff; color: #000; border-radius: 5px; diff --git a/src/js/spotlight.js b/src/js/spotlight.js index de697f0..0ae5eb3 100644 --- a/src/js/spotlight.js +++ b/src/js/spotlight.js @@ -36,8 +36,9 @@ const controls_default = { "fullscreen": 1 }; +const tpl_video = document.createElement("video"); +const tpl_control = document.createElement("div"); const controls_dom = {}; -const video = document.createElement("video"); const video_support = {}; let x; @@ -62,12 +63,16 @@ let options; let options_group; let options_infinite; let options_progress; +let options_onshow; let options_onchange; +let options_onclose; let options_fit; let options_autohide; let options_autoplay; let options_theme; let options_preload; +let options_href; +let options_click; let delay; let animation_scale; @@ -75,10 +80,12 @@ let animation_fade; let animation_slide; let animation_custom; +let body; let panel; let panes; let media; let slider; +let header; let footer; let title; let description; @@ -89,14 +96,12 @@ let maximize; let page; let player; let progress; -let track; +let gallery; +let gallery_next; let playing; let hide; let hide_cooldown; -let body; -let gallery; -let gallery_next; let prefix_request, prefix_exit; @@ -121,24 +126,25 @@ const keycodes = { addListener(document, "click", dispatch); -function init(){ +function setup(){ //console.log("init"); body = document.body; slider = getOneByClass("scene"); + header = getOneByClass("header"); footer = getOneByClass("footer"); title = getOneByClass("title"); description = getOneByClass("description"); button = getOneByClass("button"); arrow_left = getOneByClass("arrow-left"); arrow_right = getOneByClass("arrow-right"); - maximize = getOneByClass("fullscreen"); page = getOneByClass("page"); - player = getOneByClass("play"); progress = getOneByClass("progress"); panes = [getOneByClass("pane")]; + addControl("close", close); + body[prefix_request = "requestFullscreen"] || body[prefix_request = "msRequestFullscreen"] || body[prefix_request = "webkitRequestFullscreen"] || @@ -153,17 +159,30 @@ function init(){ .replace("mozRequest", "mozCancel") .replace("Request", "Exit") ); + + maximize = addControl("fullscreen", fullscreen); } else{ controls.pop(); // => "fullscreen" - display_state(maximize, false); } - // binding the tracking listeners to the "widget" will prevent all click listeners to be fired - // binding the tracking listeners to the "spl-scene" breaks on iOS (seems to be a bug in their visual/touchable overflow calculation) - // binding the tracking listeners to a wrapper "track" will fix both - // the spinner element could not be used, it is below the widget to allow user actions (pointers) + addControl("autofit", autofit); + addControl("zoom-in", zoom_in); + addControl("zoom-out", zoom_out); + addControl("theme", theme); + player = addControl("play", play); + addControl("download", download); + + addListener(arrow_left, "click", prev); + addListener(arrow_right, "click", next); + + /* + * binding the tracking listeners to the "widget" will prevent all click listeners to be fired + * binding the tracking listeners to the "spl-scene" breaks on iOS (seems to be a bug in their visual/touchable overflow calculation) + * binding the tracking listeners to a wrapper "track" will fix both + * the spinner element could not be used, it is below the widget to allow user actions (pointers) + */ const track = getOneByClass("track"); @@ -179,28 +198,50 @@ function init(){ // click listener for the wrapper "track" is already covered //addListener(track, "click", menu); - addListener(maximize, "click", fullscreen); - addListener(arrow_left, "click", prev); - addListener(arrow_right, "click", next); - addListener(player, "click", play); + addListener(button, "click", function(){ - addListener(getOneByClass("autofit"), "click", autofit); - addListener(getOneByClass("zoom-in"), "click", zoom_in); - addListener(getOneByClass("zoom-out"), "click", zoom_out); - addListener(getOneByClass("close"), "click", close); - addListener(getOneByClass("download"), "click", download); - addListener(getOneByClass("theme"), "click", theme); + if(options_click){ + + options_click(current_slide, options); + } + else if(options_href){ + + location.href = options_href; + } + }); /** - * @param {string} class_name + * @param {string} classname * @returns {HTMLElement} */ - function getOneByClass(class_name){ + function getOneByClass(classname){ //console.log("getOneByClass", class_name); - return controls_dom[class_name] = getByClass("spl-" + class_name, widget)[0]; + return controls_dom[classname] = getByClass("spl-" + classname, widget)[0]; + } +} + +export function addControl(classname, fn){ + + const div = tpl_control.cloneNode(false); + + div.className = "spl-" + classname; + addListener(div, "click", fn); + header.appendChild(div); + + return controls_dom[classname] = div; +} + +export function removeControl(classname){ + + const div = controls_dom[classname]; + + if(div){ + + header.removeChild(div); + controls_dom[classname] = null; } } @@ -224,7 +265,8 @@ function dispatch(event){ if(anchors[i] === target){ - show(anchors, group ? group.dataset : {}, i + 1); + options_group = group && group.dataset; + init_gallery(i + 1); break; } } @@ -233,20 +275,27 @@ function dispatch(event){ /** * @param {!HTMLCollection|Array} gallery - * @param {Object=} config + * @param {Object=} group * @param {number=} index */ -export function show(gallery, config, index){ +export function show(gallery, group, index){ //console.log("show", gallery, config); anchors = gallery; - options_group = config || (config = {}); - options_onchange = config["onchange"]; - init_gallery(index || config["index"]); - show_gallery(); + if(group){ + + options_group = group; + options_onshow = group["onshow"]; + options_onchange = group["onchange"]; + options_onclose = group["onclose"]; + options_click = group["onclick"]; + index = index || group["index"]; + } + + init_gallery(index); } function init_gallery(index){ @@ -257,7 +306,8 @@ function init_gallery(index){ if(slide_count){ - body || init(); + body || setup(); + options_onshow && options_onshow(index); const pane = panes[0]; const parent = pane.parentNode; @@ -280,6 +330,7 @@ function init_gallery(index){ current_slide = index || 1; disable_animation(slider); setup_page(true); + show_gallery(); } } @@ -311,7 +362,7 @@ function apply_options(anchor){ //console.log("apply_options", anchor); options = {}; - Object.assign(options, options_group); + options_group && Object.assign(options, options_group); Object.assign(options, anchor.dataset || anchor); // apply theme before controls (including control "theme") applies to the options @@ -322,6 +373,7 @@ function apply_options(anchor){ options_progress = parse_option("progress", true); options_autoplay = parse_option("autoplay"); options_preload = parse_option("preload", true); + options_href = parse_option("buttonHref"); if(options_autoplay){ @@ -653,11 +705,11 @@ function history_listener(event) { //console.log("history_listener"); - if(panel && event.state && event.state["spl"]) { + if(panel && /*event.state &&*/ event.state["spl"]) { close(true); - history.back(); - cancelEvent(event); + //history.back(); + //cancelEvent(event, true); } } @@ -1190,7 +1242,7 @@ export function close(hashchange){ setTimeout(function(){ body.removeChild(widget); - panel = media = gallery = options = options_group = anchors = options_onchange = null; + panel = media = gallery = options = options_group = anchors = options_onshow = options_onchange = options_onclose = options_click = null; }, 200); @@ -1210,10 +1262,14 @@ export function close(hashchange){ checkout(media); } + + options_onclose && options_onclose(); } function checkout(media){ + //console.log("checkout"); + if(media._root){ media._root.appendChild(media); @@ -1333,7 +1389,7 @@ function determine_src(anchor, size, options){ break; } } - else if(video.canPlayType("video/" + key.substring(3).toLowerCase())){ + else if(tpl_video.canPlayType("video/" + key.substring(3).toLowerCase())){ video_support[key] = 1; src = options[key]; @@ -1397,14 +1453,12 @@ function prepare(){ if((anchor = anchors[current_slide])){ const options_next = anchor.dataset || anchor; - const type = !options_next["media"] || (options_next["media"] === "image"); + const next_is_image = !options_next["media"] || (options_next["media"] === "image"); - if(type) gallery_next = //{ + if(next_is_image){ - //media: options_next["media"], - //src: - determine_src(anchor, size, options_next) - //}; + gallery_next = determine_src(anchor, size, options_next); + } } } @@ -1416,7 +1470,7 @@ function prepare(){ //console.log(option + ": ", options[option]); - display_state(controls_dom[option], parse_option(option) || controls_default[option]); + display_state(controls_dom[option], parse_option(option, controls_default[option])); } } @@ -1439,8 +1493,6 @@ function setup_page(direction){ if(ref && (media !== ref)){ - //console.log("ref.parentNode.removeChild(ref)"); - checkout(ref); ref = null; } @@ -1517,5 +1569,7 @@ export default { zoom: zoom, menu: menu, show: show, - play: play + play: play, + addControl: addControl, + removeControl: removeControl }; \ No newline at end of file diff --git a/src/js/template.js b/src/js/template.js index bb0c6a0..bf94e06 100644 --- a/src/js/template.js +++ b/src/js/template.js @@ -13,6 +13,8 @@ template.innerHTML = ( '

' + '
' + '
' + + // added via addControl() + /* '
' + '
' + '
' + @@ -21,6 +23,7 @@ template.innerHTML = ( '
' + '
' + '
' + + */ '
' + '
' + '
' + diff --git a/src/js/webpack.js b/src/js/webpack.js index d1fd7e6..d2a8c47 100644 --- a/src/js/webpack.js +++ b/src/js/webpack.js @@ -12,5 +12,7 @@ import Spotlight from "./spotlight.js"; /** @export */ Spotlight.menu; /** @export */ Spotlight.show; /** @export */ Spotlight.play; +/** @export */ Spotlight.addControl; +/** @export */ Spotlight.removeControl; window["Spotlight"] = Spotlight; \ No newline at end of file