Comparing version 1.10.2 to 1.10.3
/*! | ||
* Viewer.js v1.10.2 | ||
* Viewer.js v1.10.3 | ||
* https://fengyuanchen.github.io/viewerjs | ||
@@ -8,4 +8,4 @@ * | ||
* | ||
* Date: 2021-10-22T13:59:51.046Z | ||
* Date: 2022-02-02T05:15:01.702Z | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Viewer=e()}(this,function(){"use strict";function e(e,t){var i,n=Object.keys(e);return Object.getOwnPropertySymbols&&(i=Object.getOwnPropertySymbols(e),t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)),n}function l(n){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?e(Object(o),!0).forEach(function(t){var e,i;e=n,t=o[i=t],i in e?Object.defineProperty(e,i,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[i]=t}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(o)):e(Object(o)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(o,t))})}return n}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 o(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var s={backdrop:!0,button:!0,navbar:!0,title:!0,toolbar:!0,className:"",container:"body",filter:null,fullscreen:!0,inheritedAttributes:["crossOrigin","decoding","isMap","loading","referrerPolicy","sizes","srcset","useMap"],initialViewIndex:0,inline:!1,interval:5e3,keyboard:!0,focus:!0,loading:!0,loop:!0,minWidth:200,minHeight:100,movable:!0,rotatable:!0,scalable:!0,zoomable:!0,zoomOnTouch:!0,zoomOnWheel:!0,slideOnTouch:!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,move:null,moved:null,rotate:null,rotated:null,scale:null,scaled:null,zoom:null,zoomed:null,play:null,stop:null},t="undefined"!=typeof window&&void 0!==window.document,n=t?window:{},a=!(!t||!n.document.documentElement)&&"ontouchstart"in n.document.documentElement,r=t&&"PointerEvent"in n,g="viewer",c="move",u="switch",d="zoom",f="".concat(g,"-active"),v="".concat(g,"-close"),p="".concat(g,"-fade"),b="".concat(g,"-fixed"),w="".concat(g,"-fullscreen"),h="".concat(g,"-fullscreen-exit"),y="".concat(g,"-hide"),m="".concat(g,"-hide-md-down"),x="".concat(g,"-hide-sm-down"),k="".concat(g,"-hide-xs-down"),z="".concat(g,"-in"),D="".concat(g,"-invisible"),T="".concat(g,"-loading"),E="".concat(g,"-move"),I="".concat(g,"-open"),A="".concat(g,"-show"),S="".concat(g,"-transition"),O="click",C="dblclick",L="dragstart",R="focusin",F="keydown",N="load",Y="error",X=r?"pointerdown":a?"touchstart":"mousedown",M=r?"pointermove":a?"touchmove":"mousemove",q=r?"pointerup pointercancel":a?"touchend touchcancel":"mouseup",P="resize",W="transitionend",j="wheel",H="ready",B="show",V="viewed",U="rotated",K="".concat(g,"Action"),Z=/\s\s*/,$=["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 G=Number.isNaN||n.isNaN;function J(t){return"number"==typeof t&&!G(t)}function Q(t){return void 0===t}function tt(t){return"object"===i(t)&&null!==t}var et=Object.prototype.hasOwnProperty;function it(t){if(!tt(t))return!1;try{var e=t.constructor,i=e.prototype;return e&&i&&et.call(i,"isPrototypeOf")}catch(t){return!1}}function nt(t){return"function"==typeof t}function ot(e,i){if(e&&nt(i))if(Array.isArray(e)||J(e.length))for(var t=e.length,n=0;n<t&&!1!==i.call(e,e[n],n,e);n+=1);else tt(e)&&Object.keys(e).forEach(function(t){i.call(e,e[t],t,e)});return e}var st=Object.assign||function(i){for(var t=arguments.length,e=new Array(1<t?t-1:0),n=1;n<t;n++)e[n-1]=arguments[n];return tt(i)&&0<e.length&&e.forEach(function(e){tt(e)&&Object.keys(e).forEach(function(t){i[t]=e[t]})}),i},at=/^(?:width|height|left|top|marginLeft|marginTop)$/;function rt(t,e){var i=t.style;ot(e,function(t,e){at.test(e)&&J(t)&&(t+="px"),i[e]=t})}function ht(t,e){return t&&e&&(t.classList?t.classList.contains(e):-1<t.className.indexOf(e))}function lt(t,e){var i;t&&e&&(J(t.length)?ot(t,function(t){lt(t,e)}):t.classList?t.classList.add(e):(i=t.className.trim())?i.indexOf(e)<0&&(t.className="".concat(i," ").concat(e)):t.className=e)}function ct(t,e){t&&e&&(J(t.length)?ot(t,function(t){ct(t,e)}):t.classList?t.classList.remove(e):0<=t.className.indexOf(e)&&(t.className=t.className.replace(e,"")))}function ut(t,e,i){e&&(J(t.length)?ot(t,function(t){ut(t,e,i)}):(i?lt:ct)(t,e))}var dt=/([a-z\d])([A-Z])/g;function mt(t){return t.replace(dt,"$1-$2").toLowerCase()}function gt(t,e){return tt(t[e])?t[e]:t.dataset?t.dataset[e]:t.getAttribute("data-".concat(mt(e)))}function ft(t,e,i){tt(i)?t[e]=i:t.dataset?t.dataset[e]=i:t.setAttribute("data-".concat(mt(e)),i)}var vt,pt,bt=(pt=!1,t&&(vt=!1,St=function(){},Ot=Object.defineProperty({},"once",{get:function(){return pt=!0,vt},set:function(t){vt=t}}),n.addEventListener("test",St,Ot),n.removeEventListener("test",St,Ot)),pt);function wt(i,t,n,e){var o=3<arguments.length&&void 0!==e?e:{},s=n;t.trim().split(Z).forEach(function(t){var e;bt||(e=i.listeners)&&e[t]&&e[t][n]&&(s=e[t][n],delete e[t][n],0===Object.keys(e[t]).length&&delete e[t],0===Object.keys(e).length&&delete i.listeners),i.removeEventListener(t,s,o)})}function yt(s,t,a,e){var r=3<arguments.length&&void 0!==e?e:{},h=a;t.trim().split(Z).forEach(function(n){var t,o;r.once&&!bt&&(t=s.listeners,h=function(){delete o[n][a],s.removeEventListener(n,h,r);for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];a.apply(s,e)},(o=void 0===t?{}:t)[n]||(o[n]={}),o[n][a]&&s.removeEventListener(n,o[n][a],r),o[n][a]=h,s.listeners=o),s.addEventListener(n,h,r)})}function xt(t,e,i,n){var o;return nt(Event)&&nt(CustomEvent)?o=new CustomEvent(e,l({bubbles:!0,cancelable:!0,detail:i},n)):(o=document.createEvent("CustomEvent")).initCustomEvent(e,!0,!0,i),t.dispatchEvent(o)}function kt(t){var e=t.rotate,i=t.scaleX,n=t.scaleY,o=t.translateX,s=t.translateY,t=[];J(o)&&0!==o&&t.push("translateX(".concat(o,"px)")),J(s)&&0!==s&&t.push("translateY(".concat(s,"px)")),J(e)&&0!==e&&t.push("rotate(".concat(e,"deg)")),J(i)&&1!==i&&t.push("scaleX(".concat(i,")")),J(n)&&1!==n&&t.push("scaleY(".concat(n,")"));t=t.length?t.join(" "):"none";return{WebkitTransform:t,msTransform:t,transform:t}}var zt=n.navigator&&/(Macintosh|iPhone|iPod|iPad).*AppleWebKit/i.test(n.navigator.userAgent);function Dt(i,t,e){var n=document.createElement("img");if(i.naturalWidth&&!zt)return e(i.naturalWidth,i.naturalHeight),n;var o=document.body||document.documentElement;return n.onload=function(){e(n.width,n.height),zt||o.removeChild(n)},ot(t.inheritedAttributes,function(t){var e=i.getAttribute(t);null!==e&&n.setAttribute(t,e)}),n.src=i.src,zt||(n.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;",o.appendChild(n)),n}function Tt(t){switch(t){case 2:return k;case 3:return x;case 4:return m;default:return""}}function Et(t,e){var i=t.pageX,n=t.pageY,t={endX:i,endY:n};return e?t:l({timeStamp:Date.now(),startX:i,startY:n},t)}var It,At={render:function(){this.initContainer(),this.initViewer(),this.initList(),this.renderViewer()},initBody:function(){var t=this.element.ownerDocument,e=t.body||t.documentElement;this.body=e,this.scrollbarWidth=window.innerWidth-t.documentElement.clientWidth,this.initialBodyPaddingRight=e.style.paddingRight,this.initialBodyComputedPaddingRight=window.getComputedStyle(e).paddingRight},initContainer:function(){this.containerData={width:window.innerWidth,height:window.innerHeight}},initViewer:function(){var t,e=this.options,i=this.parent;e.inline&&(t={width:Math.max(i.offsetWidth,e.minWidth),height:Math.max(i.offsetHeight,e.minHeight)},this.parentData=t),!this.fulled&&t||(t=this.containerData),this.viewerData=st({},t)},renderViewer:function(){this.options.inline&&!this.fulled&&rt(this.viewer,this.viewerData)},initList:function(){var r=this,t=this.element,h=this.options,l=this.list,c=[];l.innerHTML="",ot(this.images,function(i,t){var e,n,o=i.src,s=i.alt||(_(e=o)?decodeURIComponent(e.replace(/^.*\//,"").replace(/[?&#].*$/,"")):""),a=r.getImageURL(i);(o||a)&&(e=document.createElement("li"),n=document.createElement("img"),ot(h.inheritedAttributes,function(t){var e=i.getAttribute(t);null!==e&&n.setAttribute(t,e)}),n.src=o||a,n.alt=s,n.setAttribute("data-original-url",a||o),e.setAttribute("data-index",t),e.setAttribute("data-viewer-action","view"),e.setAttribute("role","button"),h.keyboard&&e.setAttribute("tabindex",0),e.appendChild(n),l.appendChild(e),c.push(e))}),ot(this.items=c,function(e){var t,i,n=e.firstElementChild;ft(n,"filled",!0),h.loading&<(e,T),yt(n,N,t=function(t){wt(n,Y,i),h.loading&&ct(e,T),r.loadImage(t)},{once:!0}),yt(n,Y,i=function(){wt(n,N,t),h.loading&&ct(e,T)},{once:!0})}),h.transition&&yt(t,V,function(){lt(l,S)},{once:!0})},renderList:function(){var t,e,i=this.index,n=this.items[i];n&&(e=n.nextElementSibling,t=parseInt(window.getComputedStyle(e||n).marginLeft,10),e=n.offsetWidth,rt(this.list,st({width:(n=e+t)*this.length-t},kt({translateX:(this.viewerData.width-e)/2-n*i}))))},resetList:function(){var t=this.list;t.innerHTML="",ct(t,S),rt(t,kt({translateX:0}))},initImage:function(r){var t,h=this,l=this.options,e=this.image,i=this.viewerData,n=this.footer.offsetHeight,c=i.width,u=Math.max(i.height-n,n),d=this.imageData||{};this.imageInitializing={abort:function(){t.onload=null}},t=Dt(e,l,function(t,e){var i=t/e,n=c,o=u;h.imageInitializing=!1,c<u*i?o=c/i:n=u*i;var n=Math.min(.9*n,t),o=Math.min(.9*o,e),s=(c-n)/2,a=(u-o)/2,t={left:s,top:a,x:s,y:a,width:n,height:o,oldRatio:1,ratio:n/t,aspectRatio:i,naturalWidth:t,naturalHeight:e},e=st({},t);l.rotatable&&(t.rotate=d.rotate||0,e.rotate=0),l.scalable&&(t.scaleX=d.scaleX||1,t.scaleY=d.scaleY||1,e.scaleX=1,e.scaleY=1),h.imageData=t,h.initialImageData=e,r&&r()})},renderImage:function(t){var e,i=this,n=this.image,o=this.imageData;rt(n,st({width:o.width,height:o.height,marginLeft:o.x,marginTop:o.y},kt(o))),t&&((this.viewing||this.moving||this.rotating||this.scaling||this.zooming)&&this.options.transition&&ht(n,S)?(e=function(){i.imageRendering=!1,t()},this.imageRendering={abort:function(){wt(n,W,e)}},yt(n,W,e,{once:!0})):t())},resetImage:function(){var t;(this.viewing||this.viewed)&&(t=this.image,this.viewing&&this.viewing.abort(),t.parentNode.removeChild(t),this.image=null)}},r={bind:function(){var t=this.options,e=this.viewer,i=this.canvas,n=this.element.ownerDocument;yt(e,O,this.onClick=this.click.bind(this)),yt(e,L,this.onDragStart=this.dragstart.bind(this)),yt(i,X,this.onPointerDown=this.pointerdown.bind(this)),yt(n,M,this.onPointerMove=this.pointermove.bind(this)),yt(n,q,this.onPointerUp=this.pointerup.bind(this)),yt(n,F,this.onKeyDown=this.keydown.bind(this)),yt(window,P,this.onResize=this.resize.bind(this)),t.zoomable&&t.zoomOnWheel&&yt(e,j,this.onWheel=this.wheel.bind(this),{passive:!1,capture:!0}),t.toggleOnDblclick&&yt(i,C,this.onDblclick=this.dblclick.bind(this))},unbind:function(){var t=this.options,e=this.viewer,i=this.canvas,n=this.element.ownerDocument;wt(e,O,this.onClick),wt(e,L,this.onDragStart),wt(i,X,this.onPointerDown),wt(n,M,this.onPointerMove),wt(n,q,this.onPointerUp),wt(n,F,this.onKeyDown),wt(window,P,this.onResize),t.zoomable&&t.zoomOnWheel&&wt(e,j,this.onWheel,{passive:!1,capture:!0}),t.toggleOnDblclick&&wt(i,C,this.onDblclick)}},t={click:function(t){var e=this.options,i=this.imageData,n=t.target,o=gt(n,K);switch(o||"img"!==n.localName||"li"!==n.parentElement.localName||(o=gt(n=n.parentElement,K)),a&&t.isTrusted&&n===this.canvas&&clearTimeout(this.clickCanvasTimeout),o){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(gt(n,"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(-i.scaleX||-1);break;case"flip-vertical":this.scaleY(-i.scaleY||-1);break;default:this.played&&this.stop()}},dblclick:function(t){t.preventDefault(),this.viewed&&t.target===this.image&&(a&&t.isTrusted&&clearTimeout(this.doubleClickImageTimeout),this.toggle(t))},load:function(){var t=this;this.timeout&&(clearTimeout(this.timeout),this.timeout=!1);var e=this.element,i=this.options,n=this.image,o=this.index,s=this.viewerData;ct(n,D),i.loading&&ct(this.canvas,T),n.style.cssText="height:0;"+"margin-left:".concat(s.width/2,"px;")+"margin-top:".concat(s.height/2,"px;")+"max-width:none!important;position:relative;width:0;",this.initImage(function(){ut(n,E,i.movable),ut(n,S,i.transition),t.renderImage(function(){t.viewed=!0,t.viewing=!1,nt(i.viewed)&&yt(e,V,i.viewed,{once:!0}),xt(e,V,{originalImage:t.images[o],index:o,image:n},{cancelable:!1})})})},loadImage:function(t){var n=t.target,t=n.parentNode,o=t.offsetWidth||30,s=t.offsetHeight||50,a=!!gt(n,"filled");Dt(n,this.options,function(t,e){var i=t/e,t=o,e=s;o<s*i?a?t=s*i:e=o/i:a?e=o/i:t=s*i,rt(n,st({width:t,height:e},kt({translateX:(o-t)/2,translateY:(s-e)/2})))})},keydown:function(t){var e=this.options;if(e.keyboard){var i=t.keyCode||t.which||t.charCode;if(13===i&&this.viewer.contains(t.target)&&this.click(t),this.fulled)switch(i){case 27:this.played?this.stop():e.inline?this.fulled&&this.exit():this.hide();break;case 32:this.played&&this.stop();break;case 37:this.prev(e.loop);break;case 38:t.preventDefault(),this.zoom(e.zoomRatio,!0);break;case 39:this.next(e.loop);break;case 40:t.preventDefault(),this.zoom(-e.zoomRatio,!0);break;case 48:case 49:t.ctrlKey&&(t.preventDefault(),this.toggle())}}},dragstart:function(t){"img"===t.target.localName&&t.preventDefault()},pointerdown:function(t){var e=this.options,i=this.pointers,n=t.buttons,o=t.button;!this.viewed||this.showing||this.viewing||this.hiding||("mousedown"===t.type||"pointerdown"===t.type&&"mouse"===t.pointerType)&&(J(n)&&1!==n||J(o)&&0!==o||t.ctrlKey)||(t.preventDefault(),t.changedTouches?ot(t.changedTouches,function(t){i[t.identifier]=Et(t)}):i[t.pointerId||0]=Et(t),o=!!e.movable&&c,e.zoomOnTouch&&e.zoomable&&1<Object.keys(i).length?o=d:e.slideOnTouch&&("touch"===t.pointerType||"touchstart"===t.type)&&this.isSwitchable()&&(o=u),!e.transition||o!==c&&o!==d||ct(this.image,S),this.action=o)},pointermove:function(t){var e=this.pointers,i=this.action;this.viewed&&i&&(t.preventDefault(),t.changedTouches?ot(t.changedTouches,function(t){st(e[t.identifier]||{},Et(t,!0))}):st(e[t.pointerId||0]||{},Et(t,!0)),this.change(t))},pointerup:function(t){var e,i=this,n=this.options,o=this.action,s=this.pointers;t.changedTouches?ot(t.changedTouches,function(t){e=s[t.identifier],delete s[t.identifier]}):(e=s[t.pointerId||0],delete s[t.pointerId||0]),o&&(t.preventDefault(),!n.transition||o!==c&&o!==d||lt(this.image,S),this.action=!1,a&&o!==d&&e&&Date.now()-e.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(){xt(i.image,C)},50)):(this.imageClicked=!0,this.doubleClickImageTimeout=setTimeout(function(){i.imageClicked=!1},500)):(this.imageClicked=!1,n.backdrop&&"static"!==n.backdrop&&t.target===this.canvas&&(this.clickCanvasTimeout=setTimeout(function(){xt(i.canvas,O)},50)))))},resize:function(){var e=this;this.isShown&&!this.hiding&&(this.fulled&&(this.close(),this.initBody(),this.open()),this.initContainer(),this.initViewer(),this.renderViewer(),this.renderList(),this.viewed&&this.initImage(function(){e.renderImage()}),this.played&&(!this.options.fullscreen||!this.fulled||document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement?ot(this.player.getElementsByTagName("img"),function(t){yt(t,N,e.loadImage.bind(e),{once:!0}),xt(t,N)}):this.stop()))},wheel:function(t){var e,i,n=this;this.viewed&&(t.preventDefault(),this.wheeling||(this.wheeling=!0,setTimeout(function(){n.wheeling=!1},50),e=Number(this.options.zoomRatio)||.1,i=1,t.deltaY?i=0<t.deltaY?1:-1:t.wheelDelta?i=-t.wheelDelta/120:t.detail&&(i=0<t.detail?1:-1),this.zoom(-i*e,!0,t)))}},St={show:function(){var t=0<arguments.length&&void 0!==arguments[0]&&arguments[0],e=this.element,i=this.options;if(i.inline||this.showing||this.isShown||this.showing)return this;if(!this.ready)return this.build(),this.ready&&this.show(t),this;if(nt(i.show)&&yt(e,B,i.show,{once:!0}),!1===xt(e,B)||!this.ready)return this;this.hiding&&this.transitioning.abort(),this.showing=!0,this.open();var n,o=this.viewer;return ct(o,y),o.setAttribute("role","dialog"),o.setAttribute("aria-labelledby",this.title.id),o.setAttribute("aria-modal",!0),o.removeAttribute("aria-hidden"),i.transition&&!t?(n=this.shown.bind(this),this.transitioning={abort:function(){wt(o,W,n),ct(o,z)}},lt(o,S),o.initialOffsetWidth=o.offsetWidth,yt(o,W,n,{once:!0}),lt(o,z)):(lt(o,z),this.shown()),this},hide:function(){var i=this,t=0<arguments.length&&void 0!==arguments[0]&&arguments[0],e=this.element,n=this.options;if(n.inline||this.hiding||!this.isShown&&!this.showing)return this;if(nt(n.hide)&&yt(e,"hide",n.hide,{once:!0}),!1===xt(e,"hide"))return this;this.showing&&this.transitioning.abort(),this.hiding=!0,this.played?this.stop():this.viewing&&this.viewing.abort();var o,s,a=this.viewer,r=this.image,h=function(){ct(a,z),i.hidden()};return n.transition&&!t?(o=function t(e){e&&e.target===a&&(wt(a,W,t),i.hidden())},s=function(){ht(a,S)?(yt(a,W,o),ct(a,z)):h()},this.transitioning={abort:function(){i.viewed&&ht(r,S)?wt(r,W,s):ht(a,S)&&wt(a,W,o)}},this.viewed&&ht(r,S)?(yt(r,W,s,{once:!0}),this.zoomTo(0,!1,null,!0)):s()):h(),this},view:function(){var i=this,t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.options.initialViewIndex,t=Number(t)||0;if(this.hiding||this.played||t<0||t>=this.length||this.viewed&&t===this.index)return this;if(!this.isShown)return this.index=t,this.show();this.viewing&&this.viewing.abort();var e=this.element,n=this.options,o=this.title,s=this.canvas,a=this.items[t],r=a.querySelector("img"),h=gt(r,"originalUrl"),l=r.getAttribute("alt"),c=document.createElement("img");if(ot(n.inheritedAttributes,function(t){var e=r.getAttribute(t);null!==e&&c.setAttribute(t,e)}),c.src=h,c.alt=l,nt(n.view)&&yt(e,"view",n.view,{once:!0}),!1===xt(e,"view",{originalImage:this.images[t],index:t,image:c})||!this.isShown||this.hiding||this.played)return this;h=this.items[this.index];h&&(ct(h,f),h.removeAttribute("aria-selected")),lt(a,f),a.setAttribute("aria-selected",!0),n.focus&&a.focus(),this.image=c,this.viewed=!1,this.index=t,this.imageData={},lt(c,D),n.loading&<(s,T),s.innerHTML="",s.appendChild(c),this.renderList(),o.innerHTML="";function u(){var t=i.imageData,e=Array.isArray(n.title)?n.title[1]:n.title;o.innerHTML=_(t=nt(e)?e.call(i,c,t):"".concat(l," (").concat(t.naturalWidth," × ").concat(t.naturalHeight,")"))?t.replace(/&(?!amp;|quot;|#39;|lt;|gt;)/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">"):t}var d,m;return yt(e,V,u,{once:!0}),this.viewing={abort:function(){wt(e,V,u),c.complete?i.imageRendering?i.imageRendering.abort():i.imageInitializing&&i.imageInitializing.abort():(c.src="",wt(c,N,d),i.timeout&&clearTimeout(i.timeout))}},c.complete?this.load():(yt(c,N,d=function(){wt(c,Y,m),i.load()},{once:!0}),yt(c,Y,m=function(){wt(c,N,d),i.timeout&&(clearTimeout(i.timeout),i.timeout=!1),ct(c,D),n.loading&&ct(i.canvas,T)},{once:!0}),this.timeout&&clearTimeout(this.timeout),this.timeout=setTimeout(function(){ct(c,D),i.timeout=!1},1e3)),this},prev:function(){var t=this.index-1;return t<0&&(t=0<arguments.length&&void 0!==arguments[0]&&arguments[0]?this.length-1:0),this.view(t),this},next:function(){var t=this.length-1,e=this.index+1;return this.view(e=t<e?0<arguments.length&&void 0!==arguments[0]&&arguments[0]?0:t:e),this},move:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:t,i=this.imageData;return this.moveTo(Q(t)?t:i.x+Number(t),Q(e)?e:i.y+Number(e)),this},moveTo:function(t){var e=this,i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:t,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,o=this.element,s=this.options,a=this.imageData;if(t=Number(t),i=Number(i),this.viewed&&!this.played&&s.movable){var r=a.x,h=a.y,l=!1;if(J(t)?l=!0:t=r,J(i)?l=!0:i=h,l){if(nt(s.move)&&yt(o,"move",s.move,{once:!0}),!1===xt(o,"move",{x:t,y:i,oldX:r,oldY:h,originalEvent:n}))return this;a.x=t,a.y=i,a.left=t,a.top=i,this.moving=!0,this.renderImage(function(){e.moving=!1,nt(s.moved)&&yt(o,"moved",s.moved,{once:!0}),xt(o,"moved",{x:t,y:i,oldX:r,oldY:h,originalEvent:n},{cancelable:!1})})}}return this},rotate:function(t){return this.rotateTo((this.imageData.rotate||0)+Number(t)),this},rotateTo:function(t){var e=this,i=this.element,n=this.options,o=this.imageData;if(J(t=Number(t))&&this.viewed&&!this.played&&n.rotatable){var s=o.rotate;if(nt(n.rotate)&&yt(i,"rotate",n.rotate,{once:!0}),!1===xt(i,"rotate",{degree:t,oldDegree:s}))return this;o.rotate=t,this.rotating=!0,this.renderImage(function(){e.rotating=!1,nt(n.rotated)&&yt(i,U,n.rotated,{once:!0}),xt(i,U,{degree:t,oldDegree:s},{cancelable:!1})})}return 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 e=this,i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:t,n=this.element,o=this.options,s=this.imageData;if(t=Number(t),i=Number(i),this.viewed&&!this.played&&o.scalable){var a=s.scaleX,r=s.scaleY,h=!1;if(J(t)?h=!0:t=a,J(i)?h=!0:i=r,h){if(nt(o.scale)&&yt(n,"scale",o.scale,{once:!0}),!1===xt(n,"scale",{scaleX:t,scaleY:i,oldScaleX:a,oldScaleY:r}))return this;s.scaleX=t,s.scaleY=i,this.scaling=!0,this.renderImage(function(){e.scaling=!1,nt(o.scaled)&&yt(n,"scaled",o.scaled,{once:!0}),xt(n,"scaled",{scaleX:t,scaleY:i,oldScaleX:a,oldScaleY:r},{cancelable:!1})})}}return this},zoom:function(t){var e=1<arguments.length&&void 0!==arguments[1]&&arguments[1],i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,n=this.imageData;return t=Number(t),this.zoomTo(n.width*(t=t<0?1/(1-t):1+t)/n.naturalWidth,e,i),this},zoomTo:function(t){var i,n,o,e=this,s=1<arguments.length&&void 0!==arguments[1]&&arguments[1],a=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,r=3<arguments.length&&void 0!==arguments[3]&&arguments[3],h=this.element,l=this.options,c=this.pointers,u=this.imageData,d=u.x,m=u.y,g=u.width,f=u.height,v=u.naturalWidth,p=u.naturalHeight;if(J(t=Math.max(0,t))&&this.viewed&&!this.played&&(r||l.zoomable)){r||(b=Math.max(.01,l.minZoomRatio),w=Math.min(100,l.maxZoomRatio),t=Math.min(Math.max(t,b),w));var r=v*(t=a&&.055<=l.zoomRatio&&.95<t&&t<1.05?1:t),b=p*t,w=r-g,v=b-f,y=u.ratio;if(nt(l.zoom)&&yt(h,"zoom",l.zoom,{once:!0}),!1===xt(h,"zoom",{ratio:t,oldRatio:y,originalEvent:a}))return this;this.zooming=!0,a?(p={left:(p=(p=this.viewer).getBoundingClientRect()).left+(window.pageXOffset-document.documentElement.clientLeft),top:p.top+(window.pageYOffset-document.documentElement.clientTop)},c=c&&Object.keys(c).length?(o=n=i=0,ot(c,function(t){var e=t.startX,t=t.startY;i+=e,n+=t,o+=1}),{pageX:i/=o,pageY:n/=o}):{pageX:a.pageX,pageY:a.pageY},u.x-=(c.pageX-p.left-d)/g*w,u.y-=(c.pageY-p.top-m)/f*v):(u.x-=w/2,u.y-=v/2),u.left=u.x,u.top=u.y,u.width=r,u.height=b,u.oldRatio=y,u.ratio=t,this.renderImage(function(){e.zooming=!1,nt(l.zoomed)&&yt(h,"zoomed",l.zoomed,{once:!0}),xt(h,"zoomed",{ratio:t,oldRatio:y,originalEvent:a},{cancelable:!1})}),s&&this.tooltip()}return this},play:function(){var e=this,t=0<arguments.length&&void 0!==arguments[0]&&arguments[0];if(!this.isShown||this.played)return this;var i=this.element,o=this.options;if(nt(o.play)&&yt(i,"play",o.play,{once:!0}),!1===xt(i,"play"))return this;var s=this.player,a=this.loadImage.bind(this),r=[],h=0,l=0;return this.played=!0,this.onLoadWhenPlay=a,t&&this.requestFullscreen(t),lt(s,A),ot(this.items,function(t,e){var i=t.querySelector("img"),n=document.createElement("img");n.src=gt(i,"originalUrl"),n.alt=i.getAttribute("alt"),n.referrerPolicy=i.referrerPolicy,h+=1,lt(n,p),ut(n,S,o.transition),ht(t,f)&&(lt(n,z),l=e),r.push(n),yt(n,N,a,{once:!0}),s.appendChild(n)}),J(o.interval)&&0<o.interval&&1<h&&function t(){e.playing=setTimeout(function(){ct(r[l],z),lt(r[l=(l+=1)<h?l:0],z),t()},o.interval)}(),this},stop:function(){var e=this;if(!this.played)return this;var t=this.element,i=this.options;if(nt(i.stop)&&yt(t,"stop",i.stop,{once:!0}),!1===xt(t,"stop"))return this;t=this.player;return this.played=!1,clearTimeout(this.playing),ot(t.getElementsByTagName("img"),function(t){wt(t,N,e.onLoadWhenPlay)}),ct(t,A),t.innerHTML="",this.exitFullscreen(),this},full:function(){var t=this,e=this.options,i=this.viewer,n=this.image,o=this.list;return!this.isShown||this.played||this.fulled||!e.inline||(this.fulled=!0,this.open(),lt(this.button,h),e.transition&&(ct(o,S),this.viewed&&ct(n,S)),lt(i,b),i.setAttribute("role","dialog"),i.setAttribute("aria-labelledby",this.title.id),i.setAttribute("aria-modal",!0),i.removeAttribute("style"),rt(i,{zIndex:e.zIndex}),e.focus&&this.enforceFocus(),this.initContainer(),this.viewerData=st({},this.containerData),this.renderList(),this.viewed&&this.initImage(function(){t.renderImage(function(){e.transition&&setTimeout(function(){lt(n,S),lt(o,S)},0)})})),this},exit:function(){var t=this,e=this.options,i=this.viewer,n=this.image,o=this.list;return this.isShown&&!this.played&&this.fulled&&e.inline&&(this.fulled=!1,this.close(),ct(this.button,h),e.transition&&(ct(o,S),this.viewed&&ct(n,S)),e.focus&&this.clearEnforceFocus(),i.removeAttribute("role"),i.removeAttribute("aria-labelledby"),i.removeAttribute("aria-modal"),ct(i,b),rt(i,{zIndex:e.zIndexInline}),this.viewerData=st({},this.parentData),this.renderViewer(),this.renderList(),this.viewed&&this.initImage(function(){t.renderImage(function(){e.transition&&setTimeout(function(){lt(n,S),lt(o,S)},0)})})),this},tooltip:function(){var t=this,e=this.options,i=this.tooltipBox,n=this.imageData;return this.viewed&&!this.played&&e.tooltip&&(i.textContent="".concat(Math.round(100*n.ratio),"%"),this.tooltipping?clearTimeout(this.tooltipping):e.transition?(this.fading&&xt(i,W),lt(i,A),lt(i,p),lt(i,S),i.removeAttribute("aria-hidden"),i.initialOffsetWidth=i.offsetWidth,lt(i,z)):(lt(i,A),i.removeAttribute("aria-hidden")),this.tooltipping=setTimeout(function(){e.transition?(yt(i,W,function(){ct(i,A),ct(i,p),ct(i,S),i.setAttribute("aria-hidden",!0),t.fading=!1},{once:!0}),ct(i,z),t.fading=!0):(ct(i,A),i.setAttribute("aria-hidden",!0)),t.tooltipping=!1},1e3)),this},toggle:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;return 1===this.imageData.ratio?this.zoomTo(this.imageData.oldRatio,!0,t):this.zoomTo(1,!0,t),this},reset:function(){return this.viewed&&!this.played&&(this.imageData=st({},this.initialImageData),this.renderImage()),this},update:function(){var e=this,t=this.element,i=this.options,n=this.isImg;if(n&&!t.parentNode)return this.destroy();var o,s=[];return ot(n?[t]:t.querySelectorAll("img"),function(t){nt(i.filter)?i.filter.call(e,t)&&s.push(t):e.getImageURL(t)&&s.push(t)}),s.length&&(this.images=s,this.length=s.length,this.ready?(o=[],ot(this.items,function(t,e){var i=t.querySelector("img"),t=s[e];t&&i&&t.src===i.src&&t.alt===i.alt||o.push(e)}),rt(this.list,{width:"auto"}),this.initList(),this.isShown&&(this.length?this.viewed&&(0<=(t=o.indexOf(this.index))?(this.viewed=!1,this.view(Math.max(Math.min(this.index-t,this.length-1),0))):(lt(t=this.items[this.index],f),t.setAttribute("aria-selected",!0))):(this.image=null,this.viewed=!1,this.index=0,this.imageData={},this.canvas.innerHTML="",this.title.innerHTML=""))):this.build()),this},destroy:function(){var t=this.element,e=this.options;return t[g]&&(this.destroyed=!0,this.ready?(this.played&&this.stop(),e.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)):e.inline&&(this.delaying?this.delaying.abort():this.initializing&&this.initializing.abort()),e.inline||wt(t,O,this.onStart),t[g]=void 0),this}},Ot={getImageURL:function(t){var e=this.options.url;return e=_(e)?t.getAttribute(e):nt(e)?e.call(this,t):""},enforceFocus:function(){var i=this;this.clearEnforceFocus(),yt(document,R,this.onFocusin=function(t){var e=i.viewer,t=t.target;t===document||t===e||e.contains(t)||null!==t.getAttribute("tabindex")&&"true"===t.getAttribute("aria-modal")||e.focus()})},clearEnforceFocus:function(){this.onFocusin&&(wt(document,R,this.onFocusin),this.onFocusin=null)},open:function(){var t=this.body;lt(t,I),t.style.paddingRight="".concat(this.scrollbarWidth+(parseFloat(this.initialBodyComputedPaddingRight)||0),"px")},close:function(){var t=this.body;ct(t,I),t.style.paddingRight=this.initialBodyPaddingRight},shown:function(){var t=this.element,e=this.options,i=this.viewer;this.fulled=!0,this.isShown=!0,this.render(),this.bind(),this.showing=!1,e.focus&&(i.focus(),this.enforceFocus()),nt(e.shown)&&yt(t,"shown",e.shown,{once:!0}),!1!==xt(t,"shown")&&this.ready&&this.isShown&&!this.hiding&&this.view(this.index)},hidden:function(){var t=this.element,e=this.options,i=this.viewer;e.fucus&&this.clearEnforceFocus(),this.fulled=!1,this.viewed=!1,this.isShown=!1,this.close(),this.unbind(),lt(i,y),i.removeAttribute("role"),i.removeAttribute("aria-labelledby"),i.removeAttribute("aria-modal"),i.setAttribute("aria-hidden",!0),this.resetList(),this.resetImage(),this.hiding=!1,this.destroyed||(nt(e.hidden)&&yt(t,"hidden",e.hidden,{once:!0}),xt(t,"hidden",null,{cancelable:!1}))},requestFullscreen:function(t){var e=this.element.ownerDocument;this.fulled&&!(e.fullscreenElement||e.webkitFullscreenElement||e.mozFullScreenElement||e.msFullscreenElement)&&((e=e.documentElement).requestFullscreen?it(t)?e.requestFullscreen(t):e.requestFullscreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT):e.mozRequestFullScreen?e.mozRequestFullScreen():e.msRequestFullscreen&&e.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 e=this.options,i=this.pointers,n=i[Object.keys(i)[0]];if(n){var s,a,o=n.endX-n.startX,r=n.endY-n.startY;switch(this.action){case c:this.move(o,r,t);break;case d:this.zoom((s=l({},h=i),a=[],ot(h,function(o,t){delete s[t],ot(s,function(t){var e=Math.abs(o.startX-t.startX),i=Math.abs(o.startY-t.startY),n=Math.abs(o.endX-t.endX),t=Math.abs(o.endY-t.endY),i=Math.sqrt(e*e+i*i),t=Math.sqrt(n*n+t*t);a.push((t-i)/i)})}),a.sort(function(t,e){return Math.abs(t)<Math.abs(e)}),a[0]),!1,t);break;case u:this.action="switched";var h=Math.abs(o);1<h&&h>Math.abs(r)&&(this.pointers={},1<o?this.prev(e.loop):o<-1&&this.next(e.loop))}ot(i,function(t){t.startX=t.endX,t.startY=t.endY})}},isSwitchable:function(){var t=this.imageData,e=this.viewerData;return 1<this.length&&0<=t.x&&0<=t.y&&t.width<=e.width&&t.height<=e.height}},Ct=n.Viewer,Lt=(It=-1,function(){return It+=1}),n=function(){function i(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,i),!t||1!==t.nodeType)throw new Error("The first argument is required and must be an element.");this.element=t,this.options=st({},s,it(e)&&e),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.moving=!1,this.played=!1,this.playing=!1,this.pointers={},this.ready=!1,this.rotating=!1,this.scaling=!1,this.showing=!1,this.timeout=!1,this.tooltipping=!1,this.viewed=!1,this.viewing=!1,this.wheeling=!1,this.zooming=!1,this.id=Lt(),this.init()}var t,e,n;return t=i,n=[{key:"noConflict",value:function(){return window.Viewer=Ct,i}},{key:"setDefaults",value:function(t){st(s,it(t)&&t)}}],(e=[{key:"init",value:function(){var t,e,i,n,o=this,s=this.element,a=this.options;s[g]||(s[g]=this,a.focus&&!a.keyboard&&(a.focus=!1),t="img"===s.localName,e=[],ot(t?[s]:s.querySelectorAll("img"),function(t){nt(a.filter)?a.filter.call(o,t)&&e.push(t):o.getImageURL(t)&&e.push(t)}),this.isImg=t,this.length=e.length,this.images=e,this.initBody(),Q(document.createElement(g).style.transition)&&(a.transition=!1),a.inline?(i=0,n=function(){var t;(i+=1)===o.length&&(o.initializing=!1,o.delaying={abort:function(){clearTimeout(t)}},t=setTimeout(function(){o.delaying=!1,o.build()},0))},this.initializing={abort:function(){ot(e,function(t){t.complete||wt(t,N,n)})}},ot(e,function(t){t.complete?n():yt(t,N,n,{once:!0})})):yt(s,O,this.onStart=function(t){t=t.target;"img"!==t.localName||nt(a.filter)&&!a.filter.call(o,t)||o.view(o.images.indexOf(t))}))}},{key:"build",value:function(){var t,s,e,i,n,o,a,r,h,l,c,u,d,m;this.ready||(t=this.element,s=this.options,e=t.parentNode,(d=document.createElement("div")).innerHTML='<div class="viewer-container" tabindex="-1" 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" role="navigation"></ul></div></div><div class="viewer-tooltip" role="alert" aria-hidden="true"></div><div class="viewer-button" data-viewer-action="mix" role="button"></div><div class="viewer-player"></div></div>',n=(i=d.querySelector(".".concat(g,"-container"))).querySelector(".".concat(g,"-title")),o=i.querySelector(".".concat(g,"-toolbar")),a=i.querySelector(".".concat(g,"-navbar")),m=i.querySelector(".".concat(g,"-button")),d=i.querySelector(".".concat(g,"-canvas")),this.parent=e,this.viewer=i,this.title=n,this.toolbar=o,this.navbar=a,this.button=m,this.canvas=d,this.footer=i.querySelector(".".concat(g,"-footer")),this.tooltipBox=i.querySelector(".".concat(g,"-tooltip")),this.player=i.querySelector(".".concat(g,"-player")),this.list=i.querySelector(".".concat(g,"-list")),i.id="".concat(g).concat(this.id),n.id="".concat(g,"Title").concat(this.id),lt(n,s.title?Tt(Array.isArray(s.title)?s.title[0]:s.title):y),lt(a,s.navbar?Tt(s.navbar):y),ut(m,y,!s.button),s.keyboard&&m.setAttribute("tabindex",0),s.backdrop&&(lt(i,"".concat(g,"-backdrop")),s.inline||"static"===s.backdrop||ft(d,K,"hide")),_(s.className)&&s.className&&s.className.split(Z).forEach(function(t){lt(i,t)}),s.toolbar?(r=document.createElement("ul"),h=it(s.toolbar),l=$.slice(0,3),c=$.slice(7,9),u=$.slice(9),h||lt(o,Tt(s.toolbar)),ot(h?s.toolbar:$,function(t,e){var i=h&&it(t),n=h?mt(e):t,o=i&&!Q(t.show)?t.show:t;!o||!s.zoomable&&-1!==l.indexOf(n)||!s.rotatable&&-1!==c.indexOf(n)||!s.scalable&&-1!==u.indexOf(n)||(e=i&&!Q(t.size)?t.size:t,i=i&&!Q(t.click)?t.click:t,t=document.createElement("li"),s.keyboard&&t.setAttribute("tabindex",0),t.setAttribute("role","button"),lt(t,"".concat(g,"-").concat(n)),nt(i)||ft(t,K,n),J(o)&<(t,Tt(o)),-1!==["small","large"].indexOf(e)?lt(t,"".concat(g,"-").concat(e)):"play"===n&<(t,"".concat(g,"-large")),nt(i)&&yt(t,O,i),r.appendChild(t))}),o.appendChild(r)):lt(o,y),s.rotatable||(lt(d=o.querySelectorAll('li[class*="rotate"]'),D),ot(d,function(t){o.appendChild(t)})),s.inline?(lt(m,w),rt(i,{zIndex:s.zIndexInline}),"static"===window.getComputedStyle(e).position&&rt(e,{position:"relative"}),e.insertBefore(i,t.nextSibling)):(lt(m,v),lt(i,b),lt(i,p),lt(i,y),rt(i,{zIndex:s.zIndex}),(m=(m=_(m=s.container)?t.ownerDocument.querySelector(m):m)||this.body).appendChild(i)),s.inline&&(this.render(),this.bind(),this.isShown=!0),this.ready=!0,nt(s.ready)&&yt(t,H,s.ready,{once:!0}),!1!==xt(t,H)?this.ready&&s.inline&&this.view(this.index):this.ready=!1)}}])&&o(t.prototype,e),n&&o(t,n),i}();return st(n.prototype,At,r,t,St,Ot),n}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Viewer=e()}(this,function(){"use strict";function e(e,t){var i,n=Object.keys(e);return Object.getOwnPropertySymbols&&(i=Object.getOwnPropertySymbols(e),t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)),n}function l(n){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?e(Object(o),!0).forEach(function(t){var e,i;e=n,i=o[t=t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(o)):e(Object(o)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(o,t))})}return n}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 n(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var s={backdrop:!0,button:!0,navbar:!0,title:!0,toolbar:!0,className:"",container:"body",filter:null,fullscreen:!0,inheritedAttributes:["crossOrigin","decoding","isMap","loading","referrerPolicy","sizes","srcset","useMap"],initialViewIndex:0,inline:!1,interval:5e3,keyboard:!0,focus:!0,loading:!0,loop:!0,minWidth:200,minHeight:100,movable:!0,rotatable:!0,scalable:!0,zoomable:!0,zoomOnTouch:!0,zoomOnWheel:!0,slideOnTouch:!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,move:null,moved:null,rotate:null,rotated:null,scale:null,scaled:null,zoom:null,zoomed:null,play:null,stop:null},t="undefined"!=typeof window&&void 0!==window.document,o=t?window:{},a=!(!t||!o.document.documentElement)&&"ontouchstart"in o.document.documentElement,r=t&&"PointerEvent"in o,g="viewer",c="move",d="switch",m="zoom",b="".concat(g,"-active"),w="".concat(g,"-close"),y="".concat(g,"-fade"),E="".concat(g,"-fixed"),I="".concat(g,"-fullscreen"),h="".concat(g,"-fullscreen-exit"),A="".concat(g,"-hide"),S="".concat(g,"-hide-md-down"),O="".concat(g,"-hide-sm-down"),C="".concat(g,"-hide-xs-down"),L="".concat(g,"-in"),R="".concat(g,"-invisible"),F="".concat(g,"-loading"),N="".concat(g,"-move"),Y="".concat(g,"-open"),X="".concat(g,"-show"),u="".concat(g,"-transition"),M="click",P="dblclick",q="dragstart",W="focusin",j="keydown",H="load",B="error",V=r?"pointerdown":a?"touchstart":"mousedown",U=r?"pointermove":a?"touchmove":"mousemove",K=r?"pointerup pointercancel":a?"touchend touchcancel":"mouseup",Z="resize",$="transitionend",_="wheel",G="ready",J="show",Q="viewed",tt="rotated",et="".concat(g,"Action"),it=/\s\s*/,nt=["zoom-in","zoom-out","one-to-one","reset","prev","play","next","rotate-left","rotate-right","flip-horizontal","flip-vertical"];function ot(t){return"string"==typeof t}var st=Number.isNaN||o.isNaN;function x(t){return"number"==typeof t&&!st(t)}function at(t){return void 0===t}function rt(t){return"object"===i(t)&&null!==t}var ht=Object.prototype.hasOwnProperty;function lt(t){if(!rt(t))return!1;try{var e=t.constructor,i=e.prototype;return e&&i&&ht.call(i,"isPrototypeOf")}catch(t){return!1}}function k(t){return"function"==typeof t}function z(e,i){if(e&&k(i))if(Array.isArray(e)||x(e.length))for(var t=e.length,n=0;n<t&&!1!==i.call(e,e[n],n,e);n+=1);else rt(e)&&Object.keys(e).forEach(function(t){i.call(e,e[t],t,e)});return e}var ct=Object.assign||function(i){for(var t=arguments.length,e=new Array(1<t?t-1:0),n=1;n<t;n++)e[n-1]=arguments[n];return rt(i)&&0<e.length&&e.forEach(function(e){rt(e)&&Object.keys(e).forEach(function(t){i[t]=e[t]})}),i},ut=/^(?:width|height|left|top|marginLeft|marginTop)$/;function dt(t,e){var i=t.style;z(e,function(t,e){ut.test(e)&&x(t)&&(t+="px"),i[e]=t})}function mt(t,e){return t&&e&&(t.classList?t.classList.contains(e):-1<t.className.indexOf(e))}function f(t,e){var i;t&&e&&(x(t.length)?z(t,function(t){f(t,e)}):t.classList?t.classList.add(e):(i=t.className.trim())?i.indexOf(e)<0&&(t.className="".concat(i," ").concat(e)):t.className=e)}function v(t,e){t&&e&&(x(t.length)?z(t,function(t){v(t,e)}):t.classList?t.classList.remove(e):0<=t.className.indexOf(e)&&(t.className=t.className.replace(e,"")))}function gt(t,e,i){e&&(x(t.length)?z(t,function(t){gt(t,e,i)}):(i?f:v)(t,e))}var ft=/([a-z\d])([A-Z])/g;function vt(t){return t.replace(ft,"$1-$2").toLowerCase()}function pt(t,e){return rt(t[e])?t[e]:t.dataset?t.dataset[e]:t.getAttribute("data-".concat(vt(e)))}function bt(t,e,i){rt(i)?t[e]=i:t.dataset?t.dataset[e]=i:t.setAttribute("data-".concat(vt(e)),i)}yt=!1,t&&(wt=!1,r=function(){},t=Object.defineProperty({},"once",{get:function(){return yt=!0,wt},set:function(t){wt=t}}),o.addEventListener("test",r,t),o.removeEventListener("test",r,t));var wt,yt,xt=yt;function p(i,t,n,e){var o=3<arguments.length&&void 0!==e?e:{},s=n;t.trim().split(it).forEach(function(t){var e;xt||(e=i.listeners)&&e[t]&&e[t][n]&&(s=e[t][n],delete e[t][n],0===Object.keys(e[t]).length&&delete e[t],0===Object.keys(e).length&&delete i.listeners),i.removeEventListener(t,s,o)})}function T(s,t,a,e){var r=3<arguments.length&&void 0!==e?e:{},h=a;t.trim().split(it).forEach(function(n){var t,o;r.once&&!xt&&(t=s.listeners,h=function(){delete o[n][a],s.removeEventListener(n,h,r);for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];a.apply(s,e)},(o=void 0===t?{}:t)[n]||(o[n]={}),o[n][a]&&s.removeEventListener(n,o[n][a],r),o[n][a]=h,s.listeners=o),s.addEventListener(n,h,r)})}function D(t,e,i,n){var o;return k(Event)&&k(CustomEvent)?o=new CustomEvent(e,l({bubbles:!0,cancelable:!0,detail:i},n)):(o=document.createEvent("CustomEvent")).initCustomEvent(e,!0,!0,i),t.dispatchEvent(o)}function kt(t){var e=t.rotate,i=t.scaleX,n=t.scaleY,o=t.translateX,t=t.translateY,s=[],o=(x(o)&&0!==o&&s.push("translateX(".concat(o,"px)")),x(t)&&0!==t&&s.push("translateY(".concat(t,"px)")),x(e)&&0!==e&&s.push("rotate(".concat(e,"deg)")),x(i)&&1!==i&&s.push("scaleX(".concat(i,")")),x(n)&&1!==n&&s.push("scaleY(".concat(n,")")),s.length?s.join(" "):"none");return{WebkitTransform:o,msTransform:o,transform:o}}var zt=o.navigator&&/(Macintosh|iPhone|iPod|iPad).*AppleWebKit/i.test(o.navigator.userAgent);function Tt(i,t,e){var n=document.createElement("img");if(i.naturalWidth&&!zt)return e(i.naturalWidth,i.naturalHeight),n;var o=document.body||document.documentElement;return n.onload=function(){e(n.width,n.height),zt||o.removeChild(n)},z(t.inheritedAttributes,function(t){var e=i.getAttribute(t);null!==e&&n.setAttribute(t,e)}),n.src=i.src,zt||(n.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;",o.appendChild(n)),n}function Dt(t){switch(t){case 2:return C;case 3:return O;case 4:return S;default:return""}}function Et(t,e){var i=t.pageX,t=t.pageY,n={endX:i,endY:t};return e?n:l({timeStamp:Date.now(),startX:i,startY:t},n)}var It,r={render:function(){this.initContainer(),this.initViewer(),this.initList(),this.renderViewer()},initBody:function(){var t=this.element.ownerDocument,e=t.body||t.documentElement;this.body=e,this.scrollbarWidth=window.innerWidth-t.documentElement.clientWidth,this.initialBodyPaddingRight=e.style.paddingRight,this.initialBodyComputedPaddingRight=window.getComputedStyle(e).paddingRight},initContainer:function(){this.containerData={width:window.innerWidth,height:window.innerHeight}},initViewer:function(){var t,e=this.options,i=this.parent;e.inline&&(t={width:Math.max(i.offsetWidth,e.minWidth),height:Math.max(i.offsetHeight,e.minHeight)},this.parentData=t),!this.fulled&&t||(t=this.containerData),this.viewerData=ct({},t)},renderViewer:function(){this.options.inline&&!this.fulled&&dt(this.viewer,this.viewerData)},initList:function(){var r=this,t=this.element,h=this.options,l=this.list,c=[];l.innerHTML="",z(this.images,function(i,t){var e,n,o=i.src,s=i.alt||(ot(s=o)?decodeURIComponent(s.replace(/^.*\//,"").replace(/[?&#].*$/,"")):""),a=r.getImageURL(i);(o||a)&&(e=document.createElement("li"),n=document.createElement("img"),z(h.inheritedAttributes,function(t){var e=i.getAttribute(t);null!==e&&n.setAttribute(t,e)}),n.src=o||a,n.alt=s,n.setAttribute("data-original-url",a||o),e.setAttribute("data-index",t),e.setAttribute("data-viewer-action","view"),e.setAttribute("role","button"),h.keyboard&&e.setAttribute("tabindex",0),e.appendChild(n),l.appendChild(e),c.push(e))}),z(this.items=c,function(e){var t,i,n=e.firstElementChild;bt(n,"filled",!0),h.loading&&f(e,F),T(n,H,t=function(t){p(n,B,i),h.loading&&v(e,F),r.loadImage(t)},{once:!0}),T(n,B,i=function(){p(n,H,t),h.loading&&v(e,F)},{once:!0})}),h.transition&&T(t,Q,function(){f(l,u)},{once:!0})},renderList:function(){var t,e,i=this.index,n=this.items[i];n&&(t=n.nextElementSibling,t=parseInt(window.getComputedStyle(t||n).marginLeft,10),n=n.offsetWidth,dt(this.list,ct({width:(e=n+t)*this.length-t},kt({translateX:(this.viewerData.width-n)/2-e*i}))))},resetList:function(){var t=this.list;t.innerHTML="",v(t,u),dt(t,kt({translateX:0}))},initImage:function(r){var t,h=this,l=this.options,e=this.image,i=this.viewerData,n=this.footer.offsetHeight,c=i.width,u=Math.max(i.height-n,n),d=this.imageData||{};this.imageInitializing={abort:function(){t.onload=null}},t=Tt(e,l,function(t,e){var i=t/e,n=c,o=u,s=(h.imageInitializing=!1,c<u*i?o=c/i:n=u*i,n=Math.min(.9*n,t),o=Math.min(.9*o,e),(c-n)/2),a=(u-o)/2,s={left:s,top:a,x:s,y:a,width:n,height:o,oldRatio:1,ratio:n/t,aspectRatio:i,naturalWidth:t,naturalHeight:e},a=ct({},s);l.rotatable&&(s.rotate=d.rotate||0,a.rotate=0),l.scalable&&(s.scaleX=d.scaleX||1,s.scaleY=d.scaleY||1,a.scaleX=1,a.scaleY=1),h.imageData=s,h.initialImageData=a,r&&r()})},renderImage:function(t){var e,i=this,n=this.image,o=this.imageData;dt(n,ct({width:o.width,height:o.height,marginLeft:o.x,marginTop:o.y},kt(o))),t&&((this.viewing||this.moving||this.rotating||this.scaling||this.zooming)&&this.options.transition&&mt(n,u)?(e=function(){i.imageRendering=!1,t()},this.imageRendering={abort:function(){p(n,$,e)}},T(n,$,e,{once:!0})):t())},resetImage:function(){var t;(this.viewing||this.viewed)&&(t=this.image,this.viewing&&this.viewing.abort(),t.parentNode.removeChild(t),this.image=null)}},t={bind:function(){var t=this.options,e=this.viewer,i=this.canvas,n=this.element.ownerDocument;T(e,M,this.onClick=this.click.bind(this)),T(e,q,this.onDragStart=this.dragstart.bind(this)),T(i,V,this.onPointerDown=this.pointerdown.bind(this)),T(n,U,this.onPointerMove=this.pointermove.bind(this)),T(n,K,this.onPointerUp=this.pointerup.bind(this)),T(n,j,this.onKeyDown=this.keydown.bind(this)),T(window,Z,this.onResize=this.resize.bind(this)),t.zoomable&&t.zoomOnWheel&&T(e,_,this.onWheel=this.wheel.bind(this),{passive:!1,capture:!0}),t.toggleOnDblclick&&T(i,P,this.onDblclick=this.dblclick.bind(this))},unbind:function(){var t=this.options,e=this.viewer,i=this.canvas,n=this.element.ownerDocument;p(e,M,this.onClick),p(e,q,this.onDragStart),p(i,V,this.onPointerDown),p(n,U,this.onPointerMove),p(n,K,this.onPointerUp),p(n,j,this.onKeyDown),p(window,Z,this.onResize),t.zoomable&&t.zoomOnWheel&&p(e,_,this.onWheel,{passive:!1,capture:!0}),t.toggleOnDblclick&&p(i,P,this.onDblclick)}},At={click:function(t){var e=this.options,i=this.imageData,n=t.target,o=pt(n,et);switch(o||"img"!==n.localName||"li"!==n.parentElement.localName||(o=pt(n=n.parentElement,et)),a&&t.isTrusted&&n===this.canvas&&clearTimeout(this.clickCanvasTimeout),o){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(pt(n,"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(-i.scaleX||-1);break;case"flip-vertical":this.scaleY(-i.scaleY||-1);break;default:this.played&&this.stop()}},dblclick:function(t){t.preventDefault(),this.viewed&&t.target===this.image&&(a&&t.isTrusted&&clearTimeout(this.doubleClickImageTimeout),this.toggle(t.isTrusted?t:t.detail&&t.detail.originalEvent))},load:function(){var t=this,e=(this.timeout&&(clearTimeout(this.timeout),this.timeout=!1),this.element),i=this.options,n=this.image,o=this.index,s=this.viewerData;v(n,R),i.loading&&v(this.canvas,F),n.style.cssText="height:0;"+"margin-left:".concat(s.width/2,"px;")+"margin-top:".concat(s.height/2,"px;")+"max-width:none!important;position:relative;width:0;",this.initImage(function(){gt(n,N,i.movable),gt(n,u,i.transition),t.renderImage(function(){t.viewed=!0,t.viewing=!1,k(i.viewed)&&T(e,Q,i.viewed,{once:!0}),D(e,Q,{originalImage:t.images[o],index:o,image:n},{cancelable:!1})})})},loadImage:function(t){var n=t.target,t=n.parentNode,o=t.offsetWidth||30,s=t.offsetHeight||50,a=!!pt(n,"filled");Tt(n,this.options,function(t,e){var t=t/e,e=o,i=s;o<s*t?a?e=s*t:i=o/t:a?i=o/t:e=s*t,dt(n,ct({width:e,height:i},kt({translateX:(o-e)/2,translateY:(s-i)/2})))})},keydown:function(t){var e=this.options;if(e.keyboard){var i=t.keyCode||t.which||t.charCode;if(13===i&&this.viewer.contains(t.target)&&this.click(t),this.fulled)switch(i){case 27:this.played?this.stop():e.inline?this.fulled&&this.exit():this.hide();break;case 32:this.played&&this.stop();break;case 37:this.prev(e.loop);break;case 38:t.preventDefault(),this.zoom(e.zoomRatio,!0);break;case 39:this.next(e.loop);break;case 40:t.preventDefault(),this.zoom(-e.zoomRatio,!0);break;case 48:case 49:t.ctrlKey&&(t.preventDefault(),this.toggle())}}},dragstart:function(t){"img"===t.target.localName&&t.preventDefault()},pointerdown:function(t){var e=this.options,i=this.pointers,n=t.buttons,o=t.button;!this.viewed||this.showing||this.viewing||this.hiding||("mousedown"===t.type||"pointerdown"===t.type&&"mouse"===t.pointerType)&&(x(n)&&1!==n||x(o)&&0!==o||t.ctrlKey)||(t.preventDefault(),t.changedTouches?z(t.changedTouches,function(t){i[t.identifier]=Et(t)}):i[t.pointerId||0]=Et(t),n=!!e.movable&&c,e.zoomOnTouch&&e.zoomable&&1<Object.keys(i).length?n=m:e.slideOnTouch&&("touch"===t.pointerType||"touchstart"===t.type)&&this.isSwitchable()&&(n=d),!e.transition||n!==c&&n!==m||v(this.image,u),this.action=n)},pointermove:function(t){var e=this.pointers,i=this.action;this.viewed&&i&&(t.preventDefault(),t.changedTouches?z(t.changedTouches,function(t){ct(e[t.identifier]||{},Et(t,!0))}):ct(e[t.pointerId||0]||{},Et(t,!0)),this.change(t))},pointerup:function(t){var e,i=this,n=this.options,o=this.action,s=this.pointers;t.changedTouches?z(t.changedTouches,function(t){e=s[t.identifier],delete s[t.identifier]}):(e=s[t.pointerId||0],delete s[t.pointerId||0]),o&&(t.preventDefault(),!n.transition||o!==c&&o!==m||f(this.image,u),this.action=!1,a&&o!==m&&e&&Date.now()-e.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(){D(i.image,P,{originalEvent:t})},50)):(this.imageClicked=!0,this.doubleClickImageTimeout=setTimeout(function(){i.imageClicked=!1},500)):(this.imageClicked=!1,n.backdrop&&"static"!==n.backdrop&&t.target===this.canvas&&(this.clickCanvasTimeout=setTimeout(function(){D(i.canvas,M,{originalEvent:t})},50)))))},resize:function(){var e=this;this.isShown&&!this.hiding&&(this.fulled&&(this.close(),this.initBody(),this.open()),this.initContainer(),this.initViewer(),this.renderViewer(),this.renderList(),this.viewed&&this.initImage(function(){e.renderImage()}),this.played&&(!this.options.fullscreen||!this.fulled||document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement?z(this.player.getElementsByTagName("img"),function(t){T(t,H,e.loadImage.bind(e),{once:!0}),D(t,H)}):this.stop()))},wheel:function(t){var e,i,n=this;this.viewed&&(t.preventDefault(),this.wheeling||(this.wheeling=!0,setTimeout(function(){n.wheeling=!1},50),e=Number(this.options.zoomRatio)||.1,i=1,t.deltaY?i=0<t.deltaY?1:-1:t.wheelDelta?i=-t.wheelDelta/120:t.detail&&(i=0<t.detail?1:-1),this.zoom(-i*e,!0,t)))}},St={show:function(){var t=0<arguments.length&&void 0!==arguments[0]&&arguments[0],e=this.element,i=this.options;if(i.inline||this.showing||this.isShown||this.showing)return this;if(!this.ready)return this.build(),this.ready&&this.show(t),this;if(k(i.show)&&T(e,J,i.show,{once:!0}),!1===D(e,J)||!this.ready)return this;this.hiding&&this.transitioning.abort(),this.showing=!0,this.open();var n,o=this.viewer;return v(o,A),o.setAttribute("role","dialog"),o.setAttribute("aria-labelledby",this.title.id),o.setAttribute("aria-modal",!0),o.removeAttribute("aria-hidden"),i.transition&&!t?(n=this.shown.bind(this),this.transitioning={abort:function(){p(o,$,n),v(o,L)}},f(o,u),o.initialOffsetWidth=o.offsetWidth,T(o,$,n,{once:!0}),f(o,L)):(f(o,L),this.shown()),this},hide:function(){var i=this,t=0<arguments.length&&void 0!==arguments[0]&&arguments[0],e=this.element,n=this.options;if(n.inline||this.hiding||!this.isShown&&!this.showing)return this;if(k(n.hide)&&T(e,"hide",n.hide,{once:!0}),!1===D(e,"hide"))return this;this.showing&&this.transitioning.abort(),this.hiding=!0,this.played?this.stop():this.viewing&&this.viewing.abort();var o,s,a=this.viewer,r=this.image,h=function(){v(a,L),i.hidden()};return n.transition&&!t?(o=function t(e){e&&e.target===a&&(p(a,$,t),i.hidden())},s=function(){mt(a,u)?(T(a,$,o),v(a,L)):h()},this.transitioning={abort:function(){i.viewed&&mt(r,u)?p(r,$,s):mt(a,u)&&p(a,$,o)}},this.viewed&&mt(r,u)?(T(r,$,s,{once:!0}),this.zoomTo(0,!1,null,!0)):s()):h(),this},view:function(){var i=this,t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.options.initialViewIndex,t=Number(t)||0;if(this.hiding||this.played||t<0||t>=this.length||this.viewed&&t===this.index)return this;if(!this.isShown)return this.index=t,this.show();this.viewing&&this.viewing.abort();var e=this.element,n=this.options,l=this.title,o=this.canvas,s=this.items[t],a=s.querySelector("img"),r=pt(a,"originalUrl"),c=a.getAttribute("alt"),h=document.createElement("img");if(z(n.inheritedAttributes,function(t){var e=a.getAttribute(t);null!==e&&h.setAttribute(t,e)}),h.src=r,h.alt=c,k(n.view)&&T(e,"view",n.view,{once:!0}),!1===D(e,"view",{originalImage:this.images[t],index:t,image:h})||!this.isShown||this.hiding||this.played)return this;function u(){var t=i.imageData,e=Array.isArray(n.title)?n.title[1]:n.title;l.innerHTML=ot(e=k(e)?e.call(i,h,t):"".concat(c," (").concat(t.naturalWidth," × ").concat(t.naturalHeight,")"))?e.replace(/&(?!amp;|quot;|#39;|lt;|gt;)/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">"):e}var d,m,r=this.items[this.index];r&&(v(r,b),r.removeAttribute("aria-selected")),f(s,b),s.setAttribute("aria-selected",!0),n.focus&&s.focus(),this.image=h,this.viewed=!1,this.index=t,this.imageData={},f(h,R),n.loading&&f(o,F),o.innerHTML="",o.appendChild(h),this.renderList(),l.innerHTML="";return T(e,Q,u,{once:!0}),this.viewing={abort:function(){p(e,Q,u),h.complete?i.imageRendering?i.imageRendering.abort():i.imageInitializing&&i.imageInitializing.abort():(h.src="",p(h,H,d),i.timeout&&clearTimeout(i.timeout))}},h.complete?this.load():(T(h,H,d=function(){p(h,B,m),i.load()},{once:!0}),T(h,B,m=function(){p(h,H,d),i.timeout&&(clearTimeout(i.timeout),i.timeout=!1),v(h,R),n.loading&&v(i.canvas,F)},{once:!0}),this.timeout&&clearTimeout(this.timeout),this.timeout=setTimeout(function(){v(h,R),i.timeout=!1},1e3)),this},prev:function(){var t=this.index-1;return t<0&&(t=0<arguments.length&&void 0!==arguments[0]&&arguments[0]?this.length-1:0),this.view(t),this},next:function(){var t=this.length-1,e=this.index+1;return this.view(e=t<e?0<arguments.length&&void 0!==arguments[0]&&arguments[0]?0:t:e),this},move:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:t,i=this.imageData;return this.moveTo(at(t)?t:i.x+Number(t),at(e)?e:i.y+Number(e)),this},moveTo:function(t){var l=this,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:t,i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,n=this.element,o=this.options,s=this.imageData;if(t=Number(t),e=Number(e),this.viewed&&!this.played&&o.movable){var a=s.x,r=s.y,h=!1;if(x(t)?h=!0:t=a,x(e)?h=!0:e=r,h){if(k(o.move)&&T(n,"move",o.move,{once:!0}),!1===D(n,"move",{x:t,y:e,oldX:a,oldY:r,originalEvent:i}))return this;s.x=t,s.y=e,s.left=t,s.top=e,this.moving=!0,this.renderImage(function(){l.moving=!1,k(o.moved)&&T(n,"moved",o.moved,{once:!0}),D(n,"moved",{x:t,y:e,oldX:a,oldY:r,originalEvent:i},{cancelable:!1})})}}return this},rotate:function(t){return this.rotateTo((this.imageData.rotate||0)+Number(t)),this},rotateTo:function(t){var e=this,i=this.element,n=this.options,o=this.imageData;if(x(t=Number(t))&&this.viewed&&!this.played&&n.rotatable){var s=o.rotate;if(k(n.rotate)&&T(i,"rotate",n.rotate,{once:!0}),!1===D(i,"rotate",{degree:t,oldDegree:s}))return this;o.rotate=t,this.rotating=!0,this.renderImage(function(){e.rotating=!1,k(n.rotated)&&T(i,tt,n.rotated,{once:!0}),D(i,tt,{degree:t,oldDegree:s},{cancelable:!1})})}return 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 e=this,i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:t,n=this.element,o=this.options,s=this.imageData;if(t=Number(t),i=Number(i),this.viewed&&!this.played&&o.scalable){var a=s.scaleX,r=s.scaleY,h=!1;if(x(t)?h=!0:t=a,x(i)?h=!0:i=r,h){if(k(o.scale)&&T(n,"scale",o.scale,{once:!0}),!1===D(n,"scale",{scaleX:t,scaleY:i,oldScaleX:a,oldScaleY:r}))return this;s.scaleX=t,s.scaleY=i,this.scaling=!0,this.renderImage(function(){e.scaling=!1,k(o.scaled)&&T(n,"scaled",o.scaled,{once:!0}),D(n,"scaled",{scaleX:t,scaleY:i,oldScaleX:a,oldScaleY:r},{cancelable:!1})})}}return this},zoom:function(t){var e=1<arguments.length&&void 0!==arguments[1]&&arguments[1],i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,n=this.imageData;return t=Number(t),this.zoomTo(n.width*(t=t<0?1/(1-t):1+t)/n.naturalWidth,e,i),this},zoomTo:function(t){var l,c,i,u=this,d=1<arguments.length&&void 0!==arguments[1]&&arguments[1],e=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,n=3<arguments.length&&void 0!==arguments[3]&&arguments[3],o=this.element,s=this.options,a=this.pointers,r=this.imageData,m=r.x,g=r.y,f=r.width,v=r.height,p=r.naturalWidth,b=r.naturalHeight;if(x(t=Math.max(0,t))&&this.viewed&&!this.played&&(n||s.zoomable)){if(n||(n=Math.max(.01,s.minZoomRatio),w=Math.min(100,s.maxZoomRatio),t=Math.min(Math.max(t,n),w)),e)switch(e.type){case"wheel":.055<=s.zoomRatio&&.95<t&&t<1.05&&(t=1);break;case"pointermove":case"touchmove":case"mousemove":.99<t&&t<1.01&&(t=1)}var h,n=p*t,w=b*t,p=n-f,b=w-v,y=r.ratio;if(k(s.zoom)&&T(o,"zoom",s.zoom,{once:!0}),!1===D(o,"zoom",{ratio:t,oldRatio:y,originalEvent:e}))return this;this.zooming=!0,e?(h={left:(h=(h=this.viewer).getBoundingClientRect()).left+(window.pageXOffset-document.documentElement.clientLeft),top:h.top+(window.pageYOffset-document.documentElement.clientTop)},a=a&&0<Object.keys(a).length?(i=c=l=0,z(a,function(t){var e=t.startX,t=t.startY;l+=e,c+=t,i+=1}),{pageX:l/=i,pageY:c/=i}):{pageX:e.pageX,pageY:e.pageY},r.x-=(a.pageX-h.left-m)/f*p,r.y-=(a.pageY-h.top-g)/v*b):(r.x-=p/2,r.y-=b/2),r.left=r.x,r.top=r.y,r.width=n,r.height=w,r.oldRatio=y,r.ratio=t,this.renderImage(function(){u.zooming=!1,k(s.zoomed)&&T(o,"zoomed",s.zoomed,{once:!0}),D(o,"zoomed",{ratio:t,oldRatio:y,originalEvent:e},{cancelable:!1})}),d&&this.tooltip()}return this},play:function(){var e=this,t=0<arguments.length&&void 0!==arguments[0]&&arguments[0];if(!this.isShown||this.played)return this;var i=this.element,o=this.options;if(k(o.play)&&T(i,"play",o.play,{once:!0}),!1===D(i,"play"))return this;var s=this.player,a=this.loadImage.bind(this),r=[],h=0,l=0;return this.played=!0,this.onLoadWhenPlay=a,t&&this.requestFullscreen(t),f(s,X),z(this.items,function(t,e){var i=t.querySelector("img"),n=document.createElement("img");n.src=pt(i,"originalUrl"),n.alt=i.getAttribute("alt"),n.referrerPolicy=i.referrerPolicy,h+=1,f(n,y),gt(n,u,o.transition),mt(t,b)&&(f(n,L),l=e),r.push(n),T(n,H,a,{once:!0}),s.appendChild(n)}),x(o.interval)&&0<o.interval&&1<h&&function t(){e.playing=setTimeout(function(){v(r[l],L),f(r[l=(l+=1)<h?l:0],L),t()},o.interval)}(),this},stop:function(){var e=this;if(!this.played)return this;var t=this.element,i=this.options;if(k(i.stop)&&T(t,"stop",i.stop,{once:!0}),!1===D(t,"stop"))return this;i=this.player;return this.played=!1,clearTimeout(this.playing),z(i.getElementsByTagName("img"),function(t){p(t,H,e.onLoadWhenPlay)}),v(i,X),i.innerHTML="",this.exitFullscreen(),this},full:function(){var t=this,e=this.options,i=this.viewer,n=this.image,o=this.list;return!this.isShown||this.played||this.fulled||!e.inline||(this.fulled=!0,this.open(),f(this.button,h),e.transition&&(v(o,u),this.viewed&&v(n,u)),f(i,E),i.setAttribute("role","dialog"),i.setAttribute("aria-labelledby",this.title.id),i.setAttribute("aria-modal",!0),i.removeAttribute("style"),dt(i,{zIndex:e.zIndex}),e.focus&&this.enforceFocus(),this.initContainer(),this.viewerData=ct({},this.containerData),this.renderList(),this.viewed&&this.initImage(function(){t.renderImage(function(){e.transition&&setTimeout(function(){f(n,u),f(o,u)},0)})})),this},exit:function(){var t=this,e=this.options,i=this.viewer,n=this.image,o=this.list;return this.isShown&&!this.played&&this.fulled&&e.inline&&(this.fulled=!1,this.close(),v(this.button,h),e.transition&&(v(o,u),this.viewed&&v(n,u)),e.focus&&this.clearEnforceFocus(),i.removeAttribute("role"),i.removeAttribute("aria-labelledby"),i.removeAttribute("aria-modal"),v(i,E),dt(i,{zIndex:e.zIndexInline}),this.viewerData=ct({},this.parentData),this.renderViewer(),this.renderList(),this.viewed&&this.initImage(function(){t.renderImage(function(){e.transition&&setTimeout(function(){f(n,u),f(o,u)},0)})})),this},tooltip:function(){var t=this,e=this.options,i=this.tooltipBox,n=this.imageData;return this.viewed&&!this.played&&e.tooltip&&(i.textContent="".concat(Math.round(100*n.ratio),"%"),this.tooltipping?clearTimeout(this.tooltipping):e.transition?(this.fading&&D(i,$),f(i,X),f(i,y),f(i,u),i.removeAttribute("aria-hidden"),i.initialOffsetWidth=i.offsetWidth,f(i,L)):(f(i,X),i.removeAttribute("aria-hidden")),this.tooltipping=setTimeout(function(){e.transition?(T(i,$,function(){v(i,X),v(i,y),v(i,u),i.setAttribute("aria-hidden",!0),t.fading=!1},{once:!0}),v(i,L),t.fading=!0):(v(i,X),i.setAttribute("aria-hidden",!0)),t.tooltipping=!1},1e3)),this},toggle:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;return 1===this.imageData.ratio?this.zoomTo(this.imageData.oldRatio,!0,t):this.zoomTo(1,!0,t),this},reset:function(){return this.viewed&&!this.played&&(this.imageData=ct({},this.initialImageData),this.renderImage()),this},update:function(){var e=this,t=this.element,i=this.options,n=this.isImg;if(n&&!t.parentNode)return this.destroy();var o,s=[];return z(n?[t]:t.querySelectorAll("img"),function(t){k(i.filter)?i.filter.call(e,t)&&s.push(t):e.getImageURL(t)&&s.push(t)}),s.length&&(this.images=s,this.length=s.length,this.ready?(o=[],z(this.items,function(t,e){var t=t.querySelector("img"),i=s[e];i&&t&&i.src===t.src&&i.alt===t.alt||o.push(e)}),dt(this.list,{width:"auto"}),this.initList(),this.isShown&&(this.length?this.viewed&&(0<=(n=o.indexOf(this.index))?(this.viewed=!1,this.view(Math.max(Math.min(this.index-n,this.length-1),0))):(f(t=this.items[this.index],b),t.setAttribute("aria-selected",!0))):(this.image=null,this.viewed=!1,this.index=0,this.imageData={},this.canvas.innerHTML="",this.title.innerHTML=""))):this.build()),this},destroy:function(){var t=this.element,e=this.options;return t[g]&&(this.destroyed=!0,this.ready?(this.played&&this.stop(),e.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)):e.inline&&(this.delaying?this.delaying.abort():this.initializing&&this.initializing.abort()),e.inline||p(t,M,this.onStart),t[g]=void 0),this}},Ot={getImageURL:function(t){var e=this.options.url;return e=ot(e)?t.getAttribute(e):k(e)?e.call(this,t):""},enforceFocus:function(){var i=this;this.clearEnforceFocus(),T(document,W,this.onFocusin=function(t){var e=i.viewer,t=t.target;t===document||t===e||e.contains(t)||null!==t.getAttribute("tabindex")&&"true"===t.getAttribute("aria-modal")||e.focus()})},clearEnforceFocus:function(){this.onFocusin&&(p(document,W,this.onFocusin),this.onFocusin=null)},open:function(){var t=this.body;f(t,Y),t.style.paddingRight="".concat(this.scrollbarWidth+(parseFloat(this.initialBodyComputedPaddingRight)||0),"px")},close:function(){var t=this.body;v(t,Y),t.style.paddingRight=this.initialBodyPaddingRight},shown:function(){var t=this.element,e=this.options,i=this.viewer;this.fulled=!0,this.isShown=!0,this.render(),this.bind(),this.showing=!1,e.focus&&(i.focus(),this.enforceFocus()),k(e.shown)&&T(t,"shown",e.shown,{once:!0}),!1!==D(t,"shown")&&this.ready&&this.isShown&&!this.hiding&&this.view(this.index)},hidden:function(){var t=this.element,e=this.options,i=this.viewer;e.fucus&&this.clearEnforceFocus(),this.fulled=!1,this.viewed=!1,this.isShown=!1,this.close(),this.unbind(),f(i,A),i.removeAttribute("role"),i.removeAttribute("aria-labelledby"),i.removeAttribute("aria-modal"),i.setAttribute("aria-hidden",!0),this.resetList(),this.resetImage(),this.hiding=!1,this.destroyed||(k(e.hidden)&&T(t,"hidden",e.hidden,{once:!0}),D(t,"hidden",null,{cancelable:!1}))},requestFullscreen:function(t){var e=this.element.ownerDocument;this.fulled&&!(e.fullscreenElement||e.webkitFullscreenElement||e.mozFullScreenElement||e.msFullscreenElement)&&((e=e.documentElement).requestFullscreen?lt(t)?e.requestFullscreen(t):e.requestFullscreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT):e.mozRequestFullScreen?e.mozRequestFullScreen():e.msRequestFullscreen&&e.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 e=this.options,i=this.pointers,n=i[Object.keys(i)[0]];if(n){var s,a,o=n.endX-n.startX,r=n.endY-n.startY;switch(this.action){case c:this.move(o,r,t);break;case m:this.zoom((s=l({},h=i),a=[],z(h,function(o,t){delete s[t],z(s,function(t){var e=Math.abs(o.startX-t.startX),i=Math.abs(o.startY-t.startY),n=Math.abs(o.endX-t.endX),t=Math.abs(o.endY-t.endY),e=Math.sqrt(e*e+i*i),i=Math.sqrt(n*n+t*t);a.push((i-e)/e)})}),a.sort(function(t,e){return Math.abs(t)<Math.abs(e)}),a[0]),!1,t);break;case d:this.action="switched";var h=Math.abs(o);1<h&&h>Math.abs(r)&&(this.pointers={},1<o?this.prev(e.loop):o<-1&&this.next(e.loop))}z(i,function(t){t.startX=t.endX,t.startY=t.endY})}},isSwitchable:function(){var t=this.imageData,e=this.viewerData;return 1<this.length&&0<=t.x&&0<=t.y&&t.width<=e.width&&t.height<=e.height}},Ct=o.Viewer,Lt=(It=-1,function(){return It+=1}),o=function(){function o(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},i=this,n=o;if(!(i instanceof n))throw new TypeError("Cannot call a class as a function");if(!t||1!==t.nodeType)throw new Error("The first argument is required and must be an element.");this.element=t,this.options=ct({},s,lt(e)&&e),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.moving=!1,this.played=!1,this.playing=!1,this.pointers={},this.ready=!1,this.rotating=!1,this.scaling=!1,this.showing=!1,this.timeout=!1,this.tooltipping=!1,this.viewed=!1,this.viewing=!1,this.wheeling=!1,this.zooming=!1,this.id=Lt(),this.init()}var t,e,i;return t=o,i=[{key:"noConflict",value:function(){return window.Viewer=Ct,o}},{key:"setDefaults",value:function(t){ct(s,lt(t)&&t)}}],(e=[{key:"init",value:function(){var t,e,i,n,o=this,s=this.element,a=this.options;s[g]||(s[g]=this,a.focus&&!a.keyboard&&(a.focus=!1),t="img"===s.localName,e=[],z(t?[s]:s.querySelectorAll("img"),function(t){k(a.filter)?a.filter.call(o,t)&&e.push(t):o.getImageURL(t)&&e.push(t)}),this.isImg=t,this.length=e.length,this.images=e,this.initBody(),at(document.createElement(g).style.transition)&&(a.transition=!1),a.inline?(i=0,n=function(){var t;(i+=1)===o.length&&(o.initializing=!1,o.delaying={abort:function(){clearTimeout(t)}},t=setTimeout(function(){o.delaying=!1,o.build()},0))},this.initializing={abort:function(){z(e,function(t){t.complete||p(t,H,n)})}},z(e,function(t){t.complete?n():T(t,H,n,{once:!0})})):T(s,M,this.onStart=function(t){t=t.target;"img"!==t.localName||k(a.filter)&&!a.filter.call(o,t)||o.view(o.images.indexOf(t))}))}},{key:"build",value:function(){var t,s,e,i,n,o,a,c,r,u,d,m,h,l;this.ready||(t=this.element,s=this.options,e=t.parentNode,(h=document.createElement("div")).innerHTML='<div class="viewer-container" tabindex="-1" 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" role="navigation"></ul></div></div><div class="viewer-tooltip" role="alert" aria-hidden="true"></div><div class="viewer-button" data-viewer-action="mix" role="button"></div><div class="viewer-player"></div></div>',h=(i=h.querySelector(".".concat(g,"-container"))).querySelector(".".concat(g,"-title")),n=i.querySelector(".".concat(g,"-toolbar")),l=i.querySelector(".".concat(g,"-navbar")),o=i.querySelector(".".concat(g,"-button")),a=i.querySelector(".".concat(g,"-canvas")),this.parent=e,this.viewer=i,this.title=h,this.toolbar=n,this.navbar=l,this.button=o,this.canvas=a,this.footer=i.querySelector(".".concat(g,"-footer")),this.tooltipBox=i.querySelector(".".concat(g,"-tooltip")),this.player=i.querySelector(".".concat(g,"-player")),this.list=i.querySelector(".".concat(g,"-list")),i.id="".concat(g).concat(this.id),h.id="".concat(g,"Title").concat(this.id),f(h,s.title?Dt(Array.isArray(s.title)?s.title[0]:s.title):A),f(l,s.navbar?Dt(s.navbar):A),gt(o,A,!s.button),s.keyboard&&o.setAttribute("tabindex",0),s.backdrop&&(f(i,"".concat(g,"-backdrop")),s.inline||"static"===s.backdrop||bt(a,et,"hide")),ot(s.className)&&s.className&&s.className.split(it).forEach(function(t){f(i,t)}),s.toolbar?(c=document.createElement("ul"),r=lt(s.toolbar),u=nt.slice(0,3),d=nt.slice(7,9),m=nt.slice(9),r||f(n,Dt(s.toolbar)),z(r?s.toolbar:nt,function(t,e){var i,n=r&<(t),e=r?vt(e):t,o=n&&!at(t.show)?t.show:t;!o||!s.zoomable&&-1!==u.indexOf(e)||!s.rotatable&&-1!==d.indexOf(e)||!s.scalable&&-1!==m.indexOf(e)||(i=n&&!at(t.size)?t.size:t,n=n&&!at(t.click)?t.click:t,t=document.createElement("li"),s.keyboard&&t.setAttribute("tabindex",0),t.setAttribute("role","button"),f(t,"".concat(g,"-").concat(e)),k(n)||bt(t,et,e),x(o)&&f(t,Dt(o)),-1!==["small","large"].indexOf(i)?f(t,"".concat(g,"-").concat(i)):"play"===e&&f(t,"".concat(g,"-large")),k(n)&&T(t,M,n),c.appendChild(t))}),n.appendChild(c)):f(n,A),s.rotatable||(f(h=n.querySelectorAll('li[class*="rotate"]'),R),z(h,function(t){n.appendChild(t)})),s.inline?(f(o,I),dt(i,{zIndex:s.zIndexInline}),"static"===window.getComputedStyle(e).position&&dt(e,{position:"relative"}),e.insertBefore(i,t.nextSibling)):(f(o,w),f(i,E),f(i,y),f(i,A),dt(i,{zIndex:s.zIndex}),(l=(l=ot(l=s.container)?t.ownerDocument.querySelector(l):l)||this.body).appendChild(i)),s.inline&&(this.render(),this.bind(),this.isShown=!0),this.ready=!0,k(s.ready)&&T(t,G,s.ready,{once:!0}),!1!==D(t,G)?this.ready&&s.inline&&this.view(this.index):this.ready=!1)}}])&&n(t.prototype,e),i&&n(t,i),Object.defineProperty(t,"prototype",{writable:!1}),o}();return ct(o.prototype,r,t,At,St,Ot),o}); |
{ | ||
"name": "viewerjs", | ||
"description": "JavaScript image viewer.", | ||
"version": "1.10.2", | ||
"version": "1.10.3", | ||
"main": "dist/viewer.common.js", | ||
@@ -25,4 +25,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 **/*.{css,scss} --fix", | ||
"lint:js": "eslint . --fix", | ||
"prepare": "husky install", | ||
@@ -61,9 +61,9 @@ "release": "npm run clean && npm run lint && npm run build && npm run compress && npm run copy && npm test", | ||
"devDependencies": { | ||
"@babel/core": "^7.15.8", | ||
"@babel/preset-env": "^7.15.8", | ||
"@commitlint/cli": "^13.2.1", | ||
"@commitlint/config-conventional": "^13.2.0", | ||
"@babel/core": "^7.16.12", | ||
"@babel/preset-env": "^7.16.11", | ||
"@commitlint/cli": "^16.1.0", | ||
"@commitlint/config-conventional": "^16.0.0", | ||
"@rollup/plugin-babel": "^5.3.0", | ||
"babel-plugin-istanbul": "^6.1.1", | ||
"chai": "^4.3.4", | ||
"chai": "^4.3.6", | ||
"change-case": "^4.1.2", | ||
@@ -73,9 +73,9 @@ "codecov": "^3.8.3", | ||
"create-banner": "^2.0.0", | ||
"cssnano": "^5.0.8", | ||
"cssnano": "^5.0.16", | ||
"del-cli": "^4.0.1", | ||
"eslint": "^7.32.0", | ||
"eslint-config-airbnb-base": "^14.2.1", | ||
"eslint-plugin-import": "^2.25.2", | ||
"eslint": "^8.8.0", | ||
"eslint-config-airbnb-base": "^15.0.0", | ||
"eslint-plugin-import": "^2.25.4", | ||
"husky": "^7.0.4", | ||
"karma": "^6.3.5", | ||
"karma": "^6.3.13", | ||
"karma-chai": "^0.1.0", | ||
@@ -87,32 +87,18 @@ "karma-chrome-launcher": "^3.1.0", | ||
"karma-rollup-preprocessor": "^7.0.7", | ||
"lint-staged": "^11.2.3", | ||
"mocha": "^9.1.3", | ||
"lint-staged": "^12.3.3", | ||
"mocha": "^9.2.0", | ||
"npm-run-all": "^4.1.5", | ||
"postcss": "^8.3.11", | ||
"postcss-cli": "^8.3.1", | ||
"postcss": "^8.4.6", | ||
"postcss-cli": "^9.1.0", | ||
"postcss-header": "^3.0.1", | ||
"postcss-import": "^14.0.2", | ||
"postcss-preset-env": "^6.7.0", | ||
"postcss-preset-env": "^7.3.0", | ||
"postcss-url": "^10.1.3", | ||
"puppeteer": "^10.4.0", | ||
"rollup": "^2.58.0", | ||
"stylelint": "^13.13.1", | ||
"stylelint-config-standard": "^22.0.0", | ||
"stylelint-order": "^4.1.0", | ||
"uglify-js": "^3.14.2" | ||
}, | ||
"browserslist": [ | ||
"last 2 versions", | ||
"> 1%", | ||
"not ie <= 8" | ||
], | ||
"commitlint": { | ||
"extends": [ | ||
"@commitlint/config-conventional" | ||
] | ||
}, | ||
"lint-staged": { | ||
"{src,test}/**/*.js|*.conf*.js": "eslint --fix", | ||
"{src,docs}/**/*.{css,scss,html}": "stylelint --fix" | ||
"puppeteer": "^13.1.3", | ||
"rollup": "^2.66.1", | ||
"stylelint": "^14.3.0", | ||
"stylelint-config-standard-scss": "^3.0.0", | ||
"stylelint-order": "^5.0.0", | ||
"uglify-js": "^3.15.0" | ||
} | ||
} |
# Viewer.js | ||
[![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) [![Gzip Size](https://img.shields.io/bundlephobia/minzip/viewerjs.svg)](https://unpkg.com/viewerjs/dist/viewer.common.js) [![Dependencies](https://img.shields.io/david/fengyuanchen/viewerjs.svg)](https://www.npmjs.com/package/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) [![Gzip Size](https://img.shields.io/bundlephobia/minzip/viewerjs.svg)](https://unpkg.com/viewerjs/dist/viewer.common.js) | ||
@@ -39,3 +39,3 @@ > JavaScript image viewer. | ||
## Main | ||
## Main files | ||
@@ -210,4 +210,4 @@ ```text | ||
- `{ key: { show: Boolean | Number, size: String, click: Function }`: customize each property of the button. | ||
- Available keys: "zoomIn", "zoomOut", "oneToOne", "reset", "prev", "play", "next", "rotateLeft", "rotateRight", "flipHorizontal" and "flipVertical". | ||
- Available sizes: "small", "medium" (default) and "large". | ||
- Available built-in keys: "zoomIn", "zoomOut", "oneToOne", "reset", "prev", "play", "next", "rotateLeft", "rotateRight", "flipHorizontal", "flipVertical". | ||
- Available built-in sizes: "small", "medium" (default) and "large". | ||
@@ -239,2 +239,4 @@ Specify the visibility and layout of the toolbar its buttons. | ||
> see more for [custom toolbar](docs/examples/custom-toolbar.html). | ||
### className | ||
@@ -241,0 +243,0 @@ |
@@ -133,3 +133,4 @@ import { | ||
this.toggle(event); | ||
// XXX: No pageX/Y properties in custom event, fallback to the original event. | ||
this.toggle(event.isTrusted ? event : (event.detail && event.detail.originalEvent)); | ||
} | ||
@@ -440,3 +441,5 @@ }, | ||
this.doubleClickImageTimeout = setTimeout(() => { | ||
dispatchEvent(this.image, EVENT_DBLCLICK); | ||
dispatchEvent(this.image, EVENT_DBLCLICK, { | ||
originalEvent: event, | ||
}); | ||
}, 50); | ||
@@ -457,3 +460,5 @@ } else { | ||
this.clickCanvasTimeout = setTimeout(() => { | ||
dispatchEvent(this.canvas, EVENT_CLICK); | ||
dispatchEvent(this.canvas, EVENT_CLICK, { | ||
originalEvent: event, | ||
}); | ||
}, 50); | ||
@@ -460,0 +465,0 @@ } |
@@ -720,4 +720,20 @@ import { | ||
if (_originalEvent && options.zoomRatio >= 0.055 && ratio > 0.95 && ratio < 1.05) { | ||
ratio = 1; | ||
if (_originalEvent) { | ||
switch (_originalEvent.type) { | ||
case 'wheel': | ||
if (options.zoomRatio >= 0.055 && ratio > 0.95 && ratio < 1.05) { | ||
ratio = 1; | ||
} | ||
break; | ||
case 'pointermove': | ||
case 'touchmove': | ||
case 'mousemove': | ||
if (ratio > 0.99 && ratio < 1.01) { | ||
ratio = 1; | ||
} | ||
break; | ||
default: | ||
} | ||
} | ||
@@ -749,6 +765,8 @@ | ||
const offset = getOffset(this.viewer); | ||
const center = pointers && Object.keys(pointers).length ? getPointersCenter(pointers) : { | ||
pageX: _originalEvent.pageX, | ||
pageY: _originalEvent.pageY, | ||
}; | ||
const center = pointers && Object.keys(pointers).length > 0 | ||
? getPointersCenter(pointers) | ||
: { | ||
pageX: _originalEvent.pageX, | ||
pageY: _originalEvent.pageY, | ||
}; | ||
@@ -755,0 +773,0 @@ // Zoom from the triggering point of the event |
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
Sorry, the diff of this file is not supported yet
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
13240
1143
548057
27