Comparing version 1.3.1 to 1.3.2
# Changelog | ||
## 1.3.2 (Jan 24, 2019) | ||
- Fix `Document not active` error when call the `exit` method. | ||
- Improve wheel event listening for better performance (#102). | ||
## 1.3.1 (Dec 9, 2018) | ||
@@ -4,0 +9,0 @@ |
/*! | ||
* Viewer.js v1.3.1 | ||
* Viewer.js v1.3.2 | ||
* https://fengyuanchen.github.io/viewerjs | ||
@@ -8,4 +8,4 @@ * | ||
* | ||
* Date: 2018-12-09T07:48:29.436Z | ||
* Date: 2019-01-24T11:01:33.473Z | ||
*/ | ||
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):t.Viewer=i()}(this,function(){"use strict";function i(t){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function s(t,i){for(var e=0;e<i.length;e++){var n=i[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var o={backdrop:!0,button:!0,navbar:!0,title:!0,toolbar:!0,className:"",container:"body",filter:null,fullscreen:!0,initialViewIndex:0,inline:!1,interval:5e3,keyboard:!0,loading:!0,loop:!0,minWidth:200,minHeight:100,movable:!0,zoomable:!0,rotatable:!0,scalable:!0,toggleOnDblclick:!0,tooltip:!0,transition:!0,zIndex:2015,zIndexInline:0,zoomRatio:.1,minZoomRatio:.01,maxZoomRatio:100,url:"src",ready:null,show:null,shown:null,hide:null,hidden:null,view:null,viewed:null,zoom:null,zoomed:null},a="undefined"!=typeof window,r=a?window:{},h=!!a&&"ontouchstart"in r.document.documentElement,t=!!a&&"PointerEvent"in r,p="viewer",c="move",d="switch",u="zoom",m="".concat(p,"-active"),w="".concat(p,"-close"),b="".concat(p,"-fade"),y="".concat(p,"-fixed"),x="".concat(p,"-fullscreen"),l="".concat(p,"-fullscreen-exit"),k="".concat(p,"-hide"),e="".concat(p,"-hide-md-down"),n="".concat(p,"-hide-sm-down"),f="".concat(p,"-hide-xs-down"),g="".concat(p,"-in"),z="".concat(p,"-invisible"),v="".concat(p,"-loading"),D="".concat(p,"-move"),T="".concat(p,"-open"),I="".concat(p,"-show"),E="".concat(p,"-transition"),S="click",C="dblclick",L="dragstart",N="hidden",M="hide",R="keydown",Y="load",X=t?"pointerdown":h?"touchstart":"mousedown",O=t?"pointermove":h?"touchmove":"mousemove",q=t?"pointerup pointercancel":h?"touchend touchcancel":"mouseup",F="ready",W="resize",A="show",P="shown",H="transitionend",j="view",V="viewed",B="wheel mousewheel DOMMouseScroll",K="".concat(p,"Action"),U=/\s\s*/,Z=["zoom-in","zoom-out","one-to-one","reset","prev","play","next","rotate-left","rotate-right","flip-horizontal","flip-vertical"];function $(t){return"string"==typeof t}var _=Number.isNaN||r.isNaN;function G(t){return"number"==typeof t&&!_(t)}function J(t){return void 0===t}function Q(t){return"object"===i(t)&&null!==t}var tt=Object.prototype.hasOwnProperty;function it(t){if(!Q(t))return!1;try{var i=t.constructor,e=i.prototype;return i&&e&&tt.call(e,"isPrototypeOf")}catch(t){return!1}}function et(t){return"function"==typeof t}function nt(i,e){if(i&&et(e))if(Array.isArray(i)||G(i.length)){var t,n=i.length;for(t=0;t<n&&!1!==e.call(i,i[t],t,i);t+=1);}else Q(i)&&Object.keys(i).forEach(function(t){e.call(i,i[t],t,i)});return i}var st=Object.assign||function(e){for(var t=arguments.length,i=new Array(1<t?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];return Q(e)&&0<i.length&&i.forEach(function(i){Q(i)&&Object.keys(i).forEach(function(t){e[t]=i[t]})}),e},ot=/^(?:width|height|left|top|marginLeft|marginTop)$/;function at(t,i){var e=t.style;nt(i,function(t,i){ot.test(i)&&G(t)&&(t+="px"),e[i]=t})}function rt(t,i){if(i)if(G(t.length))nt(t,function(t){rt(t,i)});else if(t.classList)t.classList.add(i);else{var e=t.className.trim();e?e.indexOf(i)<0&&(t.className="".concat(e," ").concat(i)):t.className=i}}function ht(t,i){i&&(G(t.length)?nt(t,function(t){ht(t,i)}):t.classList?t.classList.remove(i):0<=t.className.indexOf(i)&&(t.className=t.className.replace(i,"")))}function lt(t,i,e){i&&(G(t.length)?nt(t,function(t){lt(t,i,e)}):e?rt(t,i):ht(t,i))}var ct=/([a-z\d])([A-Z])/g;function dt(t){return t.replace(ct,"$1-$2").toLowerCase()}function ut(t,i){return Q(t[i])?t[i]:t.dataset?t.dataset[i]:t.getAttribute("data-".concat(dt(i)))}function mt(t,i,e){Q(e)?t[i]=e:t.dataset?t.dataset[i]=e:t.setAttribute("data-".concat(dt(i)),e)}var ft=function(){var t=!1;if(a){var i=!1,e=function(){},n=Object.defineProperty({},"once",{get:function(){return t=!0,i},set:function(t){i=t}});r.addEventListener("test",e,n),r.removeEventListener("test",e,n)}return t}();function gt(e,t,n){var s=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{},o=n;t.trim().split(U).forEach(function(t){if(!ft){var i=e.listeners;i&&i[t]&&i[t][n]&&(o=i[t][n],delete i[t][n],0===Object.keys(i[t]).length&&delete i[t],0===Object.keys(i).length&&delete e.listeners)}e.removeEventListener(t,o,s)})}function vt(o,t,a){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{},h=a;t.trim().split(U).forEach(function(n){if(r.once&&!ft){var t=o.listeners,s=void 0===t?{}:t;h=function(){delete s[n][a],o.removeEventListener(n,h,r);for(var t=arguments.length,i=new Array(t),e=0;e<t;e++)i[e]=arguments[e];a.apply(o,i)},s[n]||(s[n]={}),s[n][a]&&o.removeEventListener(n,s[n][a],r),s[n][a]=h,o.listeners=s}o.addEventListener(n,h,r)})}function pt(t,i,e){var n;return et(Event)&&et(CustomEvent)?n=new CustomEvent(i,{detail:e,bubbles:!0,cancelable:!0}):(n=document.createEvent("CustomEvent")).initCustomEvent(i,!0,!0,e),t.dispatchEvent(n)}function wt(t){var i=t.rotate,e=t.scaleX,n=t.scaleY,s=t.translateX,o=t.translateY,a=[];G(s)&&0!==s&&a.push("translateX(".concat(s,"px)")),G(o)&&0!==o&&a.push("translateY(".concat(o,"px)")),G(i)&&0!==i&&a.push("rotate(".concat(i,"deg)")),G(e)&&1!==e&&a.push("scaleX(".concat(e,")")),G(n)&&1!==n&&a.push("scaleY(".concat(n,")"));var r=a.length?a.join(" "):"none";return{WebkitTransform:r,msTransform:r,transform:r}}var bt=r.navigator&&/(Macintosh|iPhone|iPod|iPad).*AppleWebKit/i.test(r.navigator.userAgent);function yt(t,i){var e=document.createElement("img");if(t.naturalWidth&&!bt)return i(t.naturalWidth,t.naturalHeight),e;var n=document.body||document.documentElement;return e.onload=function(){i(e.width,e.height),bt||n.removeChild(e)},e.src=t.src,bt||(e.style.cssText="left:0;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;opacity:0;position:absolute;top:0;z-index:-1;",n.appendChild(e)),e}function xt(t){switch(t){case 2:return f;case 3:return n;case 4:return e;default:return""}}function kt(t,i){var e=t.pageX,n=t.pageY,s={endX:e,endY:n};return i?s:st({timeStamp:Date.now(),startX:e,startY:n},s)}var zt={render:function(){this.initContainer(),this.initViewer(),this.initList(),this.renderViewer()},initContainer:function(){this.containerData={width:window.innerWidth,height:window.innerHeight}},initViewer:function(){var t,i=this.options,e=this.parent;i.inline&&(t={width:Math.max(e.offsetWidth,i.minWidth),height:Math.max(e.offsetHeight,i.minHeight)},this.parentData=t),!this.fulled&&t||(t=this.containerData),this.viewerData=st({},t)},renderViewer:function(){this.options.inline&&!this.fulled&&at(this.viewer,this.viewerData)},initList:function(){var a=this,t=this.element,r=this.options,i=this.list,h=[];nt(this.images,function(t,i){var e,n=t.src,s=t.alt||($(e=n)?e.replace(/^.*\//,"").replace(/[?&#].*$/,""):""),o=r.url;$(o)?o=t.getAttribute(o):et(o)&&(o=o.call(a,t)),(n||o)&&h.push("<li><img"+' src="'.concat(n||o,'"')+' role="button" data-viewer-action="view"'+' data-index="'.concat(i,'"')+' data-original-url="'.concat(o||n,'"')+' alt="'.concat(s,'"')+"></li>")}),i.innerHTML=h.join(""),this.items=i.getElementsByTagName("li"),nt(this.items,function(i){var t=i.firstElementChild;mt(t,"filled",!0),r.loading&&rt(i,v),vt(t,Y,function(t){r.loading&&ht(i,v),a.loadImage(t)},{once:!0})}),r.transition&&vt(t,V,function(){rt(i,E)},{once:!0})},renderList:function(t){var i=t||this.index,e=this.items[i].offsetWidth||30,n=e+1;at(this.list,st({width:n*this.length},wt({translateX:(this.viewerData.width-e)/2-n*i})))},resetList:function(){var t=this.list;t.innerHTML="",ht(t,E),at(t,wt({translateX:0}))},initImage:function(r){var t,h=this,l=this.options,i=this.image,e=this.viewerData,n=this.footer.offsetHeight,c=e.width,d=Math.max(e.height-n,n),u=this.imageData||{};this.imageInitializing={abort:function(){t.onload=null}},t=yt(i,function(t,i){var e=t/i,n=c,s=d;h.imageInitializing=!1,c<d*e?s=c/e:n=d*e;var o={naturalWidth:t,naturalHeight:i,aspectRatio:e,ratio:(n=Math.min(.9*n,t))/t,width:n,height:s=Math.min(.9*s,i),left:(c-n)/2,top:(d-s)/2},a=st({},o);l.rotatable&&(o.rotate=u.rotate||0,a.rotate=0),l.scalable&&(o.scaleX=u.scaleX||1,o.scaleY=u.scaleY||1,a.scaleX=1,a.scaleY=1),h.imageData=o,h.initialImageData=a,r&&r()})},renderImage:function(t){var i=this,e=this.image,n=this.imageData;if(at(e,st({width:n.width,height:n.height,marginLeft:n.left,marginTop:n.top},wt(n))),t)if((this.viewing||this.zooming)&&this.options.transition){var s=function(){i.imageRendering=!1,t()};this.imageRendering={abort:function(){gt(e,H,s)}},vt(e,H,s,{once:!0})}else t()},resetImage:function(){if(this.viewing||this.viewed){var t=this.image;this.viewing&&this.viewing.abort(),t.parentNode.removeChild(t),this.image=null}}},Dt={bind:function(){var t=this.options,i=this.viewer,e=this.canvas,n=this.element.ownerDocument;vt(i,S,this.onClick=this.click.bind(this)),vt(i,B,this.onWheel=this.wheel.bind(this)),vt(i,L,this.onDragStart=this.dragstart.bind(this)),vt(e,X,this.onPointerDown=this.pointerdown.bind(this)),vt(n,O,this.onPointerMove=this.pointermove.bind(this)),vt(n,q,this.onPointerUp=this.pointerup.bind(this)),vt(n,R,this.onKeyDown=this.keydown.bind(this)),vt(window,W,this.onResize=this.resize.bind(this)),t.toggleOnDblclick&&vt(e,C,this.onDblclick=this.dblclick.bind(this))},unbind:function(){var t=this.options,i=this.viewer,e=this.canvas,n=this.element.ownerDocument;gt(i,S,this.onClick),gt(i,B,this.onWheel),gt(i,L,this.onDragStart),gt(e,X,this.onPointerDown),gt(n,O,this.onPointerMove),gt(n,q,this.onPointerUp),gt(n,R,this.onKeyDown),gt(window,W,this.onResize),t.toggleOnDblclick&>(e,C,this.onDblclick)}},Tt={click:function(t){var i=t.target,e=this.options,n=this.imageData,s=ut(i,K);switch(h&&t.isTrusted&&i===this.canvas&&clearTimeout(this.clickCanvasTimeout),s){case"mix":this.played?this.stop():e.inline?this.fulled?this.exit():this.full():this.hide();break;case"hide":this.hide();break;case"view":this.view(ut(i,"index"));break;case"zoom-in":this.zoom(.1,!0);break;case"zoom-out":this.zoom(-.1,!0);break;case"one-to-one":this.toggle();break;case"reset":this.reset();break;case"prev":this.prev(e.loop);break;case"play":this.play(e.fullscreen);break;case"next":this.next(e.loop);break;case"rotate-left":this.rotate(-90);break;case"rotate-right":this.rotate(90);break;case"flip-horizontal":this.scaleX(-n.scaleX||-1);break;case"flip-vertical":this.scaleY(-n.scaleY||-1);break;default:this.played&&this.stop()}},dblclick:function(t){t.preventDefault(),this.viewed&&t.target===this.image&&(h&&t.isTrusted&&clearTimeout(this.doubleClickImageTimeout),this.toggle())},load:function(){var t=this;this.timeout&&(clearTimeout(this.timeout),this.timeout=!1);var i=this.element,e=this.options,n=this.image,s=this.index,o=this.viewerData;ht(n,z),e.loading&&ht(this.canvas,v),n.style.cssText="height:0;"+"margin-left:".concat(o.width/2,"px;")+"margin-top:".concat(o.height/2,"px;")+"max-width:none!important;position:absolute;width:0;",this.initImage(function(){lt(n,D,e.movable),lt(n,E,e.transition),t.renderImage(function(){t.viewed=!0,t.viewing=!1,et(e.viewed)&&vt(i,V,e.viewed,{once:!0}),pt(i,V,{originalImage:t.images[s],index:s,image:n})})})},loadImage:function(t){var o=t.target,i=o.parentNode,a=i.offsetWidth||30,r=i.offsetHeight||50,h=!!ut(o,"filled");yt(o,function(t,i){var e=t/i,n=a,s=r;a<r*e?h?n=r*e:s=a/e:h?s=a/e:n=r*e,at(o,st({width:n,height:s},wt({translateX:(a-n)/2,translateY:(r-s)/2})))})},keydown:function(t){var i=this.options;if(this.fulled&&i.keyboard)switch(t.keyCode||t.which||t.charCode){case 27:this.played?this.stop():i.inline?this.fulled&&this.exit():this.hide();break;case 32:this.played&&this.stop();break;case 37:this.prev(i.loop);break;case 38:t.preventDefault(),this.zoom(i.zoomRatio,!0);break;case 39:this.next(i.loop);break;case 40:t.preventDefault(),this.zoom(-i.zoomRatio,!0);break;case 48:case 49:t.ctrlKey&&(t.preventDefault(),this.toggle())}},dragstart:function(t){"img"===t.target.tagName.toLowerCase()&&t.preventDefault()},pointerdown:function(t){var i=this.options,e=this.pointers,n=t.buttons,s=t.button;if(!(!this.viewed||this.showing||this.viewing||this.hiding||G(n)&&1<n||G(s)&&0<s||t.ctrlKey)){t.preventDefault(),t.changedTouches?nt(t.changedTouches,function(t){e[t.identifier]=kt(t)}):e[t.pointerId||0]=kt(t);var o=!!i.movable&&c;1<Object.keys(e).length?o=u:"touch"!==t.pointerType&&"touchstart"!==t.type||!this.isSwitchable()||(o=d),!i.transition||o!==c&&o!==u||ht(this.image,E),this.action=o}},pointermove:function(t){var i=this.pointers,e=this.action;this.viewed&&e&&(t.preventDefault(),t.changedTouches?nt(t.changedTouches,function(t){st(i[t.identifier]||{},kt(t,!0))}):st(i[t.pointerId||0]||{},kt(t,!0)),this.change(t))},pointerup:function(t){var i,e=this,n=this.options,s=this.action,o=this.pointers;t.changedTouches?nt(t.changedTouches,function(t){i=o[t.identifier],delete o[t.identifier]}):(i=o[t.pointerId||0],delete o[t.pointerId||0]),s&&(t.preventDefault(),!n.transition||s!==c&&s!==u||rt(this.image,E),this.action=!1,h&&s!==u&&i&&Date.now()-i.timeStamp<500&&(clearTimeout(this.clickCanvasTimeout),clearTimeout(this.doubleClickImageTimeout),n.toggleOnDblclick&&this.viewed&&t.target===this.image?this.imageClicked?(this.imageClicked=!1,this.doubleClickImageTimeout=setTimeout(function(){pt(e.image,C)},50)):(this.imageClicked=!0,this.doubleClickImageTimeout=setTimeout(function(){e.imageClicked=!1},500)):(this.imageClicked=!1,n.backdrop&&"static"!==n.backdrop&&t.target===this.canvas&&(this.clickCanvasTimeout=setTimeout(function(){pt(e.canvas,S)},50)))))},resize:function(){var i=this;if(this.isShown&&!this.hiding&&(this.initContainer(),this.initViewer(),this.renderViewer(),this.renderList(),this.viewed&&this.initImage(function(){i.renderImage()}),this.played)){if(this.options.fullscreen&&this.fulled&&!document.fullscreenElement&&!document.mozFullScreenElement&&!document.webkitFullscreenElement&&!document.msFullscreenElement)return void this.stop();nt(this.player.getElementsByTagName("img"),function(t){vt(t,Y,i.loadImage.bind(i),{once:!0}),pt(t,Y)})}},wheel:function(t){var i=this;if(this.viewed&&(t.preventDefault(),!this.wheeling)){this.wheeling=!0,setTimeout(function(){i.wheeling=!1},50);var e=Number(this.options.zoomRatio)||.1,n=1;t.deltaY?n=0<t.deltaY?1:-1:t.wheelDelta?n=-t.wheelDelta/120:t.detail&&(n=0<t.detail?1:-1),this.zoom(-n*e,!0,t)}}},It={show:function(){var t=0<arguments.length&&void 0!==arguments[0]&&arguments[0],i=this.element,e=this.options;if(e.inline||this.showing||this.isShown||this.showing)return this;if(!this.ready)return this.build(),this.ready&&this.show(t),this;if(et(e.show)&&vt(i,A,e.show,{once:!0}),!1===pt(i,A)||!this.ready)return this;this.hiding&&this.transitioning.abort(),this.showing=!0,this.open();var n=this.viewer;if(ht(n,k),e.transition&&!t){var s=this.shown.bind(this);this.transitioning={abort:function(){gt(n,H,s),ht(n,g)}},rt(n,E),n.offsetWidth,vt(n,H,s,{once:!0}),rt(n,g)}else rt(n,g),this.shown();return this},hide:function(){var t=0<arguments.length&&void 0!==arguments[0]&&arguments[0],i=this.element,e=this.options;if(e.inline||this.hiding||!this.isShown&&!this.showing)return this;if(et(e.hide)&&vt(i,M,e.hide,{once:!0}),!1===pt(i,M))return this;this.showing&&this.transitioning.abort(),this.hiding=!0,this.played?this.stop():this.viewing&&this.viewing.abort();var n=this.viewer;if(e.transition&&!t){var s=this.hidden.bind(this),o=function(){vt(n,H,s,{once:!0}),ht(n,g)};this.transitioning={abort:function(){this.viewed?gt(this.image,H,o):gt(n,H,s)}},this.viewed?(vt(this.image,H,o,{once:!0}),this.zoomTo(0,!1,!1,!0)):o()}else ht(n,g),this.hidden();return this},view:function(){var e=this,t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.options.initialViewIndex;if(t=Number(t)||0,!this.isShown)return this.index=t,this.show();if(this.hiding||this.played||t<0||t>=this.length||this.viewed&&t===this.index)return this;this.viewing&&this.viewing.abort();var i=this.element,n=this.options,s=this.title,o=this.canvas,a=this.items[t],r=a.querySelector("img"),h=ut(r,"originalUrl"),l=r.getAttribute("alt"),c=document.createElement("img");if(c.src=h,c.alt=l,et(n.view)&&vt(i,j,n.view,{once:!0}),!1===pt(i,j,{originalImage:this.images[t],index:t,image:c})||!this.isShown||this.hiding||this.played)return this;this.image=c,ht(this.items[this.index],m),rt(a,m),this.viewed=!1,this.index=t,this.imageData={},rt(c,z),n.loading&&rt(o,v),o.innerHTML="",o.appendChild(c),this.renderList(),s.innerHTML="";var d,u=function(){var t=e.imageData,i=Array.isArray(n.title)?n.title[1]:n.title;s.innerHTML=et(i)?i.call(e,c,t):"".concat(l," (").concat(t.naturalWidth," × ").concat(t.naturalHeight,")")};return vt(i,V,u,{once:!0}),this.viewing={abort:function(){gt(i,V,u),c.complete?this.imageRendering?this.imageRendering.abort():this.imageInitializing&&this.imageInitializing.abort():(gt(c,Y,d),this.timeout&&clearTimeout(this.timeout))}},c.complete?this.load():(vt(c,Y,d=this.load.bind(this),{once:!0}),this.timeout&&clearTimeout(this.timeout),this.timeout=setTimeout(function(){ht(c,z),e.timeout=!1},1e3)),this},prev:function(){var t=0<arguments.length&&void 0!==arguments[0]&&arguments[0],i=this.index-1;return i<0&&(i=t?this.length-1:0),this.view(i),this},next:function(){var t=0<arguments.length&&void 0!==arguments[0]&&arguments[0],i=this.length-1,e=this.index+1;return i<e&&(e=t?0:i),this.view(e),this},move:function(t,i){var e=this.imageData;return this.moveTo(J(t)?t:e.left+Number(t),J(i)?i:e.top+Number(i)),this},moveTo:function(t){var i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:t,e=this.imageData;if(t=Number(t),i=Number(i),this.viewed&&!this.played&&this.options.movable){var n=!1;G(t)&&(e.left=t,n=!0),G(i)&&(e.top=i,n=!0),n&&this.renderImage()}return this},zoom:function(t){var i=1<arguments.length&&void 0!==arguments[1]&&arguments[1],e=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,n=this.imageData;return t=(t=Number(t))<0?1/(1-t):1+t,this.zoomTo(n.width*t/n.naturalWidth,i,e),this},zoomTo:function(t){var n,s,o,i,e,a=this,r=1<arguments.length&&void 0!==arguments[1]&&arguments[1],h=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,l=3<arguments.length&&void 0!==arguments[3]&&arguments[3],c=this.element,d=this.options,u=this.pointers,m=this.imageData,f=m.width,g=m.height,v=m.left,p=m.top,w=m.naturalWidth,b=m.naturalHeight;if(G(t=Math.max(0,t))&&this.viewed&&!this.played&&(l||d.zoomable)){if(!l){var y=Math.max(.01,d.minZoomRatio),x=Math.min(100,d.maxZoomRatio);t=Math.min(Math.max(t,y),x)}h&&.95<t&&t<1.05&&(t=1);var k=w*t,z=b*t,D=k-f,T=z-g,I=f/w;if(et(d.zoom)&&vt(c,"zoom",d.zoom,{once:!0}),!1===pt(c,"zoom",{ratio:t,oldRatio:I,originalEvent:h}))return this;if(this.zooming=!0,h){var E=(i=this.viewer,{left:(e=i.getBoundingClientRect()).left+(window.pageXOffset-document.documentElement.clientLeft),top:e.top+(window.pageYOffset-document.documentElement.clientTop)}),S=u&&Object.keys(u).length?(o=s=n=0,nt(u,function(t){var i=t.startX,e=t.startY;n+=i,s+=e,o+=1}),{pageX:n/=o,pageY:s/=o}):{pageX:h.pageX,pageY:h.pageY};m.left-=D*((S.pageX-E.left-v)/f),m.top-=T*((S.pageY-E.top-p)/g)}else m.left-=D/2,m.top-=T/2;m.width=k,m.height=z,m.ratio=t,this.renderImage(function(){a.zooming=!1,et(d.zoomed)&&vt(c,"zoomed",d.zoomed,{once:!0}),pt(c,"zoomed",{ratio:t,oldRatio:I,originalEvent:h})}),r&&this.tooltip()}return this},rotate:function(t){return this.rotateTo((this.imageData.rotate||0)+Number(t)),this},rotateTo:function(t){var i=this.imageData;return G(t=Number(t))&&this.viewed&&!this.played&&this.options.rotatable&&(i.rotate=t,this.renderImage()),this},scaleX:function(t){return this.scale(t,this.imageData.scaleY),this},scaleY:function(t){return this.scale(this.imageData.scaleX,t),this},scale:function(t){var i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:t,e=this.imageData;if(t=Number(t),i=Number(i),this.viewed&&!this.played&&this.options.scalable){var n=!1;G(t)&&(e.scaleX=t,n=!0),G(i)&&(e.scaleY=i,n=!0),n&&this.renderImage()}return this},play:function(){var i=this,t=0<arguments.length&&void 0!==arguments[0]&&arguments[0];if(!this.isShown||this.played)return this;var a=this.options,r=this.player,h=this.loadImage.bind(this),l=[],c=0,d=0;if(this.played=!0,this.onLoadWhenPlay=h,t&&this.requestFullscreen(),rt(r,I),nt(this.items,function(t,i){var e,n,s=t.querySelector("img"),o=document.createElement("img");o.src=ut(s,"originalUrl"),o.alt=s.getAttribute("alt"),c+=1,rt(o,b),lt(o,E,a.transition),n=m,((e=t).classList?e.classList.contains(n):-1<e.className.indexOf(n))&&(rt(o,g),d=i),l.push(o),vt(o,Y,h,{once:!0}),r.appendChild(o)}),G(a.interval)&&0<a.interval){var e=function t(){i.playing=setTimeout(function(){ht(l[d],g),rt(l[d=(d+=1)<c?d:0],g),t()},a.interval)};1<c&&e()}return this},stop:function(){var i=this;if(!this.played)return this;var t=this.player;return this.played=!1,clearTimeout(this.playing),nt(t.getElementsByTagName("img"),function(t){gt(t,Y,i.onLoadWhenPlay)}),ht(t,I),t.innerHTML="",this.exitFullscreen(),this},full:function(){var t=this,i=this.options,e=this.viewer,n=this.image,s=this.list;return!this.isShown||this.played||this.fulled||!i.inline||(this.fulled=!0,this.open(),rt(this.button,l),i.transition&&(ht(s,E),this.viewed&&ht(n,E)),rt(e,y),e.setAttribute("style",""),at(e,{zIndex:i.zIndex}),this.initContainer(),this.viewerData=st({},this.containerData),this.renderList(),this.viewed&&this.initImage(function(){t.renderImage(function(){i.transition&&setTimeout(function(){rt(n,E),rt(s,E)},0)})})),this},exit:function(){var t=this,i=this.options,e=this.viewer,n=this.image,s=this.list;return this.isShown&&!this.played&&this.fulled&&i.inline&&(this.fulled=!1,this.close(),ht(this.button,l),i.transition&&(ht(s,E),this.viewed&&ht(n,E)),ht(e,y),at(e,{zIndex:i.zIndexInline}),this.viewerData=st({},this.parentData),this.renderViewer(),this.renderList(),this.viewed&&this.initImage(function(){t.renderImage(function(){i.transition&&setTimeout(function(){rt(n,E),rt(s,E)},0)})})),this},tooltip:function(){var t=this,i=this.options,e=this.tooltipBox,n=this.imageData;return this.viewed&&!this.played&&i.tooltip&&(e.textContent="".concat(Math.round(100*n.ratio),"%"),this.tooltipping?clearTimeout(this.tooltipping):i.transition?(this.fading&&pt(e,H),rt(e,I),rt(e,b),rt(e,E),e.offsetWidth,rt(e,g)):rt(e,I),this.tooltipping=setTimeout(function(){i.transition?(vt(e,H,function(){ht(e,I),ht(e,b),ht(e,E),t.fading=!1},{once:!0}),ht(e,g),t.fading=!0):ht(e,I),t.tooltipping=!1},1e3)),this},toggle:function(){return 1===this.imageData.ratio?this.zoomTo(this.initialImageData.ratio,!0):this.zoomTo(1,!0),this},reset:function(){return this.viewed&&!this.played&&(this.imageData=st({},this.initialImageData),this.renderImage()),this},update:function(){var t=this.element,i=this.options,e=this.isImg;if(e&&!t.parentNode)return this.destroy();var s=[];if(nt(e?[t]:t.querySelectorAll("img"),function(t){i.filter?i.filter(t)&&s.push(t):s.push(t)}),!s.length)return this;if(this.images=s,this.length=s.length,this.ready){var o=[];if(nt(this.items,function(t,i){var e=t.querySelector("img"),n=s[i];n?n.src!==e.src&&o.push(i):o.push(i)}),at(this.list,{width:"auto"}),this.initList(),this.isShown)if(this.length){if(this.viewed){var n=o.indexOf(this.index);0<=n?(this.viewed=!1,this.view(Math.max(this.index-(n+1),0))):rt(this.items[this.index],m)}}else this.image=null,this.viewed=!1,this.index=0,this.imageData={},this.canvas.innerHTML="",this.title.innerHTML=""}else this.build();return this},destroy:function(){var t=this.element,i=this.options;return t[p]&&(this.destroyed=!0,this.ready?(this.played&&this.stop(),i.inline?(this.fulled&&this.exit(),this.unbind()):this.isShown?(this.viewing&&(this.imageRendering?this.imageRendering.abort():this.imageInitializing&&this.imageInitializing.abort()),this.hiding&&this.transitioning.abort(),this.hidden()):this.showing&&(this.transitioning.abort(),this.hidden()),this.ready=!1,this.viewer.parentNode.removeChild(this.viewer)):i.inline&&(this.delaying?this.delaying.abort():this.initializing&&this.initializing.abort()),i.inline||gt(t,S,this.onStart),t[p]=void 0),this}},Et={open:function(){var t=this.body;rt(t,T),t.style.paddingRight="".concat(this.scrollbarWidth+(parseFloat(this.initialBodyPaddingRight)||0),"px")},close:function(){var t=this.body;ht(t,T),t.style.paddingRight=this.initialBodyPaddingRight},shown:function(){var t=this.element,i=this.options;this.fulled=!0,this.isShown=!0,this.render(),this.bind(),this.showing=!1,et(i.shown)&&vt(t,P,i.shown,{once:!0}),!1!==pt(t,P)&&this.ready&&this.isShown&&!this.hiding&&this.view(this.index)},hidden:function(){var t=this.element,i=this.options;this.fulled=!1,this.viewed=!1,this.isShown=!1,this.close(),this.unbind(),rt(this.viewer,k),this.resetList(),this.resetImage(),this.hiding=!1,this.destroyed||(et(i.hidden)&&vt(t,N,i.hidden,{once:!0}),pt(t,N))},requestFullscreen:function(){var t=this.element.ownerDocument;if(this.fulled&&!t.fullscreenElement&&!t.mozFullScreenElement&&!t.webkitFullscreenElement&&!t.msFullscreenElement){var i=t.documentElement;i.requestFullscreen?i.requestFullscreen():i.msRequestFullscreen?i.msRequestFullscreen():i.mozRequestFullScreen?i.mozRequestFullScreen():i.webkitRequestFullscreen&&i.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT)}},exitFullscreen:function(){if(this.fulled){var t=this.element.ownerDocument;t.exitFullscreen?t.exitFullscreen():t.msExitFullscreen?t.msExitFullscreen():t.mozCancelFullScreen?t.mozCancelFullScreen():t.webkitExitFullscreen&&t.webkitExitFullscreen()}},change:function(t){var i,e,h,n=this.options,s=this.pointers,o=s[Object.keys(s)[0]],a=o.endX-o.startX,r=o.endY-o.startY;switch(this.action){case c:this.move(a,r);break;case u:this.zoom((e=st({},i=s),h=[],nt(i,function(r,t){delete e[t],nt(e,function(t){var i=Math.abs(r.startX-t.startX),e=Math.abs(r.startY-t.startY),n=Math.abs(r.endX-t.endX),s=Math.abs(r.endY-t.endY),o=Math.sqrt(i*i+e*e),a=(Math.sqrt(n*n+s*s)-o)/o;h.push(a)})}),h.sort(function(t,i){return Math.abs(t)<Math.abs(i)}),h[0]),!1,t);break;case d:this.action="switched";var l=Math.abs(a);1<l&&l>Math.abs(r)&&(this.pointers={},1<a?this.prev(n.loop):a<-1&&this.next(n.loop))}nt(s,function(t){t.startX=t.endX,t.startY=t.endY})},isSwitchable:function(){var t=this.imageData,i=this.viewerData;return 1<this.length&&0<=t.left&&0<=t.top&&t.width<=i.width&&t.height<=i.height}},St=r.Viewer,Ct=function(){function e(t){var i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(function(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this,e),!t||1!==t.nodeType)throw new Error("The first argument is required and must be an element.");this.element=t,this.options=st({},o,it(i)&&i),this.action=!1,this.fading=!1,this.fulled=!1,this.hiding=!1,this.imageClicked=!1,this.imageData={},this.index=this.options.initialViewIndex,this.isImg=!1,this.isShown=!1,this.length=0,this.played=!1,this.playing=!1,this.pointers={},this.ready=!1,this.showing=!1,this.timeout=!1,this.tooltipping=!1,this.viewed=!1,this.viewing=!1,this.wheeling=!1,this.zooming=!1,this.init()}var t,i,n;return t=e,n=[{key:"noConflict",value:function(){return window.Viewer=St,e}},{key:"setDefaults",value:function(t){st(o,it(t)&&t)}}],(i=[{key:"init",value:function(){var e=this,t=this.element,n=this.options;if(!t[p]){t[p]=this;var i="img"===t.tagName.toLowerCase(),s=[];nt(i?[t]:t.querySelectorAll("img"),function(t){et(n.filter)?n.filter.call(e,t)&&s.push(t):s.push(t)}),this.isImg=i,this.length=s.length,this.images=s;var o=t.ownerDocument,a=o.body||o.documentElement;if(this.body=a,this.scrollbarWidth=window.innerWidth-o.documentElement.clientWidth,this.initialBodyPaddingRight=window.getComputedStyle(a).paddingRight,J(document.createElement(p).style.transition)&&(n.transition=!1),n.inline){var r=0,h=function(){var t;(r+=1)===e.length&&(e.initializing=!1,e.delaying={abort:function(){clearTimeout(t)}},t=setTimeout(function(){e.delaying=!1,e.build()},0))};this.initializing={abort:function(){nt(s,function(t){t.complete||gt(t,Y,h)})}},nt(s,function(t){t.complete?h():vt(t,Y,h,{once:!0})})}else vt(t,S,this.onStart=function(t){var i=t.target;"img"!==i.tagName.toLowerCase()||et(n.filter)&&!n.filter.call(e,i)||e.view(e.images.indexOf(i))})}}},{key:"build",value:function(){if(!this.ready){var t=this.element,h=this.options,i=t.parentNode,e=document.createElement("div");e.innerHTML='<div class="viewer-container" touch-action="none"><div class="viewer-canvas"></div><div class="viewer-footer"><div class="viewer-title"></div><div class="viewer-toolbar"></div><div class="viewer-navbar"><ul class="viewer-list"></ul></div></div><div class="viewer-tooltip"></div><div role="button" class="viewer-button" data-viewer-action="mix"></div><div class="viewer-player"></div></div>';var n=e.querySelector(".".concat(p,"-container")),s=n.querySelector(".".concat(p,"-title")),o=n.querySelector(".".concat(p,"-toolbar")),a=n.querySelector(".".concat(p,"-navbar")),r=n.querySelector(".".concat(p,"-button")),l=n.querySelector(".".concat(p,"-canvas"));if(this.parent=i,this.viewer=n,this.title=s,this.toolbar=o,this.navbar=a,this.button=r,this.canvas=l,this.footer=n.querySelector(".".concat(p,"-footer")),this.tooltipBox=n.querySelector(".".concat(p,"-tooltip")),this.player=n.querySelector(".".concat(p,"-player")),this.list=n.querySelector(".".concat(p,"-list")),rt(s,h.title?xt(Array.isArray(h.title)?h.title[0]:h.title):k),rt(a,h.navbar?xt(h.navbar):k),lt(r,k,!h.button),h.backdrop&&(rt(n,"".concat(p,"-backdrop")),h.inline||"static"===h.backdrop||mt(l,K,"hide")),$(h.className)&&h.className&&h.className.split(U).forEach(function(t){rt(n,t)}),h.toolbar){var c=document.createElement("ul"),d=it(h.toolbar),u=Z.slice(0,3),m=Z.slice(7,9),f=Z.slice(9);d||rt(o,xt(h.toolbar)),nt(d?h.toolbar:Z,function(t,i){var e=d&&it(t),n=d?dt(i):t,s=e&&!J(t.show)?t.show:t;if(s&&(h.zoomable||-1===u.indexOf(n))&&(h.rotatable||-1===m.indexOf(n))&&(h.scalable||-1===f.indexOf(n))){var o=e&&!J(t.size)?t.size:t,a=e&&!J(t.click)?t.click:t,r=document.createElement("li");r.setAttribute("role","button"),rt(r,"".concat(p,"-").concat(n)),et(a)||mt(r,K,n),G(s)&&rt(r,xt(s)),-1!==["small","large"].indexOf(o)?rt(r,"".concat(p,"-").concat(o)):"play"===n&&rt(r,"".concat(p,"-large")),et(a)&&vt(r,S,a),c.appendChild(r)}}),o.appendChild(c)}else rt(o,k);if(!h.rotatable){var g=o.querySelectorAll('li[class*="rotate"]');rt(g,z),nt(g,function(t){o.appendChild(t)})}if(h.inline)rt(r,x),at(n,{zIndex:h.zIndexInline}),"static"===window.getComputedStyle(i).position&&at(i,{position:"relative"}),i.insertBefore(n,t.nextSibling);else{rt(r,w),rt(n,y),rt(n,b),rt(n,k),at(n,{zIndex:h.zIndex});var v=h.container;$(v)&&(v=t.ownerDocument.querySelector(v)),v||(v=this.body),v.appendChild(n)}h.inline&&(this.render(),this.bind(),this.isShown=!0),this.ready=!0,et(h.ready)&&vt(t,F,h.ready,{once:!0}),!1!==pt(t,F)?this.ready&&h.inline&&this.view(this.index):this.ready=!1}}}])&&s(t.prototype,i),n&&s(t,n),e}();return st(Ct.prototype,zt,Dt,Tt,It,Et),Ct}); | ||
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):t.Viewer=i()}(this,function(){"use strict";function i(t){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function s(t,i){for(var e=0;e<i.length;e++){var n=i[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var o={backdrop:!0,button:!0,navbar:!0,title:!0,toolbar:!0,className:"",container:"body",filter:null,fullscreen:!0,initialViewIndex:0,inline:!1,interval:5e3,keyboard:!0,loading:!0,loop:!0,minWidth:200,minHeight:100,movable:!0,zoomable:!0,rotatable:!0,scalable:!0,toggleOnDblclick:!0,tooltip:!0,transition:!0,zIndex:2015,zIndexInline:0,zoomRatio:.1,minZoomRatio:.01,maxZoomRatio:100,url:"src",ready:null,show:null,shown:null,hide:null,hidden:null,view:null,viewed:null,zoom:null,zoomed:null},a="undefined"!=typeof window,r=a?window:{},h=!!a&&"ontouchstart"in r.document.documentElement,t=!!a&&"PointerEvent"in r,p="viewer",c="move",d="switch",u="zoom",m="".concat(p,"-active"),w="".concat(p,"-close"),b="".concat(p,"-fade"),y="".concat(p,"-fixed"),x="".concat(p,"-fullscreen"),l="".concat(p,"-fullscreen-exit"),k="".concat(p,"-hide"),e="".concat(p,"-hide-md-down"),n="".concat(p,"-hide-sm-down"),f="".concat(p,"-hide-xs-down"),g="".concat(p,"-in"),z="".concat(p,"-invisible"),v="".concat(p,"-loading"),D="".concat(p,"-move"),T="".concat(p,"-open"),E="".concat(p,"-show"),I="".concat(p,"-transition"),S="click",C="dblclick",L="dragstart",N="hidden",M="hide",R="keydown",Y="load",X=t?"pointerdown":h?"touchstart":"mousedown",q=t?"pointermove":h?"touchmove":"mousemove",F=t?"pointerup pointercancel":h?"touchend touchcancel":"mouseup",O="ready",W="resize",A="show",P="shown",H="transitionend",j="view",V="viewed",B="wheel",K="".concat(p,"Action"),U=/\s\s*/,Z=["zoom-in","zoom-out","one-to-one","reset","prev","play","next","rotate-left","rotate-right","flip-horizontal","flip-vertical"];function $(t){return"string"==typeof t}var _=Number.isNaN||r.isNaN;function G(t){return"number"==typeof t&&!_(t)}function J(t){return void 0===t}function Q(t){return"object"===i(t)&&null!==t}var tt=Object.prototype.hasOwnProperty;function it(t){if(!Q(t))return!1;try{var i=t.constructor,e=i.prototype;return i&&e&&tt.call(e,"isPrototypeOf")}catch(t){return!1}}function et(t){return"function"==typeof t}function nt(i,e){if(i&&et(e))if(Array.isArray(i)||G(i.length)){var t,n=i.length;for(t=0;t<n&&!1!==e.call(i,i[t],t,i);t+=1);}else Q(i)&&Object.keys(i).forEach(function(t){e.call(i,i[t],t,i)});return i}var st=Object.assign||function(e){for(var t=arguments.length,i=new Array(1<t?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];return Q(e)&&0<i.length&&i.forEach(function(i){Q(i)&&Object.keys(i).forEach(function(t){e[t]=i[t]})}),e},ot=/^(?:width|height|left|top|marginLeft|marginTop)$/;function at(t,i){var e=t.style;nt(i,function(t,i){ot.test(i)&&G(t)&&(t+="px"),e[i]=t})}function rt(t,i){if(i)if(G(t.length))nt(t,function(t){rt(t,i)});else if(t.classList)t.classList.add(i);else{var e=t.className.trim();e?e.indexOf(i)<0&&(t.className="".concat(e," ").concat(i)):t.className=i}}function ht(t,i){i&&(G(t.length)?nt(t,function(t){ht(t,i)}):t.classList?t.classList.remove(i):0<=t.className.indexOf(i)&&(t.className=t.className.replace(i,"")))}function lt(t,i,e){i&&(G(t.length)?nt(t,function(t){lt(t,i,e)}):e?rt(t,i):ht(t,i))}var ct=/([a-z\d])([A-Z])/g;function dt(t){return t.replace(ct,"$1-$2").toLowerCase()}function ut(t,i){return Q(t[i])?t[i]:t.dataset?t.dataset[i]:t.getAttribute("data-".concat(dt(i)))}function mt(t,i,e){Q(e)?t[i]=e:t.dataset?t.dataset[i]=e:t.setAttribute("data-".concat(dt(i)),e)}var ft=function(){var t=!1;if(a){var i=!1,e=function(){},n=Object.defineProperty({},"once",{get:function(){return t=!0,i},set:function(t){i=t}});r.addEventListener("test",e,n),r.removeEventListener("test",e,n)}return t}();function gt(e,t,n){var s=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{},o=n;t.trim().split(U).forEach(function(t){if(!ft){var i=e.listeners;i&&i[t]&&i[t][n]&&(o=i[t][n],delete i[t][n],0===Object.keys(i[t]).length&&delete i[t],0===Object.keys(i).length&&delete e.listeners)}e.removeEventListener(t,o,s)})}function vt(o,t,a){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{},h=a;t.trim().split(U).forEach(function(n){if(r.once&&!ft){var t=o.listeners,s=void 0===t?{}:t;h=function(){delete s[n][a],o.removeEventListener(n,h,r);for(var t=arguments.length,i=new Array(t),e=0;e<t;e++)i[e]=arguments[e];a.apply(o,i)},s[n]||(s[n]={}),s[n][a]&&o.removeEventListener(n,s[n][a],r),s[n][a]=h,o.listeners=s}o.addEventListener(n,h,r)})}function pt(t,i,e){var n;return et(Event)&&et(CustomEvent)?n=new CustomEvent(i,{detail:e,bubbles:!0,cancelable:!0}):(n=document.createEvent("CustomEvent")).initCustomEvent(i,!0,!0,e),t.dispatchEvent(n)}function wt(t){var i=t.rotate,e=t.scaleX,n=t.scaleY,s=t.translateX,o=t.translateY,a=[];G(s)&&0!==s&&a.push("translateX(".concat(s,"px)")),G(o)&&0!==o&&a.push("translateY(".concat(o,"px)")),G(i)&&0!==i&&a.push("rotate(".concat(i,"deg)")),G(e)&&1!==e&&a.push("scaleX(".concat(e,")")),G(n)&&1!==n&&a.push("scaleY(".concat(n,")"));var r=a.length?a.join(" "):"none";return{WebkitTransform:r,msTransform:r,transform:r}}var bt=r.navigator&&/(Macintosh|iPhone|iPod|iPad).*AppleWebKit/i.test(r.navigator.userAgent);function yt(t,i){var e=document.createElement("img");if(t.naturalWidth&&!bt)return i(t.naturalWidth,t.naturalHeight),e;var n=document.body||document.documentElement;return e.onload=function(){i(e.width,e.height),bt||n.removeChild(e)},e.src=t.src,bt||(e.style.cssText="left:0;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;opacity:0;position:absolute;top:0;z-index:-1;",n.appendChild(e)),e}function xt(t){switch(t){case 2:return f;case 3:return n;case 4:return e;default:return""}}function kt(t,i){var e=t.pageX,n=t.pageY,s={endX:e,endY:n};return i?s:st({timeStamp:Date.now(),startX:e,startY:n},s)}var zt={render:function(){this.initContainer(),this.initViewer(),this.initList(),this.renderViewer()},initContainer:function(){this.containerData={width:window.innerWidth,height:window.innerHeight}},initViewer:function(){var t,i=this.options,e=this.parent;i.inline&&(t={width:Math.max(e.offsetWidth,i.minWidth),height:Math.max(e.offsetHeight,i.minHeight)},this.parentData=t),!this.fulled&&t||(t=this.containerData),this.viewerData=st({},t)},renderViewer:function(){this.options.inline&&!this.fulled&&at(this.viewer,this.viewerData)},initList:function(){var a=this,t=this.element,r=this.options,i=this.list,h=[];nt(this.images,function(t,i){var e,n=t.src,s=t.alt||($(e=n)?e.replace(/^.*\//,"").replace(/[?&#].*$/,""):""),o=r.url;$(o)?o=t.getAttribute(o):et(o)&&(o=o.call(a,t)),(n||o)&&h.push("<li><img"+' src="'.concat(n||o,'"')+' role="button" data-viewer-action="view"'+' data-index="'.concat(i,'"')+' data-original-url="'.concat(o||n,'"')+' alt="'.concat(s,'"')+"></li>")}),i.innerHTML=h.join(""),this.items=i.getElementsByTagName("li"),nt(this.items,function(i){var t=i.firstElementChild;mt(t,"filled",!0),r.loading&&rt(i,v),vt(t,Y,function(t){r.loading&&ht(i,v),a.loadImage(t)},{once:!0})}),r.transition&&vt(t,V,function(){rt(i,I)},{once:!0})},renderList:function(t){var i=t||this.index,e=this.items[i].offsetWidth||30,n=e+1;at(this.list,st({width:n*this.length},wt({translateX:(this.viewerData.width-e)/2-n*i})))},resetList:function(){var t=this.list;t.innerHTML="",ht(t,I),at(t,wt({translateX:0}))},initImage:function(r){var t,h=this,l=this.options,i=this.image,e=this.viewerData,n=this.footer.offsetHeight,c=e.width,d=Math.max(e.height-n,n),u=this.imageData||{};this.imageInitializing={abort:function(){t.onload=null}},t=yt(i,function(t,i){var e=t/i,n=c,s=d;h.imageInitializing=!1,c<d*e?s=c/e:n=d*e;var o={naturalWidth:t,naturalHeight:i,aspectRatio:e,ratio:(n=Math.min(.9*n,t))/t,width:n,height:s=Math.min(.9*s,i),left:(c-n)/2,top:(d-s)/2},a=st({},o);l.rotatable&&(o.rotate=u.rotate||0,a.rotate=0),l.scalable&&(o.scaleX=u.scaleX||1,o.scaleY=u.scaleY||1,a.scaleX=1,a.scaleY=1),h.imageData=o,h.initialImageData=a,r&&r()})},renderImage:function(t){var i=this,e=this.image,n=this.imageData;if(at(e,st({width:n.width,height:n.height,marginLeft:n.left,marginTop:n.top},wt(n))),t)if((this.viewing||this.zooming)&&this.options.transition){var s=function(){i.imageRendering=!1,t()};this.imageRendering={abort:function(){gt(e,H,s)}},vt(e,H,s,{once:!0})}else t()},resetImage:function(){if(this.viewing||this.viewed){var t=this.image;this.viewing&&this.viewing.abort(),t.parentNode.removeChild(t),this.image=null}}},Dt={bind:function(){var t=this.options,i=this.viewer,e=this.canvas,n=this.element.ownerDocument;vt(i,S,this.onClick=this.click.bind(this)),vt(i,B,this.onWheel=this.wheel.bind(this),{passive:!1,capture:!0}),vt(i,L,this.onDragStart=this.dragstart.bind(this)),vt(e,X,this.onPointerDown=this.pointerdown.bind(this)),vt(n,q,this.onPointerMove=this.pointermove.bind(this)),vt(n,F,this.onPointerUp=this.pointerup.bind(this)),vt(n,R,this.onKeyDown=this.keydown.bind(this)),vt(window,W,this.onResize=this.resize.bind(this)),t.toggleOnDblclick&&vt(e,C,this.onDblclick=this.dblclick.bind(this))},unbind:function(){var t=this.options,i=this.viewer,e=this.canvas,n=this.element.ownerDocument;gt(i,S,this.onClick),gt(i,B,this.onWheel,{passive:!1,capture:!0}),gt(i,L,this.onDragStart),gt(e,X,this.onPointerDown),gt(n,q,this.onPointerMove),gt(n,F,this.onPointerUp),gt(n,R,this.onKeyDown),gt(window,W,this.onResize),t.toggleOnDblclick&>(e,C,this.onDblclick)}},Tt={click:function(t){var i=t.target,e=this.options,n=this.imageData,s=ut(i,K);switch(h&&t.isTrusted&&i===this.canvas&&clearTimeout(this.clickCanvasTimeout),s){case"mix":this.played?this.stop():e.inline?this.fulled?this.exit():this.full():this.hide();break;case"hide":this.hide();break;case"view":this.view(ut(i,"index"));break;case"zoom-in":this.zoom(.1,!0);break;case"zoom-out":this.zoom(-.1,!0);break;case"one-to-one":this.toggle();break;case"reset":this.reset();break;case"prev":this.prev(e.loop);break;case"play":this.play(e.fullscreen);break;case"next":this.next(e.loop);break;case"rotate-left":this.rotate(-90);break;case"rotate-right":this.rotate(90);break;case"flip-horizontal":this.scaleX(-n.scaleX||-1);break;case"flip-vertical":this.scaleY(-n.scaleY||-1);break;default:this.played&&this.stop()}},dblclick:function(t){t.preventDefault(),this.viewed&&t.target===this.image&&(h&&t.isTrusted&&clearTimeout(this.doubleClickImageTimeout),this.toggle())},load:function(){var t=this;this.timeout&&(clearTimeout(this.timeout),this.timeout=!1);var i=this.element,e=this.options,n=this.image,s=this.index,o=this.viewerData;ht(n,z),e.loading&&ht(this.canvas,v),n.style.cssText="height:0;"+"margin-left:".concat(o.width/2,"px;")+"margin-top:".concat(o.height/2,"px;")+"max-width:none!important;position:absolute;width:0;",this.initImage(function(){lt(n,D,e.movable),lt(n,I,e.transition),t.renderImage(function(){t.viewed=!0,t.viewing=!1,et(e.viewed)&&vt(i,V,e.viewed,{once:!0}),pt(i,V,{originalImage:t.images[s],index:s,image:n})})})},loadImage:function(t){var o=t.target,i=o.parentNode,a=i.offsetWidth||30,r=i.offsetHeight||50,h=!!ut(o,"filled");yt(o,function(t,i){var e=t/i,n=a,s=r;a<r*e?h?n=r*e:s=a/e:h?s=a/e:n=r*e,at(o,st({width:n,height:s},wt({translateX:(a-n)/2,translateY:(r-s)/2})))})},keydown:function(t){var i=this.options;if(this.fulled&&i.keyboard)switch(t.keyCode||t.which||t.charCode){case 27:this.played?this.stop():i.inline?this.fulled&&this.exit():this.hide();break;case 32:this.played&&this.stop();break;case 37:this.prev(i.loop);break;case 38:t.preventDefault(),this.zoom(i.zoomRatio,!0);break;case 39:this.next(i.loop);break;case 40:t.preventDefault(),this.zoom(-i.zoomRatio,!0);break;case 48:case 49:t.ctrlKey&&(t.preventDefault(),this.toggle())}},dragstart:function(t){"img"===t.target.tagName.toLowerCase()&&t.preventDefault()},pointerdown:function(t){var i=this.options,e=this.pointers,n=t.buttons,s=t.button;if(!(!this.viewed||this.showing||this.viewing||this.hiding||G(n)&&1!==n||G(s)&&0!==s||t.ctrlKey)){t.preventDefault(),t.changedTouches?nt(t.changedTouches,function(t){e[t.identifier]=kt(t)}):e[t.pointerId||0]=kt(t);var o=!!i.movable&&c;1<Object.keys(e).length?o=u:"touch"!==t.pointerType&&"touchstart"!==t.type||!this.isSwitchable()||(o=d),!i.transition||o!==c&&o!==u||ht(this.image,I),this.action=o}},pointermove:function(t){var i=this.pointers,e=this.action;this.viewed&&e&&(t.preventDefault(),t.changedTouches?nt(t.changedTouches,function(t){st(i[t.identifier]||{},kt(t,!0))}):st(i[t.pointerId||0]||{},kt(t,!0)),this.change(t))},pointerup:function(t){var i,e=this,n=this.options,s=this.action,o=this.pointers;t.changedTouches?nt(t.changedTouches,function(t){i=o[t.identifier],delete o[t.identifier]}):(i=o[t.pointerId||0],delete o[t.pointerId||0]),s&&(t.preventDefault(),!n.transition||s!==c&&s!==u||rt(this.image,I),this.action=!1,h&&s!==u&&i&&Date.now()-i.timeStamp<500&&(clearTimeout(this.clickCanvasTimeout),clearTimeout(this.doubleClickImageTimeout),n.toggleOnDblclick&&this.viewed&&t.target===this.image?this.imageClicked?(this.imageClicked=!1,this.doubleClickImageTimeout=setTimeout(function(){pt(e.image,C)},50)):(this.imageClicked=!0,this.doubleClickImageTimeout=setTimeout(function(){e.imageClicked=!1},500)):(this.imageClicked=!1,n.backdrop&&"static"!==n.backdrop&&t.target===this.canvas&&(this.clickCanvasTimeout=setTimeout(function(){pt(e.canvas,S)},50)))))},resize:function(){var i=this;if(this.isShown&&!this.hiding&&(this.initContainer(),this.initViewer(),this.renderViewer(),this.renderList(),this.viewed&&this.initImage(function(){i.renderImage()}),this.played)){if(this.options.fullscreen&&this.fulled&&!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement))return void this.stop();nt(this.player.getElementsByTagName("img"),function(t){vt(t,Y,i.loadImage.bind(i),{once:!0}),pt(t,Y)})}},wheel:function(t){var i=this;if(this.viewed&&(t.preventDefault(),!this.wheeling)){this.wheeling=!0,setTimeout(function(){i.wheeling=!1},50);var e=Number(this.options.zoomRatio)||.1,n=1;t.deltaY?n=0<t.deltaY?1:-1:t.wheelDelta?n=-t.wheelDelta/120:t.detail&&(n=0<t.detail?1:-1),this.zoom(-n*e,!0,t)}}},Et={show:function(){var t=0<arguments.length&&void 0!==arguments[0]&&arguments[0],i=this.element,e=this.options;if(e.inline||this.showing||this.isShown||this.showing)return this;if(!this.ready)return this.build(),this.ready&&this.show(t),this;if(et(e.show)&&vt(i,A,e.show,{once:!0}),!1===pt(i,A)||!this.ready)return this;this.hiding&&this.transitioning.abort(),this.showing=!0,this.open();var n=this.viewer;if(ht(n,k),e.transition&&!t){var s=this.shown.bind(this);this.transitioning={abort:function(){gt(n,H,s),ht(n,g)}},rt(n,I),n.offsetWidth,vt(n,H,s,{once:!0}),rt(n,g)}else rt(n,g),this.shown();return this},hide:function(){var t=0<arguments.length&&void 0!==arguments[0]&&arguments[0],i=this.element,e=this.options;if(e.inline||this.hiding||!this.isShown&&!this.showing)return this;if(et(e.hide)&&vt(i,M,e.hide,{once:!0}),!1===pt(i,M))return this;this.showing&&this.transitioning.abort(),this.hiding=!0,this.played?this.stop():this.viewing&&this.viewing.abort();var n=this.viewer;if(e.transition&&!t){var s=this.hidden.bind(this),o=function(){vt(n,H,s,{once:!0}),ht(n,g)};this.transitioning={abort:function(){this.viewed?gt(this.image,H,o):gt(n,H,s)}},this.viewed?(vt(this.image,H,o,{once:!0}),this.zoomTo(0,!1,!1,!0)):o()}else ht(n,g),this.hidden();return this},view:function(){var e=this,t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.options.initialViewIndex;if(t=Number(t)||0,!this.isShown)return this.index=t,this.show();if(this.hiding||this.played||t<0||t>=this.length||this.viewed&&t===this.index)return this;this.viewing&&this.viewing.abort();var i=this.element,n=this.options,s=this.title,o=this.canvas,a=this.items[t],r=a.querySelector("img"),h=ut(r,"originalUrl"),l=r.getAttribute("alt"),c=document.createElement("img");if(c.src=h,c.alt=l,et(n.view)&&vt(i,j,n.view,{once:!0}),!1===pt(i,j,{originalImage:this.images[t],index:t,image:c})||!this.isShown||this.hiding||this.played)return this;this.image=c,ht(this.items[this.index],m),rt(a,m),this.viewed=!1,this.index=t,this.imageData={},rt(c,z),n.loading&&rt(o,v),o.innerHTML="",o.appendChild(c),this.renderList(),s.innerHTML="";var d,u=function(){var t=e.imageData,i=Array.isArray(n.title)?n.title[1]:n.title;s.innerHTML=et(i)?i.call(e,c,t):"".concat(l," (").concat(t.naturalWidth," × ").concat(t.naturalHeight,")")};return vt(i,V,u,{once:!0}),this.viewing={abort:function(){gt(i,V,u),c.complete?this.imageRendering?this.imageRendering.abort():this.imageInitializing&&this.imageInitializing.abort():(gt(c,Y,d),this.timeout&&clearTimeout(this.timeout))}},c.complete?this.load():(vt(c,Y,d=this.load.bind(this),{once:!0}),this.timeout&&clearTimeout(this.timeout),this.timeout=setTimeout(function(){ht(c,z),e.timeout=!1},1e3)),this},prev:function(){var t=0<arguments.length&&void 0!==arguments[0]&&arguments[0],i=this.index-1;return i<0&&(i=t?this.length-1:0),this.view(i),this},next:function(){var t=0<arguments.length&&void 0!==arguments[0]&&arguments[0],i=this.length-1,e=this.index+1;return i<e&&(e=t?0:i),this.view(e),this},move:function(t,i){var e=this.imageData;return this.moveTo(J(t)?t:e.left+Number(t),J(i)?i:e.top+Number(i)),this},moveTo:function(t){var i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:t,e=this.imageData;if(t=Number(t),i=Number(i),this.viewed&&!this.played&&this.options.movable){var n=!1;G(t)&&(e.left=t,n=!0),G(i)&&(e.top=i,n=!0),n&&this.renderImage()}return this},zoom:function(t){var i=1<arguments.length&&void 0!==arguments[1]&&arguments[1],e=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,n=this.imageData;return t=(t=Number(t))<0?1/(1-t):1+t,this.zoomTo(n.width*t/n.naturalWidth,i,e),this},zoomTo:function(t){var n,s,o,i,e,a=this,r=1<arguments.length&&void 0!==arguments[1]&&arguments[1],h=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,l=3<arguments.length&&void 0!==arguments[3]&&arguments[3],c=this.element,d=this.options,u=this.pointers,m=this.imageData,f=m.width,g=m.height,v=m.left,p=m.top,w=m.naturalWidth,b=m.naturalHeight;if(G(t=Math.max(0,t))&&this.viewed&&!this.played&&(l||d.zoomable)){if(!l){var y=Math.max(.01,d.minZoomRatio),x=Math.min(100,d.maxZoomRatio);t=Math.min(Math.max(t,y),x)}h&&.95<t&&t<1.05&&(t=1);var k=w*t,z=b*t,D=k-f,T=z-g,E=f/w;if(et(d.zoom)&&vt(c,"zoom",d.zoom,{once:!0}),!1===pt(c,"zoom",{ratio:t,oldRatio:E,originalEvent:h}))return this;if(this.zooming=!0,h){var I=(i=this.viewer,{left:(e=i.getBoundingClientRect()).left+(window.pageXOffset-document.documentElement.clientLeft),top:e.top+(window.pageYOffset-document.documentElement.clientTop)}),S=u&&Object.keys(u).length?(o=s=n=0,nt(u,function(t){var i=t.startX,e=t.startY;n+=i,s+=e,o+=1}),{pageX:n/=o,pageY:s/=o}):{pageX:h.pageX,pageY:h.pageY};m.left-=D*((S.pageX-I.left-v)/f),m.top-=T*((S.pageY-I.top-p)/g)}else m.left-=D/2,m.top-=T/2;m.width=k,m.height=z,m.ratio=t,this.renderImage(function(){a.zooming=!1,et(d.zoomed)&&vt(c,"zoomed",d.zoomed,{once:!0}),pt(c,"zoomed",{ratio:t,oldRatio:E,originalEvent:h})}),r&&this.tooltip()}return this},rotate:function(t){return this.rotateTo((this.imageData.rotate||0)+Number(t)),this},rotateTo:function(t){var i=this.imageData;return G(t=Number(t))&&this.viewed&&!this.played&&this.options.rotatable&&(i.rotate=t,this.renderImage()),this},scaleX:function(t){return this.scale(t,this.imageData.scaleY),this},scaleY:function(t){return this.scale(this.imageData.scaleX,t),this},scale:function(t){var i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:t,e=this.imageData;if(t=Number(t),i=Number(i),this.viewed&&!this.played&&this.options.scalable){var n=!1;G(t)&&(e.scaleX=t,n=!0),G(i)&&(e.scaleY=i,n=!0),n&&this.renderImage()}return this},play:function(){var i=this,t=0<arguments.length&&void 0!==arguments[0]&&arguments[0];if(!this.isShown||this.played)return this;var a=this.options,r=this.player,h=this.loadImage.bind(this),l=[],c=0,d=0;if(this.played=!0,this.onLoadWhenPlay=h,t&&this.requestFullscreen(),rt(r,E),nt(this.items,function(t,i){var e,n,s=t.querySelector("img"),o=document.createElement("img");o.src=ut(s,"originalUrl"),o.alt=s.getAttribute("alt"),c+=1,rt(o,b),lt(o,I,a.transition),n=m,((e=t).classList?e.classList.contains(n):-1<e.className.indexOf(n))&&(rt(o,g),d=i),l.push(o),vt(o,Y,h,{once:!0}),r.appendChild(o)}),G(a.interval)&&0<a.interval){var e=function t(){i.playing=setTimeout(function(){ht(l[d],g),rt(l[d=(d+=1)<c?d:0],g),t()},a.interval)};1<c&&e()}return this},stop:function(){var i=this;if(!this.played)return this;var t=this.player;return this.played=!1,clearTimeout(this.playing),nt(t.getElementsByTagName("img"),function(t){gt(t,Y,i.onLoadWhenPlay)}),ht(t,E),t.innerHTML="",this.exitFullscreen(),this},full:function(){var t=this,i=this.options,e=this.viewer,n=this.image,s=this.list;return!this.isShown||this.played||this.fulled||!i.inline||(this.fulled=!0,this.open(),rt(this.button,l),i.transition&&(ht(s,I),this.viewed&&ht(n,I)),rt(e,y),e.setAttribute("style",""),at(e,{zIndex:i.zIndex}),this.initContainer(),this.viewerData=st({},this.containerData),this.renderList(),this.viewed&&this.initImage(function(){t.renderImage(function(){i.transition&&setTimeout(function(){rt(n,I),rt(s,I)},0)})})),this},exit:function(){var t=this,i=this.options,e=this.viewer,n=this.image,s=this.list;return this.isShown&&!this.played&&this.fulled&&i.inline&&(this.fulled=!1,this.close(),ht(this.button,l),i.transition&&(ht(s,I),this.viewed&&ht(n,I)),ht(e,y),at(e,{zIndex:i.zIndexInline}),this.viewerData=st({},this.parentData),this.renderViewer(),this.renderList(),this.viewed&&this.initImage(function(){t.renderImage(function(){i.transition&&setTimeout(function(){rt(n,I),rt(s,I)},0)})})),this},tooltip:function(){var t=this,i=this.options,e=this.tooltipBox,n=this.imageData;return this.viewed&&!this.played&&i.tooltip&&(e.textContent="".concat(Math.round(100*n.ratio),"%"),this.tooltipping?clearTimeout(this.tooltipping):i.transition?(this.fading&&pt(e,H),rt(e,E),rt(e,b),rt(e,I),e.offsetWidth,rt(e,g)):rt(e,E),this.tooltipping=setTimeout(function(){i.transition?(vt(e,H,function(){ht(e,E),ht(e,b),ht(e,I),t.fading=!1},{once:!0}),ht(e,g),t.fading=!0):ht(e,E),t.tooltipping=!1},1e3)),this},toggle:function(){return 1===this.imageData.ratio?this.zoomTo(this.initialImageData.ratio,!0):this.zoomTo(1,!0),this},reset:function(){return this.viewed&&!this.played&&(this.imageData=st({},this.initialImageData),this.renderImage()),this},update:function(){var t=this.element,i=this.options,e=this.isImg;if(e&&!t.parentNode)return this.destroy();var s=[];if(nt(e?[t]:t.querySelectorAll("img"),function(t){i.filter?i.filter(t)&&s.push(t):s.push(t)}),!s.length)return this;if(this.images=s,this.length=s.length,this.ready){var o=[];if(nt(this.items,function(t,i){var e=t.querySelector("img"),n=s[i];n?n.src!==e.src&&o.push(i):o.push(i)}),at(this.list,{width:"auto"}),this.initList(),this.isShown)if(this.length){if(this.viewed){var n=o.indexOf(this.index);0<=n?(this.viewed=!1,this.view(Math.max(this.index-(n+1),0))):rt(this.items[this.index],m)}}else this.image=null,this.viewed=!1,this.index=0,this.imageData={},this.canvas.innerHTML="",this.title.innerHTML=""}else this.build();return this},destroy:function(){var t=this.element,i=this.options;return t[p]&&(this.destroyed=!0,this.ready?(this.played&&this.stop(),i.inline?(this.fulled&&this.exit(),this.unbind()):this.isShown?(this.viewing&&(this.imageRendering?this.imageRendering.abort():this.imageInitializing&&this.imageInitializing.abort()),this.hiding&&this.transitioning.abort(),this.hidden()):this.showing&&(this.transitioning.abort(),this.hidden()),this.ready=!1,this.viewer.parentNode.removeChild(this.viewer)):i.inline&&(this.delaying?this.delaying.abort():this.initializing&&this.initializing.abort()),i.inline||gt(t,S,this.onStart),t[p]=void 0),this}},It={open:function(){var t=this.body;rt(t,T),t.style.paddingRight="".concat(this.scrollbarWidth+(parseFloat(this.initialBodyPaddingRight)||0),"px")},close:function(){var t=this.body;ht(t,T),t.style.paddingRight=this.initialBodyPaddingRight},shown:function(){var t=this.element,i=this.options;this.fulled=!0,this.isShown=!0,this.render(),this.bind(),this.showing=!1,et(i.shown)&&vt(t,P,i.shown,{once:!0}),!1!==pt(t,P)&&this.ready&&this.isShown&&!this.hiding&&this.view(this.index)},hidden:function(){var t=this.element,i=this.options;this.fulled=!1,this.viewed=!1,this.isShown=!1,this.close(),this.unbind(),rt(this.viewer,k),this.resetList(),this.resetImage(),this.hiding=!1,this.destroyed||(et(i.hidden)&&vt(t,N,i.hidden,{once:!0}),pt(t,N))},requestFullscreen:function(){var t=this.element.ownerDocument;if(this.fulled&&!(t.fullscreenElement||t.webkitFullscreenElement||t.mozFullScreenElement||t.msFullscreenElement)){var i=t.documentElement;i.requestFullscreen?i.requestFullscreen():i.webkitRequestFullscreen?i.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT):i.mozRequestFullScreen?i.mozRequestFullScreen():i.msRequestFullscreen&&i.msRequestFullscreen()}},exitFullscreen:function(){var t=this.element.ownerDocument;this.fulled&&(t.fullscreenElement||t.webkitFullscreenElement||t.mozFullScreenElement||t.msFullscreenElement)&&(t.exitFullscreen?t.exitFullscreen():t.webkitExitFullscreen?t.webkitExitFullscreen():t.mozCancelFullScreen?t.mozCancelFullScreen():t.msExitFullscreen&&t.msExitFullscreen())},change:function(t){var i,e,h,n=this.options,s=this.pointers,o=s[Object.keys(s)[0]],a=o.endX-o.startX,r=o.endY-o.startY;switch(this.action){case c:this.move(a,r);break;case u:this.zoom((e=st({},i=s),h=[],nt(i,function(r,t){delete e[t],nt(e,function(t){var i=Math.abs(r.startX-t.startX),e=Math.abs(r.startY-t.startY),n=Math.abs(r.endX-t.endX),s=Math.abs(r.endY-t.endY),o=Math.sqrt(i*i+e*e),a=(Math.sqrt(n*n+s*s)-o)/o;h.push(a)})}),h.sort(function(t,i){return Math.abs(t)<Math.abs(i)}),h[0]),!1,t);break;case d:this.action="switched";var l=Math.abs(a);1<l&&l>Math.abs(r)&&(this.pointers={},1<a?this.prev(n.loop):a<-1&&this.next(n.loop))}nt(s,function(t){t.startX=t.endX,t.startY=t.endY})},isSwitchable:function(){var t=this.imageData,i=this.viewerData;return 1<this.length&&0<=t.left&&0<=t.top&&t.width<=i.width&&t.height<=i.height}},St=r.Viewer,Ct=function(){function e(t){var i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(function(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this,e),!t||1!==t.nodeType)throw new Error("The first argument is required and must be an element.");this.element=t,this.options=st({},o,it(i)&&i),this.action=!1,this.fading=!1,this.fulled=!1,this.hiding=!1,this.imageClicked=!1,this.imageData={},this.index=this.options.initialViewIndex,this.isImg=!1,this.isShown=!1,this.length=0,this.played=!1,this.playing=!1,this.pointers={},this.ready=!1,this.showing=!1,this.timeout=!1,this.tooltipping=!1,this.viewed=!1,this.viewing=!1,this.wheeling=!1,this.zooming=!1,this.init()}var t,i,n;return t=e,n=[{key:"noConflict",value:function(){return window.Viewer=St,e}},{key:"setDefaults",value:function(t){st(o,it(t)&&t)}}],(i=[{key:"init",value:function(){var e=this,t=this.element,n=this.options;if(!t[p]){t[p]=this;var i="img"===t.tagName.toLowerCase(),s=[];nt(i?[t]:t.querySelectorAll("img"),function(t){et(n.filter)?n.filter.call(e,t)&&s.push(t):s.push(t)}),this.isImg=i,this.length=s.length,this.images=s;var o=t.ownerDocument,a=o.body||o.documentElement;if(this.body=a,this.scrollbarWidth=window.innerWidth-o.documentElement.clientWidth,this.initialBodyPaddingRight=window.getComputedStyle(a).paddingRight,J(document.createElement(p).style.transition)&&(n.transition=!1),n.inline){var r=0,h=function(){var t;(r+=1)===e.length&&(e.initializing=!1,e.delaying={abort:function(){clearTimeout(t)}},t=setTimeout(function(){e.delaying=!1,e.build()},0))};this.initializing={abort:function(){nt(s,function(t){t.complete||gt(t,Y,h)})}},nt(s,function(t){t.complete?h():vt(t,Y,h,{once:!0})})}else vt(t,S,this.onStart=function(t){var i=t.target;"img"!==i.tagName.toLowerCase()||et(n.filter)&&!n.filter.call(e,i)||e.view(e.images.indexOf(i))})}}},{key:"build",value:function(){if(!this.ready){var t=this.element,h=this.options,i=t.parentNode,e=document.createElement("div");e.innerHTML='<div class="viewer-container" touch-action="none"><div class="viewer-canvas"></div><div class="viewer-footer"><div class="viewer-title"></div><div class="viewer-toolbar"></div><div class="viewer-navbar"><ul class="viewer-list"></ul></div></div><div class="viewer-tooltip"></div><div role="button" class="viewer-button" data-viewer-action="mix"></div><div class="viewer-player"></div></div>';var n=e.querySelector(".".concat(p,"-container")),s=n.querySelector(".".concat(p,"-title")),o=n.querySelector(".".concat(p,"-toolbar")),a=n.querySelector(".".concat(p,"-navbar")),r=n.querySelector(".".concat(p,"-button")),l=n.querySelector(".".concat(p,"-canvas"));if(this.parent=i,this.viewer=n,this.title=s,this.toolbar=o,this.navbar=a,this.button=r,this.canvas=l,this.footer=n.querySelector(".".concat(p,"-footer")),this.tooltipBox=n.querySelector(".".concat(p,"-tooltip")),this.player=n.querySelector(".".concat(p,"-player")),this.list=n.querySelector(".".concat(p,"-list")),rt(s,h.title?xt(Array.isArray(h.title)?h.title[0]:h.title):k),rt(a,h.navbar?xt(h.navbar):k),lt(r,k,!h.button),h.backdrop&&(rt(n,"".concat(p,"-backdrop")),h.inline||"static"===h.backdrop||mt(l,K,"hide")),$(h.className)&&h.className&&h.className.split(U).forEach(function(t){rt(n,t)}),h.toolbar){var c=document.createElement("ul"),d=it(h.toolbar),u=Z.slice(0,3),m=Z.slice(7,9),f=Z.slice(9);d||rt(o,xt(h.toolbar)),nt(d?h.toolbar:Z,function(t,i){var e=d&&it(t),n=d?dt(i):t,s=e&&!J(t.show)?t.show:t;if(s&&(h.zoomable||-1===u.indexOf(n))&&(h.rotatable||-1===m.indexOf(n))&&(h.scalable||-1===f.indexOf(n))){var o=e&&!J(t.size)?t.size:t,a=e&&!J(t.click)?t.click:t,r=document.createElement("li");r.setAttribute("role","button"),rt(r,"".concat(p,"-").concat(n)),et(a)||mt(r,K,n),G(s)&&rt(r,xt(s)),-1!==["small","large"].indexOf(o)?rt(r,"".concat(p,"-").concat(o)):"play"===n&&rt(r,"".concat(p,"-large")),et(a)&&vt(r,S,a),c.appendChild(r)}}),o.appendChild(c)}else rt(o,k);if(!h.rotatable){var g=o.querySelectorAll('li[class*="rotate"]');rt(g,z),nt(g,function(t){o.appendChild(t)})}if(h.inline)rt(r,x),at(n,{zIndex:h.zIndexInline}),"static"===window.getComputedStyle(i).position&&at(i,{position:"relative"}),i.insertBefore(n,t.nextSibling);else{rt(r,w),rt(n,y),rt(n,b),rt(n,k),at(n,{zIndex:h.zIndex});var v=h.container;$(v)&&(v=t.ownerDocument.querySelector(v)),v||(v=this.body),v.appendChild(n)}h.inline&&(this.render(),this.bind(),this.isShown=!0),this.ready=!0,et(h.ready)&&vt(t,O,h.ready,{once:!0}),!1!==pt(t,O)?this.ready&&h.inline&&this.view(this.index):this.ready=!1}}}])&&s(t.prototype,i),n&&s(t,n),e}();return st(Ct.prototype,zt,Dt,Tt,Et,It),Ct}); |
{ | ||
"name": "viewerjs", | ||
"description": "JavaScript image viewer.", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"main": "dist/viewer.common.js", | ||
@@ -44,4 +44,4 @@ "module": "dist/viewer.esm.js", | ||
"lint": "npm run lint:js && npm run lint:css", | ||
"lint:css": "stylelint {src,docs}/**/*.{css,scss,html} --fix", | ||
"lint:js": "eslint src test *.js --fix", | ||
"lint:css": "stylelint {src,docs,examples}/**/*.{css,scss,html} --fix", | ||
"release": "npm run clear && npm run lint && npm run build && npm run compress && npm run copy && npm test", | ||
@@ -54,9 +54,9 @@ "start": "npm-run-all --parallel watch:*", | ||
"devDependencies": { | ||
"@babel/core": "^7.2.0", | ||
"@babel/preset-env": "^7.2.0", | ||
"@commitlint/cli": "^7.2.1", | ||
"@commitlint/config-conventional": "^7.1.2", | ||
"@babel/core": "^7.2.2", | ||
"@babel/preset-env": "^7.3.1", | ||
"@commitlint/cli": "^7.3.2", | ||
"@commitlint/config-conventional": "^7.3.1", | ||
"babel-plugin-istanbul": "^5.1.0", | ||
"chai": "^4.2.0", | ||
"change-case": "^3.0.2", | ||
"change-case": "^3.1.0", | ||
"codecov": "^3.1.0", | ||
@@ -66,9 +66,9 @@ "cpy-cli": "^2.0.0", | ||
"cross-env": "^5.2.0", | ||
"cssnano": "^4.1.7", | ||
"cssnano": "^4.1.8", | ||
"del-cli": "^1.1.0", | ||
"eslint": "^5.10.0", | ||
"eslint": "^5.12.1", | ||
"eslint-config-airbnb-base": "^13.1.0", | ||
"eslint-plugin-import": "^2.14.0", | ||
"husky": "^1.2.0", | ||
"karma": "^3.1.3", | ||
"eslint-plugin-import": "^2.15.0", | ||
"husky": "^1.3.1", | ||
"karma": "^4.0.0", | ||
"karma-chai": "^0.1.0", | ||
@@ -79,20 +79,52 @@ "karma-chrome-launcher": "^2.2.0", | ||
"karma-mocha-reporter": "^2.2.5", | ||
"karma-rollup-preprocessor": "^6.1.1", | ||
"karma-rollup-preprocessor": "^6.1.2", | ||
"lint-staged": "^8.1.0", | ||
"mocha": "^5.2.0", | ||
"npm-run-all": "^4.1.5", | ||
"postcss-cli": "^6.0.1", | ||
"postcss-cli": "^6.1.1", | ||
"postcss-header": "^1.0.0", | ||
"postcss-import": "^12.0.1", | ||
"postcss-preset-env": "^6.4.0", | ||
"postcss-preset-env": "^6.5.0", | ||
"postcss-url": "^8.0.0", | ||
"puppeteer": "^1.11.0", | ||
"rollup": "^0.67.4", | ||
"rollup-plugin-babel": "^4.0.3", | ||
"rollup-plugin-babel": "^4.3.2", | ||
"rollup-watch": "^4.3.1", | ||
"stylelint": "^9.9.0", | ||
"stylelint": "^9.10.1", | ||
"stylelint-config-standard": "^18.2.0", | ||
"stylelint-order": "^2.0.0", | ||
"uglify-js": "^3.4.9" | ||
}, | ||
"browserslist": [ | ||
"last 2 versions", | ||
"> 1%", | ||
"not ie <= 8" | ||
], | ||
"commitlint": { | ||
"extends": [ | ||
"@commitlint/config-conventional" | ||
] | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "lint-staged", | ||
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS" | ||
} | ||
}, | ||
"lint-staged": { | ||
"linters": { | ||
"*.js": [ | ||
"eslint --fix", | ||
"git add" | ||
], | ||
"*.{css,scss,html}": [ | ||
"stylelint --fix", | ||
"git add" | ||
] | ||
}, | ||
"ignore": [ | ||
"{dist,docs}/**/*.js", | ||
"*.min.*" | ||
] | ||
} | ||
} |
# Viewer.js | ||
[![Build Status](https://travis-ci.org/fengyuanchen/viewerjs.svg)](https://travis-ci.org/fengyuanchen/viewerjs) [![Downloads](https://img.shields.io/npm/dm/viewerjs.svg)](https://www.npmjs.com/package/viewerjs) [![Version](https://img.shields.io/npm/v/viewerjs.svg)](https://www.npmjs.com/package/viewerjs) [![Donate on Patreon](https://img.shields.io/badge/donate-on%20patreon-fa7664.svg)](https://www.patreon.com/chenfengyuan) | ||
[![Build Status](https://img.shields.io/travis/fengyuanchen/viewerjs.svg)](https://travis-ci.org/fengyuanchen/viewerjs) [![Downloads](https://img.shields.io/npm/dm/viewerjs.svg)](https://www.npmjs.com/package/viewerjs) [![Version](https://img.shields.io/npm/v/viewerjs.svg)](https://www.npmjs.com/package/viewerjs) [![Donate on Patreon](https://img.shields.io/badge/donate-on%20patreon-fa7664.svg)](https://www.patreon.com/chenfengyuan) | ||
@@ -5,0 +5,0 @@ > JavaScript image viewer. |
@@ -52,3 +52,3 @@ export const IS_BROWSER = typeof window !== 'undefined'; | ||
export const EVENT_VIEWED = 'viewed'; | ||
export const EVENT_WHEEL = 'wheel mousewheel DOMMouseScroll'; | ||
export const EVENT_WHEEL = 'wheel'; | ||
export const EVENT_ZOOM = 'zoom'; | ||
@@ -55,0 +55,0 @@ export const EVENT_ZOOMED = 'zoomed'; |
@@ -23,3 +23,6 @@ import { | ||
addListener(viewer, EVENT_CLICK, (this.onClick = this.click.bind(this))); | ||
addListener(viewer, EVENT_WHEEL, (this.onWheel = this.wheel.bind(this))); | ||
addListener(viewer, EVENT_WHEEL, (this.onWheel = this.wheel.bind(this)), { | ||
passive: false, | ||
capture: true, | ||
}); | ||
addListener(viewer, EVENT_DRAG_START, (this.onDragStart = this.dragstart.bind(this))); | ||
@@ -42,3 +45,6 @@ addListener(canvas, EVENT_POINTER_DOWN, (this.onPointerDown = this.pointerdown.bind(this))); | ||
removeListener(viewer, EVENT_CLICK, this.onClick); | ||
removeListener(viewer, EVENT_WHEEL, this.onWheel); | ||
removeListener(viewer, EVENT_WHEEL, this.onWheel, { | ||
passive: false, | ||
capture: true, | ||
}); | ||
removeListener(viewer, EVENT_DRAG_START, this.onDragStart); | ||
@@ -45,0 +51,0 @@ removeListener(canvas, EVENT_POINTER_DOWN, this.onPointerDown); |
@@ -310,6 +310,6 @@ import { | ||
// No primary button (usually the left button) | ||
// Note: Touch events does not contain `buttons` and `button` properties | ||
|| (isNumber(buttons) && buttons > 1) | ||
|| (isNumber(button) && button > 0) | ||
// No primary button (Usually the left button) | ||
// Note that touch events have no `buttons` or `button` property | ||
|| (isNumber(buttons) && buttons !== 1) | ||
|| (isNumber(button) && button !== 0) | ||
@@ -450,7 +450,8 @@ // Open context menu | ||
if (this.played) { | ||
if (this.options.fullscreen && this.fulled | ||
&& !document.fullscreenElement | ||
&& !document.mozFullScreenElement | ||
&& !document.webkitFullscreenElement | ||
&& !document.msFullscreenElement) { | ||
if (this.options.fullscreen && this.fulled && !( | ||
document.fullscreenElement | ||
|| document.webkitFullscreenElement | ||
|| document.mozFullScreenElement | ||
|| document.msFullscreenElement | ||
)) { | ||
this.stop(); | ||
@@ -457,0 +458,0 @@ return; |
@@ -87,14 +87,19 @@ import { | ||
if (this.fulled && !document.fullscreenElement && !document.mozFullScreenElement | ||
&& !document.webkitFullscreenElement && !document.msFullscreenElement) { | ||
if (this.fulled && !( | ||
document.fullscreenElement | ||
|| document.webkitFullscreenElement | ||
|| document.mozFullScreenElement | ||
|| document.msFullscreenElement | ||
)) { | ||
const { documentElement } = document; | ||
// Element.requestFullscreen() | ||
if (documentElement.requestFullscreen) { | ||
documentElement.requestFullscreen(); | ||
} else if (documentElement.webkitRequestFullscreen) { | ||
documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT); | ||
} else if (documentElement.mozRequestFullScreen) { | ||
documentElement.mozRequestFullScreen(); | ||
} else if (documentElement.msRequestFullscreen) { | ||
documentElement.msRequestFullscreen(); | ||
} else if (documentElement.mozRequestFullScreen) { | ||
documentElement.mozRequestFullScreen(); | ||
} else if (documentElement.webkitRequestFullscreen) { | ||
documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT); | ||
} | ||
@@ -105,13 +110,19 @@ } | ||
exitFullscreen() { | ||
if (this.fulled) { | ||
const document = this.element.ownerDocument; | ||
const document = this.element.ownerDocument; | ||
if (this.fulled && ( | ||
document.fullscreenElement | ||
|| document.webkitFullscreenElement | ||
|| document.mozFullScreenElement | ||
|| document.msFullscreenElement | ||
)) { | ||
// Document.exitFullscreen() | ||
if (document.exitFullscreen) { | ||
document.exitFullscreen(); | ||
} else if (document.webkitExitFullscreen) { | ||
document.webkitExitFullscreen(); | ||
} else if (document.mozCancelFullScreen) { | ||
document.mozCancelFullScreen(); | ||
} else if (document.msExitFullscreen) { | ||
document.msExitFullscreen(); | ||
} else if (document.mozCancelFullScreen) { | ||
document.mozCancelFullScreen(); | ||
} else if (document.webkitExitFullscreen) { | ||
document.webkitExitFullscreen(); | ||
} | ||
@@ -118,0 +129,0 @@ } |
@@ -217,2 +217,4 @@ import { | ||
height: imageData.height, | ||
// XXX: Not to use translateX/Y to avoid image shaking when zooming | ||
marginLeft: imageData.left, | ||
@@ -219,0 +221,0 @@ marginTop: imageData.top, |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
478433
11331