boka-human-cliend-v2 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/boka-human-v2.common.js +3459 -18
- package/dist/boka-human-v2.css +9 -1
- package/dist/boka-human-v2.umd.js +3459 -18
- package/dist/boka-human-v2.umd.min.js +11 -1
- package/package.json +5 -1
- package/src/BokaHumanV2.vue +209 -7
- package/src/demo/App.vue +27 -0
- package/src/demo/main.js +7 -0
- package/vue.config.js +3 -2
|
@@ -96,15 +96,3304 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
96
96
|
/************************************************************************/
|
|
97
97
|
/******/ ({
|
|
98
98
|
|
|
99
|
-
/***/ "
|
|
99
|
+
/***/ "0808":
|
|
100
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
101
|
+
|
|
102
|
+
// extracted by mini-css-extract-plugin
|
|
103
|
+
|
|
104
|
+
/***/ }),
|
|
105
|
+
|
|
106
|
+
/***/ "5014":
|
|
107
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
108
|
+
|
|
109
|
+
/* WEBPACK VAR INJECTION */(function(module) {/* interact.js 1.10.27 | https://raw.github.com/taye/interact.js/main/LICENSE */
|
|
110
|
+
|
|
111
|
+
!function(t,e){ true?module.exports=e():undefined}(this,(function(){"use strict";function t(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function e(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?t(Object(r),!0).forEach((function(t){a(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):t(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function n(t){return n="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},n(t)}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,d(r.key),r)}}function o(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function a(t,e,n){return(e=d(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&l(t,e)}function c(t){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},c(t)}function l(t,e){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},l(t,e)}function u(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function p(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=c(t);if(e){var i=c(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return u(t)}(this,n)}}function f(){return f="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=c(t)););return t}(t,e);if(r){var i=Object.getOwnPropertyDescriptor(r,e);return i.get?i.get.call(arguments.length<3?t:n):i.value}},f.apply(this,arguments)}function d(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}var h=function(t){return!(!t||!t.Window)&&t instanceof t.Window},v=void 0,g=void 0;function m(t){v=t;var e=t.document.createTextNode("");e.ownerDocument!==t.document&&"function"==typeof t.wrap&&t.wrap(e)===e&&(t=t.wrap(t)),g=t}function y(t){return h(t)?t:(t.ownerDocument||t).defaultView||g.window}"undefined"!=typeof window&&window&&m(window);var b=function(t){return!!t&&"object"===n(t)},x=function(t){return"function"==typeof t},w={window:function(t){return t===g||h(t)},docFrag:function(t){return b(t)&&11===t.nodeType},object:b,func:x,number:function(t){return"number"==typeof t},bool:function(t){return"boolean"==typeof t},string:function(t){return"string"==typeof t},element:function(t){if(!t||"object"!==n(t))return!1;var e=y(t)||g;return/object|function/.test("undefined"==typeof Element?"undefined":n(Element))?t instanceof Element||t instanceof e.Element:1===t.nodeType&&"string"==typeof t.nodeName},plainObject:function(t){return b(t)&&!!t.constructor&&/function Object\b/.test(t.constructor.toString())},array:function(t){return b(t)&&void 0!==t.length&&x(t.splice)}};function E(t){var e=t.interaction;if("drag"===e.prepared.name){var n=e.prepared.axis;"x"===n?(e.coords.cur.page.y=e.coords.start.page.y,e.coords.cur.client.y=e.coords.start.client.y,e.coords.velocity.client.y=0,e.coords.velocity.page.y=0):"y"===n&&(e.coords.cur.page.x=e.coords.start.page.x,e.coords.cur.client.x=e.coords.start.client.x,e.coords.velocity.client.x=0,e.coords.velocity.page.x=0)}}function T(t){var e=t.iEvent,n=t.interaction;if("drag"===n.prepared.name){var r=n.prepared.axis;if("x"===r||"y"===r){var i="x"===r?"y":"x";e.page[i]=n.coords.start.page[i],e.client[i]=n.coords.start.client[i],e.delta[i]=0}}}var S={id:"actions/drag",install:function(t){var e=t.actions,n=t.Interactable,r=t.defaults;n.prototype.draggable=S.draggable,e.map.drag=S,e.methodDict.drag="draggable",r.actions.drag=S.defaults},listeners:{"interactions:before-action-move":E,"interactions:action-resume":E,"interactions:action-move":T,"auto-start:check":function(t){var e=t.interaction,n=t.interactable,r=t.buttons,i=n.options.drag;if(i&&i.enabled&&(!e.pointerIsDown||!/mouse|pointer/.test(e.pointerType)||0!=(r&n.options.drag.mouseButtons)))return t.action={name:"drag",axis:"start"===i.lockAxis?i.startAxis:i.lockAxis},!1}},draggable:function(t){return w.object(t)?(this.options.drag.enabled=!1!==t.enabled,this.setPerAction("drag",t),this.setOnEvents("drag",t),/^(xy|x|y|start)$/.test(t.lockAxis)&&(this.options.drag.lockAxis=t.lockAxis),/^(xy|x|y)$/.test(t.startAxis)&&(this.options.drag.startAxis=t.startAxis),this):w.bool(t)?(this.options.drag.enabled=t,this):this.options.drag},beforeMove:E,move:T,defaults:{startAxis:"xy",lockAxis:"xy"},getCursor:function(){return"move"},filterEventType:function(t){return 0===t.search("drag")}},_=S,P={init:function(t){var e=t;P.document=e.document,P.DocumentFragment=e.DocumentFragment||O,P.SVGElement=e.SVGElement||O,P.SVGSVGElement=e.SVGSVGElement||O,P.SVGElementInstance=e.SVGElementInstance||O,P.Element=e.Element||O,P.HTMLElement=e.HTMLElement||P.Element,P.Event=e.Event,P.Touch=e.Touch||O,P.PointerEvent=e.PointerEvent||e.MSPointerEvent},document:null,DocumentFragment:null,SVGElement:null,SVGSVGElement:null,SVGElementInstance:null,Element:null,HTMLElement:null,Event:null,Touch:null,PointerEvent:null};function O(){}var k=P;var D={init:function(t){var e=k.Element,n=t.navigator||{};D.supportsTouch="ontouchstart"in t||w.func(t.DocumentTouch)&&k.document instanceof t.DocumentTouch,D.supportsPointerEvent=!1!==n.pointerEnabled&&!!k.PointerEvent,D.isIOS=/iP(hone|od|ad)/.test(n.platform),D.isIOS7=/iP(hone|od|ad)/.test(n.platform)&&/OS 7[^\d]/.test(n.appVersion),D.isIe9=/MSIE 9/.test(n.userAgent),D.isOperaMobile="Opera"===n.appName&&D.supportsTouch&&/Presto/.test(n.userAgent),D.prefixedMatchesSelector="matches"in e.prototype?"matches":"webkitMatchesSelector"in e.prototype?"webkitMatchesSelector":"mozMatchesSelector"in e.prototype?"mozMatchesSelector":"oMatchesSelector"in e.prototype?"oMatchesSelector":"msMatchesSelector",D.pEventTypes=D.supportsPointerEvent?k.PointerEvent===t.MSPointerEvent?{up:"MSPointerUp",down:"MSPointerDown",over:"mouseover",out:"mouseout",move:"MSPointerMove",cancel:"MSPointerCancel"}:{up:"pointerup",down:"pointerdown",over:"pointerover",out:"pointerout",move:"pointermove",cancel:"pointercancel"}:null,D.wheelEvent=k.document&&"onmousewheel"in k.document?"mousewheel":"wheel"},supportsTouch:null,supportsPointerEvent:null,isIOS7:null,isIOS:null,isIe9:null,isOperaMobile:null,prefixedMatchesSelector:null,pEventTypes:null,wheelEvent:null};var I=D;function M(t,e){if(t.contains)return t.contains(e);for(;e;){if(e===t)return!0;e=e.parentNode}return!1}function z(t,e){for(;w.element(t);){if(R(t,e))return t;t=A(t)}return null}function A(t){var e=t.parentNode;if(w.docFrag(e)){for(;(e=e.host)&&w.docFrag(e););return e}return e}function R(t,e){return g!==v&&(e=e.replace(/\/deep\//g," ")),t[I.prefixedMatchesSelector](e)}var C=function(t){return t.parentNode||t.host};function j(t,e){for(var n,r=[],i=t;(n=C(i))&&i!==e&&n!==i.ownerDocument;)r.unshift(i),i=n;return r}function F(t,e,n){for(;w.element(t);){if(R(t,e))return!0;if((t=A(t))===n)return R(t,e)}return!1}function X(t){return t.correspondingUseElement||t}function Y(t){var e=t instanceof k.SVGElement?t.getBoundingClientRect():t.getClientRects()[0];return e&&{left:e.left,right:e.right,top:e.top,bottom:e.bottom,width:e.width||e.right-e.left,height:e.height||e.bottom-e.top}}function L(t){var e,n=Y(t);if(!I.isIOS7&&n){var r={x:(e=(e=y(t))||g).scrollX||e.document.documentElement.scrollLeft,y:e.scrollY||e.document.documentElement.scrollTop};n.left+=r.x,n.right+=r.x,n.top+=r.y,n.bottom+=r.y}return n}function q(t){for(var e=[];t;)e.push(t),t=A(t);return e}function B(t){return!!w.string(t)&&(k.document.querySelector(t),!0)}function V(t,e){for(var n in e)t[n]=e[n];return t}function W(t,e,n){return"parent"===t?A(n):"self"===t?e.getRect(n):z(n,t)}function G(t,e,n,r){var i=t;return w.string(i)?i=W(i,e,n):w.func(i)&&(i=i.apply(void 0,r)),w.element(i)&&(i=L(i)),i}function N(t){return t&&{x:"x"in t?t.x:t.left,y:"y"in t?t.y:t.top}}function U(t){return!t||"x"in t&&"y"in t||((t=V({},t)).x=t.left||0,t.y=t.top||0,t.width=t.width||(t.right||0)-t.x,t.height=t.height||(t.bottom||0)-t.y),t}function H(t,e,n){t.left&&(e.left+=n.x),t.right&&(e.right+=n.x),t.top&&(e.top+=n.y),t.bottom&&(e.bottom+=n.y),e.width=e.right-e.left,e.height=e.bottom-e.top}function K(t,e,n){var r=n&&t.options[n];return N(G(r&&r.origin||t.options.origin,t,e,[t&&e]))||{x:0,y:0}}function $(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(t){return!0},r=arguments.length>3?arguments[3]:void 0;if(r=r||{},w.string(t)&&-1!==t.search(" ")&&(t=J(t)),w.array(t))return t.forEach((function(t){return $(t,e,n,r)})),r;if(w.object(t)&&(e=t,t=""),w.func(e)&&n(t))r[t]=r[t]||[],r[t].push(e);else if(w.array(e))for(var i=0,o=e;i<o.length;i++){var a=o[i];$(t,a,n,r)}else if(w.object(e))for(var s in e){$(J(s).map((function(e){return"".concat(t).concat(e)})),e[s],n,r)}return r}function J(t){return t.trim().split(/ +/)}var Q=function(t,e){return Math.sqrt(t*t+e*e)},Z=["webkit","moz"];function tt(t,e){t.__set||(t.__set={});var n=function(n){if(Z.some((function(t){return 0===n.indexOf(t)})))return 1;"function"!=typeof t[n]&&"__set"!==n&&Object.defineProperty(t,n,{get:function(){return n in t.__set?t.__set[n]:t.__set[n]=e[n]},set:function(e){t.__set[n]=e},configurable:!0})};for(var r in e)n(r);return t}function et(t,e){t.page=t.page||{},t.page.x=e.page.x,t.page.y=e.page.y,t.client=t.client||{},t.client.x=e.client.x,t.client.y=e.client.y,t.timeStamp=e.timeStamp}function nt(t){t.page.x=0,t.page.y=0,t.client.x=0,t.client.y=0}function rt(t){return t instanceof k.Event||t instanceof k.Touch}function it(t,e,n){return t=t||"page",(n=n||{}).x=e[t+"X"],n.y=e[t+"Y"],n}function ot(t,e){return e=e||{x:0,y:0},I.isOperaMobile&&rt(t)?(it("screen",t,e),e.x+=window.scrollX,e.y+=window.scrollY):it("page",t,e),e}function at(t){return w.number(t.pointerId)?t.pointerId:t.identifier}function st(t,e,n){var r=e.length>1?lt(e):e[0];ot(r,t.page),function(t,e){e=e||{},I.isOperaMobile&&rt(t)?it("screen",t,e):it("client",t,e)}(r,t.client),t.timeStamp=n}function ct(t){var e=[];return w.array(t)?(e[0]=t[0],e[1]=t[1]):"touchend"===t.type?1===t.touches.length?(e[0]=t.touches[0],e[1]=t.changedTouches[0]):0===t.touches.length&&(e[0]=t.changedTouches[0],e[1]=t.changedTouches[1]):(e[0]=t.touches[0],e[1]=t.touches[1]),e}function lt(t){for(var e={pageX:0,pageY:0,clientX:0,clientY:0,screenX:0,screenY:0},n=0;n<t.length;n++){var r=t[n];for(var i in e)e[i]+=r[i]}for(var o in e)e[o]/=t.length;return e}function ut(t){if(!t.length)return null;var e=ct(t),n=Math.min(e[0].pageX,e[1].pageX),r=Math.min(e[0].pageY,e[1].pageY),i=Math.max(e[0].pageX,e[1].pageX),o=Math.max(e[0].pageY,e[1].pageY);return{x:n,y:r,left:n,top:r,right:i,bottom:o,width:i-n,height:o-r}}function pt(t,e){var n=e+"X",r=e+"Y",i=ct(t),o=i[0][n]-i[1][n],a=i[0][r]-i[1][r];return Q(o,a)}function ft(t,e){var n=e+"X",r=e+"Y",i=ct(t),o=i[1][n]-i[0][n],a=i[1][r]-i[0][r];return 180*Math.atan2(a,o)/Math.PI}function dt(t){return w.string(t.pointerType)?t.pointerType:w.number(t.pointerType)?[void 0,void 0,"touch","pen","mouse"][t.pointerType]:/touch/.test(t.type||"")||t instanceof k.Touch?"touch":"mouse"}function ht(t){var e=w.func(t.composedPath)?t.composedPath():t.path;return[X(e?e[0]:t.target),X(t.currentTarget)]}var vt=function(){function t(e){r(this,t),this.immediatePropagationStopped=!1,this.propagationStopped=!1,this._interaction=e}return o(t,[{key:"preventDefault",value:function(){}},{key:"stopPropagation",value:function(){this.propagationStopped=!0}},{key:"stopImmediatePropagation",value:function(){this.immediatePropagationStopped=this.propagationStopped=!0}}]),t}();Object.defineProperty(vt.prototype,"interaction",{get:function(){return this._interaction._proxy},set:function(){}});var gt=function(t,e){for(var n=0;n<e.length;n++){var r=e[n];t.push(r)}return t},mt=function(t){return gt([],t)},yt=function(t,e){for(var n=0;n<t.length;n++)if(e(t[n],n,t))return n;return-1},bt=function(t,e){return t[yt(t,e)]},xt=function(t){s(n,t);var e=p(n);function n(t,i,o){var a;r(this,n),(a=e.call(this,i._interaction)).dropzone=void 0,a.dragEvent=void 0,a.relatedTarget=void 0,a.draggable=void 0,a.propagationStopped=!1,a.immediatePropagationStopped=!1;var s="dragleave"===o?t.prev:t.cur,c=s.element,l=s.dropzone;return a.type=o,a.target=c,a.currentTarget=c,a.dropzone=l,a.dragEvent=i,a.relatedTarget=i.target,a.draggable=i.interactable,a.timeStamp=i.timeStamp,a}return o(n,[{key:"reject",value:function(){var t=this,e=this._interaction.dropState;if("dropactivate"===this.type||this.dropzone&&e.cur.dropzone===this.dropzone&&e.cur.element===this.target)if(e.prev.dropzone=this.dropzone,e.prev.element=this.target,e.rejected=!0,e.events.enter=null,this.stopImmediatePropagation(),"dropactivate"===this.type){var r=e.activeDrops,i=yt(r,(function(e){var n=e.dropzone,r=e.element;return n===t.dropzone&&r===t.target}));e.activeDrops.splice(i,1);var o=new n(e,this.dragEvent,"dropdeactivate");o.dropzone=this.dropzone,o.target=this.target,this.dropzone.fire(o)}else this.dropzone.fire(new n(e,this.dragEvent,"dragleave"))}},{key:"preventDefault",value:function(){}},{key:"stopPropagation",value:function(){this.propagationStopped=!0}},{key:"stopImmediatePropagation",value:function(){this.immediatePropagationStopped=this.propagationStopped=!0}}]),n}(vt);function wt(t,e){for(var n=0,r=t.slice();n<r.length;n++){var i=r[n],o=i.dropzone,a=i.element;e.dropzone=o,e.target=a,o.fire(e),e.propagationStopped=e.immediatePropagationStopped=!1}}function Et(t,e){for(var n=function(t,e){for(var n=[],r=0,i=t.interactables.list;r<i.length;r++){var o=i[r];if(o.options.drop.enabled){var a=o.options.drop.accept;if(!(w.element(a)&&a!==e||w.string(a)&&!R(e,a)||w.func(a)&&!a({dropzone:o,draggableElement:e})))for(var s=0,c=o.getAllElements();s<c.length;s++){var l=c[s];l!==e&&n.push({dropzone:o,element:l,rect:o.getRect(l)})}}}return n}(t,e),r=0;r<n.length;r++){var i=n[r];i.rect=i.dropzone.getRect(i.element)}return n}function Tt(t,e,n){for(var r=t.dropState,i=t.interactable,o=t.element,a=[],s=0,c=r.activeDrops;s<c.length;s++){var l=c[s],u=l.dropzone,p=l.element,f=l.rect,d=u.dropCheck(e,n,i,o,p,f);a.push(d?p:null)}var h=function(t){for(var e,n,r,i=[],o=0;o<t.length;o++){var a=t[o],s=t[e];if(a&&o!==e)if(s){var c=C(a),l=C(s);if(c!==a.ownerDocument)if(l!==a.ownerDocument)if(c!==l){i=i.length?i:j(s);var u=void 0;if(s instanceof k.HTMLElement&&a instanceof k.SVGElement&&!(a instanceof k.SVGSVGElement)){if(a===l)continue;u=a.ownerSVGElement}else u=a;for(var p=j(u,s.ownerDocument),f=0;p[f]&&p[f]===i[f];)f++;var d=[p[f-1],p[f],i[f]];if(d[0])for(var h=d[0].lastChild;h;){if(h===d[1]){e=o,i=p;break}if(h===d[2])break;h=h.previousSibling}}else r=s,void 0,void 0,(parseInt(y(n=a).getComputedStyle(n).zIndex,10)||0)>=(parseInt(y(r).getComputedStyle(r).zIndex,10)||0)&&(e=o);else e=o}else e=o}return e}(a);return r.activeDrops[h]||null}function St(t,e,n){var r=t.dropState,i={enter:null,leave:null,activate:null,deactivate:null,move:null,drop:null};return"dragstart"===n.type&&(i.activate=new xt(r,n,"dropactivate"),i.activate.target=null,i.activate.dropzone=null),"dragend"===n.type&&(i.deactivate=new xt(r,n,"dropdeactivate"),i.deactivate.target=null,i.deactivate.dropzone=null),r.rejected||(r.cur.element!==r.prev.element&&(r.prev.dropzone&&(i.leave=new xt(r,n,"dragleave"),n.dragLeave=i.leave.target=r.prev.element,n.prevDropzone=i.leave.dropzone=r.prev.dropzone),r.cur.dropzone&&(i.enter=new xt(r,n,"dragenter"),n.dragEnter=r.cur.element,n.dropzone=r.cur.dropzone)),"dragend"===n.type&&r.cur.dropzone&&(i.drop=new xt(r,n,"drop"),n.dropzone=r.cur.dropzone,n.relatedTarget=r.cur.element),"dragmove"===n.type&&r.cur.dropzone&&(i.move=new xt(r,n,"dropmove"),n.dropzone=r.cur.dropzone)),i}function _t(t,e){var n=t.dropState,r=n.activeDrops,i=n.cur,o=n.prev;e.leave&&o.dropzone.fire(e.leave),e.enter&&i.dropzone.fire(e.enter),e.move&&i.dropzone.fire(e.move),e.drop&&i.dropzone.fire(e.drop),e.deactivate&&wt(r,e.deactivate),n.prev.dropzone=i.dropzone,n.prev.element=i.element}function Pt(t,e){var n=t.interaction,r=t.iEvent,i=t.event;if("dragmove"===r.type||"dragend"===r.type){var o=n.dropState;e.dynamicDrop&&(o.activeDrops=Et(e,n.element));var a=r,s=Tt(n,a,i);o.rejected=o.rejected&&!!s&&s.dropzone===o.cur.dropzone&&s.element===o.cur.element,o.cur.dropzone=s&&s.dropzone,o.cur.element=s&&s.element,o.events=St(n,0,a)}}var Ot={id:"actions/drop",install:function(t){var e=t.actions,n=t.interactStatic,r=t.Interactable,i=t.defaults;t.usePlugin(_),r.prototype.dropzone=function(t){return function(t,e){if(w.object(e)){if(t.options.drop.enabled=!1!==e.enabled,e.listeners){var n=$(e.listeners),r=Object.keys(n).reduce((function(t,e){return t[/^(enter|leave)/.test(e)?"drag".concat(e):/^(activate|deactivate|move)/.test(e)?"drop".concat(e):e]=n[e],t}),{}),i=t.options.drop.listeners;i&&t.off(i),t.on(r),t.options.drop.listeners=r}return w.func(e.ondrop)&&t.on("drop",e.ondrop),w.func(e.ondropactivate)&&t.on("dropactivate",e.ondropactivate),w.func(e.ondropdeactivate)&&t.on("dropdeactivate",e.ondropdeactivate),w.func(e.ondragenter)&&t.on("dragenter",e.ondragenter),w.func(e.ondragleave)&&t.on("dragleave",e.ondragleave),w.func(e.ondropmove)&&t.on("dropmove",e.ondropmove),/^(pointer|center)$/.test(e.overlap)?t.options.drop.overlap=e.overlap:w.number(e.overlap)&&(t.options.drop.overlap=Math.max(Math.min(1,e.overlap),0)),"accept"in e&&(t.options.drop.accept=e.accept),"checker"in e&&(t.options.drop.checker=e.checker),t}if(w.bool(e))return t.options.drop.enabled=e,t;return t.options.drop}(this,t)},r.prototype.dropCheck=function(t,e,n,r,i,o){return function(t,e,n,r,i,o,a){var s=!1;if(!(a=a||t.getRect(o)))return!!t.options.drop.checker&&t.options.drop.checker(e,n,s,t,o,r,i);var c=t.options.drop.overlap;if("pointer"===c){var l=K(r,i,"drag"),u=ot(e);u.x+=l.x,u.y+=l.y;var p=u.x>a.left&&u.x<a.right,f=u.y>a.top&&u.y<a.bottom;s=p&&f}var d=r.getRect(i);if(d&&"center"===c){var h=d.left+d.width/2,v=d.top+d.height/2;s=h>=a.left&&h<=a.right&&v>=a.top&&v<=a.bottom}if(d&&w.number(c)){s=Math.max(0,Math.min(a.right,d.right)-Math.max(a.left,d.left))*Math.max(0,Math.min(a.bottom,d.bottom)-Math.max(a.top,d.top))/(d.width*d.height)>=c}t.options.drop.checker&&(s=t.options.drop.checker(e,n,s,t,o,r,i));return s}(this,t,e,n,r,i,o)},n.dynamicDrop=function(e){return w.bool(e)?(t.dynamicDrop=e,n):t.dynamicDrop},V(e.phaselessTypes,{dragenter:!0,dragleave:!0,dropactivate:!0,dropdeactivate:!0,dropmove:!0,drop:!0}),e.methodDict.drop="dropzone",t.dynamicDrop=!1,i.actions.drop=Ot.defaults},listeners:{"interactions:before-action-start":function(t){var e=t.interaction;"drag"===e.prepared.name&&(e.dropState={cur:{dropzone:null,element:null},prev:{dropzone:null,element:null},rejected:null,events:null,activeDrops:[]})},"interactions:after-action-start":function(t,e){var n=t.interaction,r=(t.event,t.iEvent);if("drag"===n.prepared.name){var i=n.dropState;i.activeDrops=[],i.events={},i.activeDrops=Et(e,n.element),i.events=St(n,0,r),i.events.activate&&(wt(i.activeDrops,i.events.activate),e.fire("actions/drop:start",{interaction:n,dragEvent:r}))}},"interactions:action-move":Pt,"interactions:after-action-move":function(t,e){var n=t.interaction,r=t.iEvent;if("drag"===n.prepared.name){var i=n.dropState;_t(n,i.events),e.fire("actions/drop:move",{interaction:n,dragEvent:r}),i.events={}}},"interactions:action-end":function(t,e){if("drag"===t.interaction.prepared.name){var n=t.interaction,r=t.iEvent;Pt(t,e),_t(n,n.dropState.events),e.fire("actions/drop:end",{interaction:n,dragEvent:r})}},"interactions:stop":function(t){var e=t.interaction;if("drag"===e.prepared.name){var n=e.dropState;n&&(n.activeDrops=null,n.events=null,n.cur.dropzone=null,n.cur.element=null,n.prev.dropzone=null,n.prev.element=null,n.rejected=!1)}}},getActiveDrops:Et,getDrop:Tt,getDropEvents:St,fireDropEvents:_t,filterEventType:function(t){return 0===t.search("drag")||0===t.search("drop")},defaults:{enabled:!1,accept:null,overlap:"pointer"}},kt=Ot;function Dt(t){var e=t.interaction,n=t.iEvent,r=t.phase;if("gesture"===e.prepared.name){var i=e.pointers.map((function(t){return t.pointer})),o="start"===r,a="end"===r,s=e.interactable.options.deltaSource;if(n.touches=[i[0],i[1]],o)n.distance=pt(i,s),n.box=ut(i),n.scale=1,n.ds=0,n.angle=ft(i,s),n.da=0,e.gesture.startDistance=n.distance,e.gesture.startAngle=n.angle;else if(a||e.pointers.length<2){var c=e.prevEvent;n.distance=c.distance,n.box=c.box,n.scale=c.scale,n.ds=0,n.angle=c.angle,n.da=0}else n.distance=pt(i,s),n.box=ut(i),n.scale=n.distance/e.gesture.startDistance,n.angle=ft(i,s),n.ds=n.scale-e.gesture.scale,n.da=n.angle-e.gesture.angle;e.gesture.distance=n.distance,e.gesture.angle=n.angle,w.number(n.scale)&&n.scale!==1/0&&!isNaN(n.scale)&&(e.gesture.scale=n.scale)}}var It={id:"actions/gesture",before:["actions/drag","actions/resize"],install:function(t){var e=t.actions,n=t.Interactable,r=t.defaults;n.prototype.gesturable=function(t){return w.object(t)?(this.options.gesture.enabled=!1!==t.enabled,this.setPerAction("gesture",t),this.setOnEvents("gesture",t),this):w.bool(t)?(this.options.gesture.enabled=t,this):this.options.gesture},e.map.gesture=It,e.methodDict.gesture="gesturable",r.actions.gesture=It.defaults},listeners:{"interactions:action-start":Dt,"interactions:action-move":Dt,"interactions:action-end":Dt,"interactions:new":function(t){t.interaction.gesture={angle:0,distance:0,scale:1,startAngle:0,startDistance:0}},"auto-start:check":function(t){if(!(t.interaction.pointers.length<2)){var e=t.interactable.options.gesture;if(e&&e.enabled)return t.action={name:"gesture"},!1}}},defaults:{},getCursor:function(){return""},filterEventType:function(t){return 0===t.search("gesture")}},Mt=It;function zt(t,e,n,r,i,o,a){if(!e)return!1;if(!0===e){var s=w.number(o.width)?o.width:o.right-o.left,c=w.number(o.height)?o.height:o.bottom-o.top;if(a=Math.min(a,Math.abs(("left"===t||"right"===t?s:c)/2)),s<0&&("left"===t?t="right":"right"===t&&(t="left")),c<0&&("top"===t?t="bottom":"bottom"===t&&(t="top")),"left"===t){var l=s>=0?o.left:o.right;return n.x<l+a}if("top"===t){var u=c>=0?o.top:o.bottom;return n.y<u+a}if("right"===t)return n.x>(s>=0?o.right:o.left)-a;if("bottom"===t)return n.y>(c>=0?o.bottom:o.top)-a}return!!w.element(r)&&(w.element(e)?e===r:F(r,e,i))}function At(t){var e=t.iEvent,n=t.interaction;if("resize"===n.prepared.name&&n.resizeAxes){var r=e;n.interactable.options.resize.square?("y"===n.resizeAxes?r.delta.x=r.delta.y:r.delta.y=r.delta.x,r.axes="xy"):(r.axes=n.resizeAxes,"x"===n.resizeAxes?r.delta.y=0:"y"===n.resizeAxes&&(r.delta.x=0))}}var Rt,Ct,jt={id:"actions/resize",before:["actions/drag"],install:function(t){var e=t.actions,n=t.browser,r=t.Interactable,i=t.defaults;jt.cursors=function(t){return t.isIe9?{x:"e-resize",y:"s-resize",xy:"se-resize",top:"n-resize",left:"w-resize",bottom:"s-resize",right:"e-resize",topleft:"se-resize",bottomright:"se-resize",topright:"ne-resize",bottomleft:"ne-resize"}:{x:"ew-resize",y:"ns-resize",xy:"nwse-resize",top:"ns-resize",left:"ew-resize",bottom:"ns-resize",right:"ew-resize",topleft:"nwse-resize",bottomright:"nwse-resize",topright:"nesw-resize",bottomleft:"nesw-resize"}}(n),jt.defaultMargin=n.supportsTouch||n.supportsPointerEvent?20:10,r.prototype.resizable=function(e){return function(t,e,n){if(w.object(e))return t.options.resize.enabled=!1!==e.enabled,t.setPerAction("resize",e),t.setOnEvents("resize",e),w.string(e.axis)&&/^x$|^y$|^xy$/.test(e.axis)?t.options.resize.axis=e.axis:null===e.axis&&(t.options.resize.axis=n.defaults.actions.resize.axis),w.bool(e.preserveAspectRatio)?t.options.resize.preserveAspectRatio=e.preserveAspectRatio:w.bool(e.square)&&(t.options.resize.square=e.square),t;if(w.bool(e))return t.options.resize.enabled=e,t;return t.options.resize}(this,e,t)},e.map.resize=jt,e.methodDict.resize="resizable",i.actions.resize=jt.defaults},listeners:{"interactions:new":function(t){t.interaction.resizeAxes="xy"},"interactions:action-start":function(t){!function(t){var e=t.iEvent,n=t.interaction;if("resize"===n.prepared.name&&n.prepared.edges){var r=e,i=n.rect;n._rects={start:V({},i),corrected:V({},i),previous:V({},i),delta:{left:0,right:0,width:0,top:0,bottom:0,height:0}},r.edges=n.prepared.edges,r.rect=n._rects.corrected,r.deltaRect=n._rects.delta}}(t),At(t)},"interactions:action-move":function(t){!function(t){var e=t.iEvent,n=t.interaction;if("resize"===n.prepared.name&&n.prepared.edges){var r=e,i=n.interactable.options.resize.invert,o="reposition"===i||"negate"===i,a=n.rect,s=n._rects,c=s.start,l=s.corrected,u=s.delta,p=s.previous;if(V(p,l),o){if(V(l,a),"reposition"===i){if(l.top>l.bottom){var f=l.top;l.top=l.bottom,l.bottom=f}if(l.left>l.right){var d=l.left;l.left=l.right,l.right=d}}}else l.top=Math.min(a.top,c.bottom),l.bottom=Math.max(a.bottom,c.top),l.left=Math.min(a.left,c.right),l.right=Math.max(a.right,c.left);for(var h in l.width=l.right-l.left,l.height=l.bottom-l.top,l)u[h]=l[h]-p[h];r.edges=n.prepared.edges,r.rect=l,r.deltaRect=u}}(t),At(t)},"interactions:action-end":function(t){var e=t.iEvent,n=t.interaction;if("resize"===n.prepared.name&&n.prepared.edges){var r=e;r.edges=n.prepared.edges,r.rect=n._rects.corrected,r.deltaRect=n._rects.delta}},"auto-start:check":function(t){var e=t.interaction,n=t.interactable,r=t.element,i=t.rect,o=t.buttons;if(i){var a=V({},e.coords.cur.page),s=n.options.resize;if(s&&s.enabled&&(!e.pointerIsDown||!/mouse|pointer/.test(e.pointerType)||0!=(o&s.mouseButtons))){if(w.object(s.edges)){var c={left:!1,right:!1,top:!1,bottom:!1};for(var l in c)c[l]=zt(l,s.edges[l],a,e._latestPointer.eventTarget,r,i,s.margin||jt.defaultMargin);c.left=c.left&&!c.right,c.top=c.top&&!c.bottom,(c.left||c.right||c.top||c.bottom)&&(t.action={name:"resize",edges:c})}else{var u="y"!==s.axis&&a.x>i.right-jt.defaultMargin,p="x"!==s.axis&&a.y>i.bottom-jt.defaultMargin;(u||p)&&(t.action={name:"resize",axes:(u?"x":"")+(p?"y":"")})}return!t.action&&void 0}}}},defaults:{square:!1,preserveAspectRatio:!1,axis:"xy",margin:NaN,edges:null,invert:"none"},cursors:null,getCursor:function(t){var e=t.edges,n=t.axis,r=t.name,i=jt.cursors,o=null;if(n)o=i[r+n];else if(e){for(var a="",s=0,c=["top","bottom","left","right"];s<c.length;s++){var l=c[s];e[l]&&(a+=l)}o=i[a]}return o},filterEventType:function(t){return 0===t.search("resize")},defaultMargin:null},Ft=jt,Xt={id:"actions",install:function(t){t.usePlugin(Mt),t.usePlugin(Ft),t.usePlugin(_),t.usePlugin(kt)}},Yt=0;var Lt={request:function(t){return Rt(t)},cancel:function(t){return Ct(t)},init:function(t){if(Rt=t.requestAnimationFrame,Ct=t.cancelAnimationFrame,!Rt)for(var e=["ms","moz","webkit","o"],n=0;n<e.length;n++){var r=e[n];Rt=t["".concat(r,"RequestAnimationFrame")],Ct=t["".concat(r,"CancelAnimationFrame")]||t["".concat(r,"CancelRequestAnimationFrame")]}Rt=Rt&&Rt.bind(t),Ct=Ct&&Ct.bind(t),Rt||(Rt=function(e){var n=Date.now(),r=Math.max(0,16-(n-Yt)),i=t.setTimeout((function(){e(n+r)}),r);return Yt=n+r,i},Ct=function(t){return clearTimeout(t)})}};var qt={defaults:{enabled:!1,margin:60,container:null,speed:300},now:Date.now,interaction:null,i:0,x:0,y:0,isScrolling:!1,prevTime:0,margin:0,speed:0,start:function(t){qt.isScrolling=!0,Lt.cancel(qt.i),t.autoScroll=qt,qt.interaction=t,qt.prevTime=qt.now(),qt.i=Lt.request(qt.scroll)},stop:function(){qt.isScrolling=!1,qt.interaction&&(qt.interaction.autoScroll=null),Lt.cancel(qt.i)},scroll:function(){var t=qt.interaction,e=t.interactable,n=t.element,r=t.prepared.name,i=e.options[r].autoScroll,o=Bt(i.container,e,n),a=qt.now(),s=(a-qt.prevTime)/1e3,c=i.speed*s;if(c>=1){var l={x:qt.x*c,y:qt.y*c};if(l.x||l.y){var u=Vt(o);w.window(o)?o.scrollBy(l.x,l.y):o&&(o.scrollLeft+=l.x,o.scrollTop+=l.y);var p=Vt(o),f={x:p.x-u.x,y:p.y-u.y};(f.x||f.y)&&e.fire({type:"autoscroll",target:n,interactable:e,delta:f,interaction:t,container:o})}qt.prevTime=a}qt.isScrolling&&(Lt.cancel(qt.i),qt.i=Lt.request(qt.scroll))},check:function(t,e){var n;return null==(n=t.options[e].autoScroll)?void 0:n.enabled},onInteractionMove:function(t){var e=t.interaction,n=t.pointer;if(e.interacting()&&qt.check(e.interactable,e.prepared.name))if(e.simulation)qt.x=qt.y=0;else{var r,i,o,a,s=e.interactable,c=e.element,l=e.prepared.name,u=s.options[l].autoScroll,p=Bt(u.container,s,c);if(w.window(p))a=n.clientX<qt.margin,r=n.clientY<qt.margin,i=n.clientX>p.innerWidth-qt.margin,o=n.clientY>p.innerHeight-qt.margin;else{var f=Y(p);a=n.clientX<f.left+qt.margin,r=n.clientY<f.top+qt.margin,i=n.clientX>f.right-qt.margin,o=n.clientY>f.bottom-qt.margin}qt.x=i?1:a?-1:0,qt.y=o?1:r?-1:0,qt.isScrolling||(qt.margin=u.margin,qt.speed=u.speed,qt.start(e))}}};function Bt(t,e,n){return(w.string(t)?W(t,e,n):t)||y(n)}function Vt(t){return w.window(t)&&(t=window.document.body),{x:t.scrollLeft,y:t.scrollTop}}var Wt={id:"auto-scroll",install:function(t){var e=t.defaults,n=t.actions;t.autoScroll=qt,qt.now=function(){return t.now()},n.phaselessTypes.autoscroll=!0,e.perAction.autoScroll=qt.defaults},listeners:{"interactions:new":function(t){t.interaction.autoScroll=null},"interactions:destroy":function(t){t.interaction.autoScroll=null,qt.stop(),qt.interaction&&(qt.interaction=null)},"interactions:stop":qt.stop,"interactions:action-move":function(t){return qt.onInteractionMove(t)}}},Gt=Wt;function Nt(t,e){var n=!1;return function(){return n||(g.console.warn(e),n=!0),t.apply(this,arguments)}}function Ut(t,e){return t.name=e.name,t.axis=e.axis,t.edges=e.edges,t}function Ht(t){return w.bool(t)?(this.options.styleCursor=t,this):null===t?(delete this.options.styleCursor,this):this.options.styleCursor}function Kt(t){return w.func(t)?(this.options.actionChecker=t,this):null===t?(delete this.options.actionChecker,this):this.options.actionChecker}var $t={id:"auto-start/interactableMethods",install:function(t){var e=t.Interactable;e.prototype.getAction=function(e,n,r,i){var o=function(t,e,n,r,i){var o=t.getRect(r),a=e.buttons||{0:1,1:4,3:8,4:16}[e.button],s={action:null,interactable:t,interaction:n,element:r,rect:o,buttons:a};return i.fire("auto-start:check",s),s.action}(this,n,r,i,t);return this.options.actionChecker?this.options.actionChecker(e,n,o,this,i,r):o},e.prototype.ignoreFrom=Nt((function(t){return this._backCompatOption("ignoreFrom",t)}),"Interactable.ignoreFrom() has been deprecated. Use Interactble.draggable({ignoreFrom: newValue})."),e.prototype.allowFrom=Nt((function(t){return this._backCompatOption("allowFrom",t)}),"Interactable.allowFrom() has been deprecated. Use Interactble.draggable({allowFrom: newValue})."),e.prototype.actionChecker=Kt,e.prototype.styleCursor=Ht}};function Jt(t,e,n,r,i){return e.testIgnoreAllow(e.options[t.name],n,r)&&e.options[t.name].enabled&&ee(e,n,t,i)?t:null}function Qt(t,e,n,r,i,o,a){for(var s=0,c=r.length;s<c;s++){var l=r[s],u=i[s],p=l.getAction(e,n,t,u);if(p){var f=Jt(p,l,u,o,a);if(f)return{action:f,interactable:l,element:u}}}return{action:null,interactable:null,element:null}}function Zt(t,e,n,r,i){var o=[],a=[],s=r;function c(t){o.push(t),a.push(s)}for(;w.element(s);){o=[],a=[],i.interactables.forEachMatch(s,c);var l=Qt(t,e,n,o,a,r,i);if(l.action&&!l.interactable.options[l.action.name].manualStart)return l;s=A(s)}return{action:null,interactable:null,element:null}}function te(t,e,n){var r=e.action,i=e.interactable,o=e.element;r=r||{name:null},t.interactable=i,t.element=o,Ut(t.prepared,r),t.rect=i&&r.name?i.getRect(o):null,ie(t,n),n.fire("autoStart:prepared",{interaction:t})}function ee(t,e,n,r){var i=t.options,o=i[n.name].max,a=i[n.name].maxPerElement,s=r.autoStart.maxInteractions,c=0,l=0,u=0;if(!(o&&a&&s))return!1;for(var p=0,f=r.interactions.list;p<f.length;p++){var d=f[p],h=d.prepared.name;if(d.interacting()){if(++c>=s)return!1;if(d.interactable===t){if((l+=h===n.name?1:0)>=o)return!1;if(d.element===e&&(u++,h===n.name&&u>=a))return!1}}}return s>0}function ne(t,e){return w.number(t)?(e.autoStart.maxInteractions=t,this):e.autoStart.maxInteractions}function re(t,e,n){var r=n.autoStart.cursorElement;r&&r!==t&&(r.style.cursor=""),t.ownerDocument.documentElement.style.cursor=e,t.style.cursor=e,n.autoStart.cursorElement=e?t:null}function ie(t,e){var n=t.interactable,r=t.element,i=t.prepared;if("mouse"===t.pointerType&&n&&n.options.styleCursor){var o="";if(i.name){var a=n.options[i.name].cursorChecker;o=w.func(a)?a(i,n,r,t._interacting):e.actions.map[i.name].getCursor(i)}re(t.element,o||"",e)}else e.autoStart.cursorElement&&re(e.autoStart.cursorElement,"",e)}var oe={id:"auto-start/base",before:["actions"],install:function(t){var e=t.interactStatic,n=t.defaults;t.usePlugin($t),n.base.actionChecker=null,n.base.styleCursor=!0,V(n.perAction,{manualStart:!1,max:1/0,maxPerElement:1,allowFrom:null,ignoreFrom:null,mouseButtons:1}),e.maxInteractions=function(e){return ne(e,t)},t.autoStart={maxInteractions:1/0,withinInteractionLimit:ee,cursorElement:null}},listeners:{"interactions:down":function(t,e){var n=t.interaction,r=t.pointer,i=t.event,o=t.eventTarget;n.interacting()||te(n,Zt(n,r,i,o,e),e)},"interactions:move":function(t,e){!function(t,e){var n=t.interaction,r=t.pointer,i=t.event,o=t.eventTarget;"mouse"!==n.pointerType||n.pointerIsDown||n.interacting()||te(n,Zt(n,r,i,o,e),e)}(t,e),function(t,e){var n=t.interaction;if(n.pointerIsDown&&!n.interacting()&&n.pointerWasMoved&&n.prepared.name){e.fire("autoStart:before-start",t);var r=n.interactable,i=n.prepared.name;i&&r&&(r.options[i].manualStart||!ee(r,n.element,n.prepared,e)?n.stop():(n.start(n.prepared,r,n.element),ie(n,e)))}}(t,e)},"interactions:stop":function(t,e){var n=t.interaction,r=n.interactable;r&&r.options.styleCursor&&re(n.element,"",e)}},maxInteractions:ne,withinInteractionLimit:ee,validateAction:Jt},ae=oe;var se={id:"auto-start/dragAxis",listeners:{"autoStart:before-start":function(t,e){var n=t.interaction,r=t.eventTarget,i=t.dx,o=t.dy;if("drag"===n.prepared.name){var a=Math.abs(i),s=Math.abs(o),c=n.interactable.options.drag,l=c.startAxis,u=a>s?"x":a<s?"y":"xy";if(n.prepared.axis="start"===c.lockAxis?u[0]:c.lockAxis,"xy"!==u&&"xy"!==l&&l!==u){n.prepared.name=null;for(var p=r,f=function(t){if(t!==n.interactable){var i=n.interactable.options.drag;if(!i.manualStart&&t.testIgnoreAllow(i,p,r)){var o=t.getAction(n.downPointer,n.downEvent,n,p);if(o&&"drag"===o.name&&function(t,e){if(!e)return!1;var n=e.options.drag.startAxis;return"xy"===t||"xy"===n||n===t}(u,t)&&ae.validateAction(o,t,p,r,e))return t}}};w.element(p);){var d=e.interactables.forEachMatch(p,f);if(d){n.prepared.name="drag",n.interactable=d,n.element=p;break}p=A(p)}}}}}};function ce(t){var e=t.prepared&&t.prepared.name;if(!e)return null;var n=t.interactable.options;return n[e].hold||n[e].delay}var le={id:"auto-start/hold",install:function(t){var e=t.defaults;t.usePlugin(ae),e.perAction.hold=0,e.perAction.delay=0},listeners:{"interactions:new":function(t){t.interaction.autoStartHoldTimer=null},"autoStart:prepared":function(t){var e=t.interaction,n=ce(e);n>0&&(e.autoStartHoldTimer=setTimeout((function(){e.start(e.prepared,e.interactable,e.element)}),n))},"interactions:move":function(t){var e=t.interaction,n=t.duplicate;e.autoStartHoldTimer&&e.pointerWasMoved&&!n&&(clearTimeout(e.autoStartHoldTimer),e.autoStartHoldTimer=null)},"autoStart:before-start":function(t){var e=t.interaction;ce(e)>0&&(e.prepared.name=null)}},getHoldDuration:ce},ue=le,pe={id:"auto-start",install:function(t){t.usePlugin(ae),t.usePlugin(ue),t.usePlugin(se)}},fe=function(t){return/^(always|never|auto)$/.test(t)?(this.options.preventDefault=t,this):w.bool(t)?(this.options.preventDefault=t?"always":"never",this):this.options.preventDefault};function de(t){var e=t.interaction,n=t.event;e.interactable&&e.interactable.checkAndPreventDefault(n)}var he={id:"core/interactablePreventDefault",install:function(t){var e=t.Interactable;e.prototype.preventDefault=fe,e.prototype.checkAndPreventDefault=function(e){return function(t,e,n){var r=t.options.preventDefault;if("never"!==r)if("always"!==r){if(e.events.supportsPassive&&/^touch(start|move)$/.test(n.type)){var i=y(n.target).document,o=e.getDocOptions(i);if(!o||!o.events||!1!==o.events.passive)return}/^(mouse|pointer|touch)*(down|start)/i.test(n.type)||w.element(n.target)&&R(n.target,"input,select,textarea,[contenteditable=true],[contenteditable=true] *")||n.preventDefault()}else n.preventDefault()}(this,t,e)},t.interactions.docEvents.push({type:"dragstart",listener:function(e){for(var n=0,r=t.interactions.list;n<r.length;n++){var i=r[n];if(i.element&&(i.element===e.target||M(i.element,e.target)))return void i.interactable.checkAndPreventDefault(e)}}})},listeners:["down","move","up","cancel"].reduce((function(t,e){return t["interactions:".concat(e)]=de,t}),{})};function ve(t,e){if(e.phaselessTypes[t])return!0;for(var n in e.map)if(0===t.indexOf(n)&&t.substr(n.length)in e.phases)return!0;return!1}function ge(t){var e={};for(var n in t){var r=t[n];w.plainObject(r)?e[n]=ge(r):w.array(r)?e[n]=mt(r):e[n]=r}return e}var me=function(){function t(e){r(this,t),this.states=[],this.startOffset={left:0,right:0,top:0,bottom:0},this.startDelta=void 0,this.result=void 0,this.endResult=void 0,this.startEdges=void 0,this.edges=void 0,this.interaction=void 0,this.interaction=e,this.result=ye(),this.edges={left:!1,right:!1,top:!1,bottom:!1}}return o(t,[{key:"start",value:function(t,e){var n,r,i=t.phase,o=this.interaction,a=function(t){var e=t.interactable.options[t.prepared.name],n=e.modifiers;if(n&&n.length)return n;return["snap","snapSize","snapEdges","restrict","restrictEdges","restrictSize"].map((function(t){var n=e[t];return n&&n.enabled&&{options:n,methods:n._methods}})).filter((function(t){return!!t}))}(o);this.prepareStates(a),this.startEdges=V({},o.edges),this.edges=V({},this.startEdges),this.startOffset=(n=o.rect,r=e,n?{left:r.x-n.left,top:r.y-n.top,right:n.right-r.x,bottom:n.bottom-r.y}:{left:0,top:0,right:0,bottom:0}),this.startDelta={x:0,y:0};var s=this.fillArg({phase:i,pageCoords:e,preEnd:!1});return this.result=ye(),this.startAll(s),this.result=this.setAll(s)}},{key:"fillArg",value:function(t){var e=this.interaction;return t.interaction=e,t.interactable=e.interactable,t.element=e.element,t.rect||(t.rect=e.rect),t.edges||(t.edges=this.startEdges),t.startOffset=this.startOffset,t}},{key:"startAll",value:function(t){for(var e=0,n=this.states;e<n.length;e++){var r=n[e];r.methods.start&&(t.state=r,r.methods.start(t))}}},{key:"setAll",value:function(t){var e=t.phase,n=t.preEnd,r=t.skipModifiers,i=t.rect,o=t.edges;t.coords=V({},t.pageCoords),t.rect=V({},i),t.edges=V({},o);for(var a=r?this.states.slice(r):this.states,s=ye(t.coords,t.rect),c=0;c<a.length;c++){var l,u=a[c],p=u.options,f=V({},t.coords),d=null;null!=(l=u.methods)&&l.set&&this.shouldDo(p,n,e)&&(t.state=u,d=u.methods.set(t),H(t.edges,t.rect,{x:t.coords.x-f.x,y:t.coords.y-f.y})),s.eventProps.push(d)}V(this.edges,t.edges),s.delta.x=t.coords.x-t.pageCoords.x,s.delta.y=t.coords.y-t.pageCoords.y,s.rectDelta.left=t.rect.left-i.left,s.rectDelta.right=t.rect.right-i.right,s.rectDelta.top=t.rect.top-i.top,s.rectDelta.bottom=t.rect.bottom-i.bottom;var h=this.result.coords,v=this.result.rect;if(h&&v){var g=s.rect.left!==v.left||s.rect.right!==v.right||s.rect.top!==v.top||s.rect.bottom!==v.bottom;s.changed=g||h.x!==s.coords.x||h.y!==s.coords.y}return s}},{key:"applyToInteraction",value:function(t){var e=this.interaction,n=t.phase,r=e.coords.cur,i=e.coords.start,o=this.result,a=this.startDelta,s=o.delta;"start"===n&&V(this.startDelta,o.delta);for(var c=0,l=[[i,a],[r,s]];c<l.length;c++){var u=l[c],p=u[0],f=u[1];p.page.x+=f.x,p.page.y+=f.y,p.client.x+=f.x,p.client.y+=f.y}var d=this.result.rectDelta,h=t.rect||e.rect;h.left+=d.left,h.right+=d.right,h.top+=d.top,h.bottom+=d.bottom,h.width=h.right-h.left,h.height=h.bottom-h.top}},{key:"setAndApply",value:function(t){var e=this.interaction,n=t.phase,r=t.preEnd,i=t.skipModifiers,o=this.setAll(this.fillArg({preEnd:r,phase:n,pageCoords:t.modifiedCoords||e.coords.cur.page}));if(this.result=o,!o.changed&&(!i||i<this.states.length)&&e.interacting())return!1;if(t.modifiedCoords){var a=e.coords.cur.page,s={x:t.modifiedCoords.x-a.x,y:t.modifiedCoords.y-a.y};o.coords.x+=s.x,o.coords.y+=s.y,o.delta.x+=s.x,o.delta.y+=s.y}this.applyToInteraction(t)}},{key:"beforeEnd",value:function(t){var e=t.interaction,n=t.event,r=this.states;if(r&&r.length){for(var i=!1,o=0;o<r.length;o++){var a=r[o];t.state=a;var s=a.options,c=a.methods,l=c.beforeEnd&&c.beforeEnd(t);if(l)return this.endResult=l,!1;i=i||!i&&this.shouldDo(s,!0,t.phase,!0)}i&&e.move({event:n,preEnd:!0})}}},{key:"stop",value:function(t){var e=t.interaction;if(this.states&&this.states.length){var n=V({states:this.states,interactable:e.interactable,element:e.element,rect:null},t);this.fillArg(n);for(var r=0,i=this.states;r<i.length;r++){var o=i[r];n.state=o,o.methods.stop&&o.methods.stop(n)}this.states=null,this.endResult=null}}},{key:"prepareStates",value:function(t){this.states=[];for(var e=0;e<t.length;e++){var n=t[e],r=n.options,i=n.methods,o=n.name;this.states.push({options:r,methods:i,index:e,name:o})}return this.states}},{key:"restoreInteractionCoords",value:function(t){var e=t.interaction,n=e.coords,r=e.rect,i=e.modification;if(i.result){for(var o=i.startDelta,a=i.result,s=a.delta,c=a.rectDelta,l=0,u=[[n.start,o],[n.cur,s]];l<u.length;l++){var p=u[l],f=p[0],d=p[1];f.page.x-=d.x,f.page.y-=d.y,f.client.x-=d.x,f.client.y-=d.y}r.left-=c.left,r.right-=c.right,r.top-=c.top,r.bottom-=c.bottom}}},{key:"shouldDo",value:function(t,e,n,r){return!(!t||!1===t.enabled||r&&!t.endOnly||t.endOnly&&!e||"start"===n&&!t.setStart)}},{key:"copyFrom",value:function(t){this.startOffset=t.startOffset,this.startDelta=t.startDelta,this.startEdges=t.startEdges,this.edges=t.edges,this.states=t.states.map((function(t){return ge(t)})),this.result=ye(V({},t.result.coords),V({},t.result.rect))}},{key:"destroy",value:function(){for(var t in this)this[t]=null}}]),t}();function ye(t,e){return{rect:e,coords:t,delta:{x:0,y:0},rectDelta:{left:0,right:0,top:0,bottom:0},eventProps:[],changed:!0}}function be(t,e){var n=t.defaults,r={start:t.start,set:t.set,beforeEnd:t.beforeEnd,stop:t.stop},i=function(t){var i=t||{};for(var o in i.enabled=!1!==i.enabled,n)o in i||(i[o]=n[o]);var a={options:i,methods:r,name:e,enable:function(){return i.enabled=!0,a},disable:function(){return i.enabled=!1,a}};return a};return e&&"string"==typeof e&&(i._defaults=n,i._methods=r),i}function xe(t){var e=t.iEvent,n=t.interaction.modification.result;n&&(e.modifiers=n.eventProps)}var we={id:"modifiers/base",before:["actions"],install:function(t){t.defaults.perAction.modifiers=[]},listeners:{"interactions:new":function(t){var e=t.interaction;e.modification=new me(e)},"interactions:before-action-start":function(t){var e=t.interaction,n=t.interaction.modification;n.start(t,e.coords.start.page),e.edges=n.edges,n.applyToInteraction(t)},"interactions:before-action-move":function(t){var e=t.interaction,n=e.modification,r=n.setAndApply(t);return e.edges=n.edges,r},"interactions:before-action-end":function(t){var e=t.interaction,n=e.modification,r=n.beforeEnd(t);return e.edges=n.startEdges,r},"interactions:action-start":xe,"interactions:action-move":xe,"interactions:action-end":xe,"interactions:after-action-start":function(t){return t.interaction.modification.restoreInteractionCoords(t)},"interactions:after-action-move":function(t){return t.interaction.modification.restoreInteractionCoords(t)},"interactions:stop":function(t){return t.interaction.modification.stop(t)}}},Ee=we,Te={base:{preventDefault:"auto",deltaSource:"page"},perAction:{enabled:!1,origin:{x:0,y:0}},actions:{}},Se=function(t){s(n,t);var e=p(n);function n(t,i,o,a,s,c,l){var p;r(this,n),(p=e.call(this,t)).relatedTarget=null,p.screenX=void 0,p.screenY=void 0,p.button=void 0,p.buttons=void 0,p.ctrlKey=void 0,p.shiftKey=void 0,p.altKey=void 0,p.metaKey=void 0,p.page=void 0,p.client=void 0,p.delta=void 0,p.rect=void 0,p.x0=void 0,p.y0=void 0,p.t0=void 0,p.dt=void 0,p.duration=void 0,p.clientX0=void 0,p.clientY0=void 0,p.velocity=void 0,p.speed=void 0,p.swipe=void 0,p.axes=void 0,p.preEnd=void 0,s=s||t.element;var f=t.interactable,d=(f&&f.options||Te).deltaSource,h=K(f,s,o),v="start"===a,g="end"===a,m=v?u(p):t.prevEvent,y=v?t.coords.start:g?{page:m.page,client:m.client,timeStamp:t.coords.cur.timeStamp}:t.coords.cur;return p.page=V({},y.page),p.client=V({},y.client),p.rect=V({},t.rect),p.timeStamp=y.timeStamp,g||(p.page.x-=h.x,p.page.y-=h.y,p.client.x-=h.x,p.client.y-=h.y),p.ctrlKey=i.ctrlKey,p.altKey=i.altKey,p.shiftKey=i.shiftKey,p.metaKey=i.metaKey,p.button=i.button,p.buttons=i.buttons,p.target=s,p.currentTarget=s,p.preEnd=c,p.type=l||o+(a||""),p.interactable=f,p.t0=v?t.pointers[t.pointers.length-1].downTime:m.t0,p.x0=t.coords.start.page.x-h.x,p.y0=t.coords.start.page.y-h.y,p.clientX0=t.coords.start.client.x-h.x,p.clientY0=t.coords.start.client.y-h.y,p.delta=v||g?{x:0,y:0}:{x:p[d].x-m[d].x,y:p[d].y-m[d].y},p.dt=t.coords.delta.timeStamp,p.duration=p.timeStamp-p.t0,p.velocity=V({},t.coords.velocity[d]),p.speed=Q(p.velocity.x,p.velocity.y),p.swipe=g||"inertiastart"===a?p.getSwipe():null,p}return o(n,[{key:"getSwipe",value:function(){var t=this._interaction;if(t.prevEvent.speed<600||this.timeStamp-t.prevEvent.timeStamp>150)return null;var e=180*Math.atan2(t.prevEvent.velocityY,t.prevEvent.velocityX)/Math.PI;e<0&&(e+=360);var n=112.5<=e&&e<247.5,r=202.5<=e&&e<337.5;return{up:r,down:!r&&22.5<=e&&e<157.5,left:n,right:!n&&(292.5<=e||e<67.5),angle:e,speed:t.prevEvent.speed,velocity:{x:t.prevEvent.velocityX,y:t.prevEvent.velocityY}}}},{key:"preventDefault",value:function(){}},{key:"stopImmediatePropagation",value:function(){this.immediatePropagationStopped=this.propagationStopped=!0}},{key:"stopPropagation",value:function(){this.propagationStopped=!0}}]),n}(vt);Object.defineProperties(Se.prototype,{pageX:{get:function(){return this.page.x},set:function(t){this.page.x=t}},pageY:{get:function(){return this.page.y},set:function(t){this.page.y=t}},clientX:{get:function(){return this.client.x},set:function(t){this.client.x=t}},clientY:{get:function(){return this.client.y},set:function(t){this.client.y=t}},dx:{get:function(){return this.delta.x},set:function(t){this.delta.x=t}},dy:{get:function(){return this.delta.y},set:function(t){this.delta.y=t}},velocityX:{get:function(){return this.velocity.x},set:function(t){this.velocity.x=t}},velocityY:{get:function(){return this.velocity.y},set:function(t){this.velocity.y=t}}});var _e=o((function t(e,n,i,o,a){r(this,t),this.id=void 0,this.pointer=void 0,this.event=void 0,this.downTime=void 0,this.downTarget=void 0,this.id=e,this.pointer=n,this.event=i,this.downTime=o,this.downTarget=a})),Pe=function(t){return t.interactable="",t.element="",t.prepared="",t.pointerIsDown="",t.pointerWasMoved="",t._proxy="",t}({}),Oe=function(t){return t.start="",t.move="",t.end="",t.stop="",t.interacting="",t}({}),ke=0,De=function(){function t(e){var n=this,i=e.pointerType,o=e.scopeFire;r(this,t),this.interactable=null,this.element=null,this.rect=null,this._rects=void 0,this.edges=null,this._scopeFire=void 0,this.prepared={name:null,axis:null,edges:null},this.pointerType=void 0,this.pointers=[],this.downEvent=null,this.downPointer={},this._latestPointer={pointer:null,event:null,eventTarget:null},this.prevEvent=null,this.pointerIsDown=!1,this.pointerWasMoved=!1,this._interacting=!1,this._ending=!1,this._stopped=!0,this._proxy=void 0,this.simulation=null,this.doMove=Nt((function(t){this.move(t)}),"The interaction.doMove() method has been renamed to interaction.move()"),this.coords={start:{page:{x:0,y:0},client:{x:0,y:0},timeStamp:0},prev:{page:{x:0,y:0},client:{x:0,y:0},timeStamp:0},cur:{page:{x:0,y:0},client:{x:0,y:0},timeStamp:0},delta:{page:{x:0,y:0},client:{x:0,y:0},timeStamp:0},velocity:{page:{x:0,y:0},client:{x:0,y:0},timeStamp:0}},this._id=ke++,this._scopeFire=o,this.pointerType=i;var a=this;this._proxy={};var s=function(t){Object.defineProperty(n._proxy,t,{get:function(){return a[t]}})};for(var c in Pe)s(c);var l=function(t){Object.defineProperty(n._proxy,t,{value:function(){return a[t].apply(a,arguments)}})};for(var u in Oe)l(u);this._scopeFire("interactions:new",{interaction:this})}return o(t,[{key:"pointerMoveTolerance",get:function(){return 1}},{key:"pointerDown",value:function(t,e,n){var r=this.updatePointer(t,e,n,!0),i=this.pointers[r];this._scopeFire("interactions:down",{pointer:t,event:e,eventTarget:n,pointerIndex:r,pointerInfo:i,type:"down",interaction:this})}},{key:"start",value:function(t,e,n){return!(this.interacting()||!this.pointerIsDown||this.pointers.length<("gesture"===t.name?2:1)||!e.options[t.name].enabled)&&(Ut(this.prepared,t),this.interactable=e,this.element=n,this.rect=e.getRect(n),this.edges=this.prepared.edges?V({},this.prepared.edges):{left:!0,right:!0,top:!0,bottom:!0},this._stopped=!1,this._interacting=this._doPhase({interaction:this,event:this.downEvent,phase:"start"})&&!this._stopped,this._interacting)}},{key:"pointerMove",value:function(t,e,n){this.simulation||this.modification&&this.modification.endResult||this.updatePointer(t,e,n,!1);var r,i,o=this.coords.cur.page.x===this.coords.prev.page.x&&this.coords.cur.page.y===this.coords.prev.page.y&&this.coords.cur.client.x===this.coords.prev.client.x&&this.coords.cur.client.y===this.coords.prev.client.y;this.pointerIsDown&&!this.pointerWasMoved&&(r=this.coords.cur.client.x-this.coords.start.client.x,i=this.coords.cur.client.y-this.coords.start.client.y,this.pointerWasMoved=Q(r,i)>this.pointerMoveTolerance);var a,s,c,l=this.getPointerIndex(t),u={pointer:t,pointerIndex:l,pointerInfo:this.pointers[l],event:e,type:"move",eventTarget:n,dx:r,dy:i,duplicate:o,interaction:this};o||(a=this.coords.velocity,s=this.coords.delta,c=Math.max(s.timeStamp/1e3,.001),a.page.x=s.page.x/c,a.page.y=s.page.y/c,a.client.x=s.client.x/c,a.client.y=s.client.y/c,a.timeStamp=c),this._scopeFire("interactions:move",u),o||this.simulation||(this.interacting()&&(u.type=null,this.move(u)),this.pointerWasMoved&&et(this.coords.prev,this.coords.cur))}},{key:"move",value:function(t){t&&t.event||nt(this.coords.delta),(t=V({pointer:this._latestPointer.pointer,event:this._latestPointer.event,eventTarget:this._latestPointer.eventTarget,interaction:this},t||{})).phase="move",this._doPhase(t)}},{key:"pointerUp",value:function(t,e,n,r){var i=this.getPointerIndex(t);-1===i&&(i=this.updatePointer(t,e,n,!1));var o=/cancel$/i.test(e.type)?"cancel":"up";this._scopeFire("interactions:".concat(o),{pointer:t,pointerIndex:i,pointerInfo:this.pointers[i],event:e,eventTarget:n,type:o,curEventTarget:r,interaction:this}),this.simulation||this.end(e),this.removePointer(t,e)}},{key:"documentBlur",value:function(t){this.end(t),this._scopeFire("interactions:blur",{event:t,type:"blur",interaction:this})}},{key:"end",value:function(t){var e;this._ending=!0,t=t||this._latestPointer.event,this.interacting()&&(e=this._doPhase({event:t,interaction:this,phase:"end"})),this._ending=!1,!0===e&&this.stop()}},{key:"currentAction",value:function(){return this._interacting?this.prepared.name:null}},{key:"interacting",value:function(){return this._interacting}},{key:"stop",value:function(){this._scopeFire("interactions:stop",{interaction:this}),this.interactable=this.element=null,this._interacting=!1,this._stopped=!0,this.prepared.name=this.prevEvent=null}},{key:"getPointerIndex",value:function(t){var e=at(t);return"mouse"===this.pointerType||"pen"===this.pointerType?this.pointers.length-1:yt(this.pointers,(function(t){return t.id===e}))}},{key:"getPointerInfo",value:function(t){return this.pointers[this.getPointerIndex(t)]}},{key:"updatePointer",value:function(t,e,n,r){var i,o,a,s=at(t),c=this.getPointerIndex(t),l=this.pointers[c];return r=!1!==r&&(r||/(down|start)$/i.test(e.type)),l?l.pointer=t:(l=new _e(s,t,e,null,null),c=this.pointers.length,this.pointers.push(l)),st(this.coords.cur,this.pointers.map((function(t){return t.pointer})),this._now()),i=this.coords.delta,o=this.coords.prev,a=this.coords.cur,i.page.x=a.page.x-o.page.x,i.page.y=a.page.y-o.page.y,i.client.x=a.client.x-o.client.x,i.client.y=a.client.y-o.client.y,i.timeStamp=a.timeStamp-o.timeStamp,r&&(this.pointerIsDown=!0,l.downTime=this.coords.cur.timeStamp,l.downTarget=n,tt(this.downPointer,t),this.interacting()||(et(this.coords.start,this.coords.cur),et(this.coords.prev,this.coords.cur),this.downEvent=e,this.pointerWasMoved=!1)),this._updateLatestPointer(t,e,n),this._scopeFire("interactions:update-pointer",{pointer:t,event:e,eventTarget:n,down:r,pointerInfo:l,pointerIndex:c,interaction:this}),c}},{key:"removePointer",value:function(t,e){var n=this.getPointerIndex(t);if(-1!==n){var r=this.pointers[n];this._scopeFire("interactions:remove-pointer",{pointer:t,event:e,eventTarget:null,pointerIndex:n,pointerInfo:r,interaction:this}),this.pointers.splice(n,1),this.pointerIsDown=!1}}},{key:"_updateLatestPointer",value:function(t,e,n){this._latestPointer.pointer=t,this._latestPointer.event=e,this._latestPointer.eventTarget=n}},{key:"destroy",value:function(){this._latestPointer.pointer=null,this._latestPointer.event=null,this._latestPointer.eventTarget=null}},{key:"_createPreparedEvent",value:function(t,e,n,r){return new Se(this,t,this.prepared.name,e,this.element,n,r)}},{key:"_fireEvent",value:function(t){var e;null==(e=this.interactable)||e.fire(t),(!this.prevEvent||t.timeStamp>=this.prevEvent.timeStamp)&&(this.prevEvent=t)}},{key:"_doPhase",value:function(t){var e=t.event,n=t.phase,r=t.preEnd,i=t.type,o=this.rect;if(o&&"move"===n&&(H(this.edges,o,this.coords.delta[this.interactable.options.deltaSource]),o.width=o.right-o.left,o.height=o.bottom-o.top),!1===this._scopeFire("interactions:before-action-".concat(n),t))return!1;var a=t.iEvent=this._createPreparedEvent(e,n,r,i);return this._scopeFire("interactions:action-".concat(n),t),"start"===n&&(this.prevEvent=a),this._fireEvent(a),this._scopeFire("interactions:after-action-".concat(n),t),!0}},{key:"_now",value:function(){return Date.now()}}]),t}();function Ie(t){Me(t.interaction)}function Me(t){if(!function(t){return!(!t.offset.pending.x&&!t.offset.pending.y)}(t))return!1;var e=t.offset.pending;return Ae(t.coords.cur,e),Ae(t.coords.delta,e),H(t.edges,t.rect,e),e.x=0,e.y=0,!0}function ze(t){var e=t.x,n=t.y;this.offset.pending.x+=e,this.offset.pending.y+=n,this.offset.total.x+=e,this.offset.total.y+=n}function Ae(t,e){var n=t.page,r=t.client,i=e.x,o=e.y;n.x+=i,n.y+=o,r.x+=i,r.y+=o}Oe.offsetBy="";var Re={id:"offset",before:["modifiers","pointer-events","actions","inertia"],install:function(t){t.Interaction.prototype.offsetBy=ze},listeners:{"interactions:new":function(t){t.interaction.offset={total:{x:0,y:0},pending:{x:0,y:0}}},"interactions:update-pointer":function(t){return function(t){t.pointerIsDown&&(Ae(t.coords.cur,t.offset.total),t.offset.pending.x=0,t.offset.pending.y=0)}(t.interaction)},"interactions:before-action-start":Ie,"interactions:before-action-move":Ie,"interactions:before-action-end":function(t){var e=t.interaction;if(Me(e))return e.move({offset:!0}),e.end(),!1},"interactions:stop":function(t){var e=t.interaction;e.offset.total.x=0,e.offset.total.y=0,e.offset.pending.x=0,e.offset.pending.y=0}}},Ce=Re;var je=function(){function t(e){r(this,t),this.active=!1,this.isModified=!1,this.smoothEnd=!1,this.allowResume=!1,this.modification=void 0,this.modifierCount=0,this.modifierArg=void 0,this.startCoords=void 0,this.t0=0,this.v0=0,this.te=0,this.targetOffset=void 0,this.modifiedOffset=void 0,this.currentOffset=void 0,this.lambda_v0=0,this.one_ve_v0=0,this.timeout=void 0,this.interaction=void 0,this.interaction=e}return o(t,[{key:"start",value:function(t){var e=this.interaction,n=Fe(e);if(!n||!n.enabled)return!1;var r=e.coords.velocity.client,i=Q(r.x,r.y),o=this.modification||(this.modification=new me(e));if(o.copyFrom(e.modification),this.t0=e._now(),this.allowResume=n.allowResume,this.v0=i,this.currentOffset={x:0,y:0},this.startCoords=e.coords.cur.page,this.modifierArg=o.fillArg({pageCoords:this.startCoords,preEnd:!0,phase:"inertiastart"}),this.t0-e.coords.cur.timeStamp<50&&i>n.minSpeed&&i>n.endSpeed)this.startInertia();else{if(o.result=o.setAll(this.modifierArg),!o.result.changed)return!1;this.startSmoothEnd()}return e.modification.result.rect=null,e.offsetBy(this.targetOffset),e._doPhase({interaction:e,event:t,phase:"inertiastart"}),e.offsetBy({x:-this.targetOffset.x,y:-this.targetOffset.y}),e.modification.result.rect=null,this.active=!0,e.simulation=this,!0}},{key:"startInertia",value:function(){var t=this,e=this.interaction.coords.velocity.client,n=Fe(this.interaction),r=n.resistance,i=-Math.log(n.endSpeed/this.v0)/r;this.targetOffset={x:(e.x-i)/r,y:(e.y-i)/r},this.te=i,this.lambda_v0=r/this.v0,this.one_ve_v0=1-n.endSpeed/this.v0;var o=this.modification,a=this.modifierArg;a.pageCoords={x:this.startCoords.x+this.targetOffset.x,y:this.startCoords.y+this.targetOffset.y},o.result=o.setAll(a),o.result.changed&&(this.isModified=!0,this.modifiedOffset={x:this.targetOffset.x+o.result.delta.x,y:this.targetOffset.y+o.result.delta.y}),this.onNextFrame((function(){return t.inertiaTick()}))}},{key:"startSmoothEnd",value:function(){var t=this;this.smoothEnd=!0,this.isModified=!0,this.targetOffset={x:this.modification.result.delta.x,y:this.modification.result.delta.y},this.onNextFrame((function(){return t.smoothEndTick()}))}},{key:"onNextFrame",value:function(t){var e=this;this.timeout=Lt.request((function(){e.active&&t()}))}},{key:"inertiaTick",value:function(){var t,e,n,r,i,o,a,s=this,c=this.interaction,l=Fe(c).resistance,u=(c._now()-this.t0)/1e3;if(u<this.te){var p,f=1-(Math.exp(-l*u)-this.lambda_v0)/this.one_ve_v0;this.isModified?(t=0,e=0,n=this.targetOffset.x,r=this.targetOffset.y,i=this.modifiedOffset.x,o=this.modifiedOffset.y,p={x:Ye(a=f,t,n,i),y:Ye(a,e,r,o)}):p={x:this.targetOffset.x*f,y:this.targetOffset.y*f};var d={x:p.x-this.currentOffset.x,y:p.y-this.currentOffset.y};this.currentOffset.x+=d.x,this.currentOffset.y+=d.y,c.offsetBy(d),c.move(),this.onNextFrame((function(){return s.inertiaTick()}))}else c.offsetBy({x:this.modifiedOffset.x-this.currentOffset.x,y:this.modifiedOffset.y-this.currentOffset.y}),this.end()}},{key:"smoothEndTick",value:function(){var t=this,e=this.interaction,n=e._now()-this.t0,r=Fe(e).smoothEndDuration;if(n<r){var i={x:Le(n,0,this.targetOffset.x,r),y:Le(n,0,this.targetOffset.y,r)},o={x:i.x-this.currentOffset.x,y:i.y-this.currentOffset.y};this.currentOffset.x+=o.x,this.currentOffset.y+=o.y,e.offsetBy(o),e.move({skipModifiers:this.modifierCount}),this.onNextFrame((function(){return t.smoothEndTick()}))}else e.offsetBy({x:this.targetOffset.x-this.currentOffset.x,y:this.targetOffset.y-this.currentOffset.y}),this.end()}},{key:"resume",value:function(t){var e=t.pointer,n=t.event,r=t.eventTarget,i=this.interaction;i.offsetBy({x:-this.currentOffset.x,y:-this.currentOffset.y}),i.updatePointer(e,n,r,!0),i._doPhase({interaction:i,event:n,phase:"resume"}),et(i.coords.prev,i.coords.cur),this.stop()}},{key:"end",value:function(){this.interaction.move(),this.interaction.end(),this.stop()}},{key:"stop",value:function(){this.active=this.smoothEnd=!1,this.interaction.simulation=null,Lt.cancel(this.timeout)}}]),t}();function Fe(t){var e=t.interactable,n=t.prepared;return e&&e.options&&n.name&&e.options[n.name].inertia}var Xe={id:"inertia",before:["modifiers","actions"],install:function(t){var e=t.defaults;t.usePlugin(Ce),t.usePlugin(Ee),t.actions.phases.inertiastart=!0,t.actions.phases.resume=!0,e.perAction.inertia={enabled:!1,resistance:10,minSpeed:100,endSpeed:10,allowResume:!0,smoothEndDuration:300}},listeners:{"interactions:new":function(t){var e=t.interaction;e.inertia=new je(e)},"interactions:before-action-end":function(t){var e=t.interaction,n=t.event;return(!e._interacting||e.simulation||!e.inertia.start(n))&&null},"interactions:down":function(t){var e=t.interaction,n=t.eventTarget,r=e.inertia;if(r.active)for(var i=n;w.element(i);){if(i===e.element){r.resume(t);break}i=A(i)}},"interactions:stop":function(t){var e=t.interaction.inertia;e.active&&e.stop()},"interactions:before-action-resume":function(t){var e=t.interaction.modification;e.stop(t),e.start(t,t.interaction.coords.cur.page),e.applyToInteraction(t)},"interactions:before-action-inertiastart":function(t){return t.interaction.modification.setAndApply(t)},"interactions:action-resume":xe,"interactions:action-inertiastart":xe,"interactions:after-action-inertiastart":function(t){return t.interaction.modification.restoreInteractionCoords(t)},"interactions:after-action-resume":function(t){return t.interaction.modification.restoreInteractionCoords(t)}}};function Ye(t,e,n,r){var i=1-t;return i*i*e+2*i*t*n+t*t*r}function Le(t,e,n,r){return-n*(t/=r)*(t-2)+e}var qe=Xe;function Be(t,e){for(var n=0;n<e.length;n++){var r=e[n];if(t.immediatePropagationStopped)break;r(t)}}var Ve=function(){function t(e){r(this,t),this.options=void 0,this.types={},this.propagationStopped=!1,this.immediatePropagationStopped=!1,this.global=void 0,this.options=V({},e||{})}return o(t,[{key:"fire",value:function(t){var e,n=this.global;(e=this.types[t.type])&&Be(t,e),!t.propagationStopped&&n&&(e=n[t.type])&&Be(t,e)}},{key:"on",value:function(t,e){var n=$(t,e);for(t in n)this.types[t]=gt(this.types[t]||[],n[t])}},{key:"off",value:function(t,e){var n=$(t,e);for(t in n){var r=this.types[t];if(r&&r.length)for(var i=0,o=n[t];i<o.length;i++){var a=o[i],s=r.indexOf(a);-1!==s&&r.splice(s,1)}}}},{key:"getRect",value:function(t){return null}}]),t}();var We=function(){function t(e){r(this,t),this.currentTarget=void 0,this.originalEvent=void 0,this.type=void 0,this.originalEvent=e,tt(this,e)}return o(t,[{key:"preventOriginalDefault",value:function(){this.originalEvent.preventDefault()}},{key:"stopPropagation",value:function(){this.originalEvent.stopPropagation()}},{key:"stopImmediatePropagation",value:function(){this.originalEvent.stopImmediatePropagation()}}]),t}();function Ge(t){return w.object(t)?{capture:!!t.capture,passive:!!t.passive}:{capture:!!t,passive:!1}}function Ne(t,e){return t===e||("boolean"==typeof t?!!e.capture===t&&!1==!!e.passive:!!t.capture==!!e.capture&&!!t.passive==!!e.passive)}var Ue={id:"events",install:function(t){var e,n=[],r={},i=[],o={add:a,remove:s,addDelegate:function(t,e,n,o,s){var u=Ge(s);if(!r[n]){r[n]=[];for(var p=0;p<i.length;p++){var f=i[p];a(f,n,c),a(f,n,l,!0)}}var d=r[n],h=bt(d,(function(n){return n.selector===t&&n.context===e}));h||(h={selector:t,context:e,listeners:[]},d.push(h));h.listeners.push({func:o,options:u})},removeDelegate:function(t,e,n,i,o){var a,u=Ge(o),p=r[n],f=!1;if(!p)return;for(a=p.length-1;a>=0;a--){var d=p[a];if(d.selector===t&&d.context===e){for(var h=d.listeners,v=h.length-1;v>=0;v--){var g=h[v];if(g.func===i&&Ne(g.options,u)){h.splice(v,1),h.length||(p.splice(a,1),s(e,n,c),s(e,n,l,!0)),f=!0;break}}if(f)break}}},delegateListener:c,delegateUseCapture:l,delegatedEvents:r,documents:i,targets:n,supportsOptions:!1,supportsPassive:!1};function a(t,e,r,i){if(t.addEventListener){var a=Ge(i),s=bt(n,(function(e){return e.eventTarget===t}));s||(s={eventTarget:t,events:{}},n.push(s)),s.events[e]||(s.events[e]=[]),bt(s.events[e],(function(t){return t.func===r&&Ne(t.options,a)}))||(t.addEventListener(e,r,o.supportsOptions?a:a.capture),s.events[e].push({func:r,options:a}))}}function s(t,e,r,i){if(t.addEventListener&&t.removeEventListener){var a=yt(n,(function(e){return e.eventTarget===t})),c=n[a];if(c&&c.events)if("all"!==e){var l=!1,u=c.events[e];if(u){if("all"===r){for(var p=u.length-1;p>=0;p--){var f=u[p];s(t,e,f.func,f.options)}return}for(var d=Ge(i),h=0;h<u.length;h++){var v=u[h];if(v.func===r&&Ne(v.options,d)){t.removeEventListener(e,r,o.supportsOptions?d:d.capture),u.splice(h,1),0===u.length&&(delete c.events[e],l=!0);break}}}l&&!Object.keys(c.events).length&&n.splice(a,1)}else for(e in c.events)c.events.hasOwnProperty(e)&&s(t,e,"all")}}function c(t,e){for(var n=Ge(e),i=new We(t),o=r[t.type],a=ht(t)[0],s=a;w.element(s);){for(var c=0;c<o.length;c++){var l=o[c],u=l.selector,p=l.context;if(R(s,u)&&M(p,a)&&M(p,s)){var f=l.listeners;i.currentTarget=s;for(var d=0;d<f.length;d++){var h=f[d];Ne(h.options,n)&&h.func(i)}}}s=A(s)}}function l(t){return c(t,!0)}return null==(e=t.document)||e.createElement("div").addEventListener("test",null,{get capture(){return o.supportsOptions=!0},get passive(){return o.supportsPassive=!0}}),t.events=o,o}},He={methodOrder:["simulationResume","mouseOrPen","hasPointer","idle"],search:function(t){for(var e=0,n=He.methodOrder;e<n.length;e++){var r=n[e],i=He[r](t);if(i)return i}return null},simulationResume:function(t){var e=t.pointerType,n=t.eventType,r=t.eventTarget,i=t.scope;if(!/down|start/i.test(n))return null;for(var o=0,a=i.interactions.list;o<a.length;o++){var s=a[o],c=r;if(s.simulation&&s.simulation.allowResume&&s.pointerType===e)for(;c;){if(c===s.element)return s;c=A(c)}}return null},mouseOrPen:function(t){var e,n=t.pointerId,r=t.pointerType,i=t.eventType,o=t.scope;if("mouse"!==r&&"pen"!==r)return null;for(var a=0,s=o.interactions.list;a<s.length;a++){var c=s[a];if(c.pointerType===r){if(c.simulation&&!Ke(c,n))continue;if(c.interacting())return c;e||(e=c)}}if(e)return e;for(var l=0,u=o.interactions.list;l<u.length;l++){var p=u[l];if(!(p.pointerType!==r||/down/i.test(i)&&p.simulation))return p}return null},hasPointer:function(t){for(var e=t.pointerId,n=0,r=t.scope.interactions.list;n<r.length;n++){var i=r[n];if(Ke(i,e))return i}return null},idle:function(t){for(var e=t.pointerType,n=0,r=t.scope.interactions.list;n<r.length;n++){var i=r[n];if(1===i.pointers.length){var o=i.interactable;if(o&&(!o.options.gesture||!o.options.gesture.enabled))continue}else if(i.pointers.length>=2)continue;if(!i.interacting()&&e===i.pointerType)return i}return null}};function Ke(t,e){return t.pointers.some((function(t){return t.id===e}))}var $e=He,Je=["pointerDown","pointerMove","pointerUp","updatePointer","removePointer","windowBlur"];function Qe(t,e){return function(n){var r=e.interactions.list,i=dt(n),o=ht(n),a=o[0],s=o[1],c=[];if(/^touch/.test(n.type)){e.prevTouchTime=e.now();for(var l=0,u=n.changedTouches;l<u.length;l++){var p=u[l],f={pointer:p,pointerId:at(p),pointerType:i,eventType:n.type,eventTarget:a,curEventTarget:s,scope:e},d=Ze(f);c.push([f.pointer,f.eventTarget,f.curEventTarget,d])}}else{var h=!1;if(!I.supportsPointerEvent&&/mouse/.test(n.type)){for(var v=0;v<r.length&&!h;v++)h="mouse"!==r[v].pointerType&&r[v].pointerIsDown;h=h||e.now()-e.prevTouchTime<500||0===n.timeStamp}if(!h){var g={pointer:n,pointerId:at(n),pointerType:i,eventType:n.type,curEventTarget:s,eventTarget:a,scope:e},m=Ze(g);c.push([g.pointer,g.eventTarget,g.curEventTarget,m])}}for(var y=0;y<c.length;y++){var b=c[y],x=b[0],w=b[1],E=b[2];b[3][t](x,n,w,E)}}}function Ze(t){var e=t.pointerType,n=t.scope,r={interaction:$e.search(t),searchDetails:t};return n.fire("interactions:find",r),r.interaction||n.interactions.new({pointerType:e})}function tn(t,e){var n=t.doc,r=t.scope,i=t.options,o=r.interactions.docEvents,a=r.events,s=a[e];for(var c in r.browser.isIOS&&!i.events&&(i.events={passive:!1}),a.delegatedEvents)s(n,c,a.delegateListener),s(n,c,a.delegateUseCapture,!0);for(var l=i&&i.events,u=0;u<o.length;u++){var p=o[u];s(n,p.type,p.listener,l)}}var en={id:"core/interactions",install:function(t){for(var e={},n=0;n<Je.length;n++){var i=Je[n];e[i]=Qe(i,t)}var a,c=I.pEventTypes;function l(){for(var e=0,n=t.interactions.list;e<n.length;e++){var r=n[e];if(r.pointerIsDown&&"touch"===r.pointerType&&!r._interacting)for(var i=function(){var e=a[o];t.documents.some((function(t){return M(t.doc,e.downTarget)}))||r.removePointer(e.pointer,e.event)},o=0,a=r.pointers;o<a.length;o++)i()}}(a=k.PointerEvent?[{type:c.down,listener:l},{type:c.down,listener:e.pointerDown},{type:c.move,listener:e.pointerMove},{type:c.up,listener:e.pointerUp},{type:c.cancel,listener:e.pointerUp}]:[{type:"mousedown",listener:e.pointerDown},{type:"mousemove",listener:e.pointerMove},{type:"mouseup",listener:e.pointerUp},{type:"touchstart",listener:l},{type:"touchstart",listener:e.pointerDown},{type:"touchmove",listener:e.pointerMove},{type:"touchend",listener:e.pointerUp},{type:"touchcancel",listener:e.pointerUp}]).push({type:"blur",listener:function(e){for(var n=0,r=t.interactions.list;n<r.length;n++){r[n].documentBlur(e)}}}),t.prevTouchTime=0,t.Interaction=function(e){s(i,e);var n=p(i);function i(){return r(this,i),n.apply(this,arguments)}return o(i,[{key:"pointerMoveTolerance",get:function(){return t.interactions.pointerMoveTolerance},set:function(e){t.interactions.pointerMoveTolerance=e}},{key:"_now",value:function(){return t.now()}}]),i}(De),t.interactions={list:[],new:function(e){e.scopeFire=function(e,n){return t.fire(e,n)};var n=new t.Interaction(e);return t.interactions.list.push(n),n},listeners:e,docEvents:a,pointerMoveTolerance:1},t.usePlugin(he)},listeners:{"scope:add-document":function(t){return tn(t,"add")},"scope:remove-document":function(t){return tn(t,"remove")},"interactable:unset":function(t,e){for(var n=t.interactable,r=e.interactions.list.length-1;r>=0;r--){var i=e.interactions.list[r];i.interactable===n&&(i.stop(),e.fire("interactions:destroy",{interaction:i}),i.destroy(),e.interactions.list.length>2&&e.interactions.list.splice(r,1))}}},onDocSignal:tn,doOnInteractions:Qe,methodNames:Je},nn=en,rn=function(t){return t[t.On=0]="On",t[t.Off=1]="Off",t}(rn||{}),on=function(){function t(e,n,i,o){r(this,t),this.target=void 0,this.options=void 0,this._actions=void 0,this.events=new Ve,this._context=void 0,this._win=void 0,this._doc=void 0,this._scopeEvents=void 0,this._actions=n.actions,this.target=e,this._context=n.context||i,this._win=y(B(e)?this._context:e),this._doc=this._win.document,this._scopeEvents=o,this.set(n)}return o(t,[{key:"_defaults",get:function(){return{base:{},perAction:{},actions:{}}}},{key:"setOnEvents",value:function(t,e){return w.func(e.onstart)&&this.on("".concat(t,"start"),e.onstart),w.func(e.onmove)&&this.on("".concat(t,"move"),e.onmove),w.func(e.onend)&&this.on("".concat(t,"end"),e.onend),w.func(e.oninertiastart)&&this.on("".concat(t,"inertiastart"),e.oninertiastart),this}},{key:"updatePerActionListeners",value:function(t,e,n){var r,i=this,o=null==(r=this._actions.map[t])?void 0:r.filterEventType,a=function(t){return(null==o||o(t))&&ve(t,i._actions)};(w.array(e)||w.object(e))&&this._onOff(rn.Off,t,e,void 0,a),(w.array(n)||w.object(n))&&this._onOff(rn.On,t,n,void 0,a)}},{key:"setPerAction",value:function(t,e){var n=this._defaults;for(var r in e){var i=r,o=this.options[t],a=e[i];"listeners"===i&&this.updatePerActionListeners(t,o.listeners,a),w.array(a)?o[i]=mt(a):w.plainObject(a)?(o[i]=V(o[i]||{},ge(a)),w.object(n.perAction[i])&&"enabled"in n.perAction[i]&&(o[i].enabled=!1!==a.enabled)):w.bool(a)&&w.object(n.perAction[i])?o[i].enabled=a:o[i]=a}}},{key:"getRect",value:function(t){return t=t||(w.element(this.target)?this.target:null),w.string(this.target)&&(t=t||this._context.querySelector(this.target)),L(t)}},{key:"rectChecker",value:function(t){var e=this;return w.func(t)?(this.getRect=function(n){var r=V({},t.apply(e,n));return"width"in r||(r.width=r.right-r.left,r.height=r.bottom-r.top),r},this):null===t?(delete this.getRect,this):this.getRect}},{key:"_backCompatOption",value:function(t,e){if(B(e)||w.object(e)){for(var n in this.options[t]=e,this._actions.map)this.options[n][t]=e;return this}return this.options[t]}},{key:"origin",value:function(t){return this._backCompatOption("origin",t)}},{key:"deltaSource",value:function(t){return"page"===t||"client"===t?(this.options.deltaSource=t,this):this.options.deltaSource}},{key:"getAllElements",value:function(){var t=this.target;return w.string(t)?Array.from(this._context.querySelectorAll(t)):w.func(t)&&t.getAllElements?t.getAllElements():w.element(t)?[t]:[]}},{key:"context",value:function(){return this._context}},{key:"inContext",value:function(t){return this._context===t.ownerDocument||M(this._context,t)}},{key:"testIgnoreAllow",value:function(t,e,n){return!this.testIgnore(t.ignoreFrom,e,n)&&this.testAllow(t.allowFrom,e,n)}},{key:"testAllow",value:function(t,e,n){return!t||!!w.element(n)&&(w.string(t)?F(n,t,e):!!w.element(t)&&M(t,n))}},{key:"testIgnore",value:function(t,e,n){return!(!t||!w.element(n))&&(w.string(t)?F(n,t,e):!!w.element(t)&&M(t,n))}},{key:"fire",value:function(t){return this.events.fire(t),this}},{key:"_onOff",value:function(t,e,n,r,i){w.object(e)&&!w.array(e)&&(r=n,n=null);var o=$(e,n,i);for(var a in o){"wheel"===a&&(a=I.wheelEvent);for(var s=0,c=o[a];s<c.length;s++){var l=c[s];ve(a,this._actions)?this.events[t===rn.On?"on":"off"](a,l):w.string(this.target)?this._scopeEvents[t===rn.On?"addDelegate":"removeDelegate"](this.target,this._context,a,l,r):this._scopeEvents[t===rn.On?"add":"remove"](this.target,a,l,r)}}return this}},{key:"on",value:function(t,e,n){return this._onOff(rn.On,t,e,n)}},{key:"off",value:function(t,e,n){return this._onOff(rn.Off,t,e,n)}},{key:"set",value:function(t){var e=this._defaults;for(var n in w.object(t)||(t={}),this.options=ge(e.base),this._actions.methodDict){var r=n,i=this._actions.methodDict[r];this.options[r]={},this.setPerAction(r,V(V({},e.perAction),e.actions[r])),this[i](t[r])}for(var o in t)"getRect"!==o?w.func(this[o])&&this[o](t[o]):this.rectChecker(t.getRect);return this}},{key:"unset",value:function(){if(w.string(this.target))for(var t in this._scopeEvents.delegatedEvents)for(var e=this._scopeEvents.delegatedEvents[t],n=e.length-1;n>=0;n--){var r=e[n],i=r.selector,o=r.context,a=r.listeners;i===this.target&&o===this._context&&e.splice(n,1);for(var s=a.length-1;s>=0;s--)this._scopeEvents.removeDelegate(this.target,this._context,t,a[s][0],a[s][1])}else this._scopeEvents.remove(this.target,"all")}}]),t}(),an=function(){function t(e){var n=this;r(this,t),this.list=[],this.selectorMap={},this.scope=void 0,this.scope=e,e.addListeners({"interactable:unset":function(t){var e=t.interactable,r=e.target,i=w.string(r)?n.selectorMap[r]:r[n.scope.id],o=yt(i,(function(t){return t===e}));i.splice(o,1)}})}return o(t,[{key:"new",value:function(t,e){e=V(e||{},{actions:this.scope.actions});var n=new this.scope.Interactable(t,e,this.scope.document,this.scope.events);return this.scope.addDocument(n._doc),this.list.push(n),w.string(t)?(this.selectorMap[t]||(this.selectorMap[t]=[]),this.selectorMap[t].push(n)):(n.target[this.scope.id]||Object.defineProperty(t,this.scope.id,{value:[],configurable:!0}),t[this.scope.id].push(n)),this.scope.fire("interactable:new",{target:t,options:e,interactable:n,win:this.scope._win}),n}},{key:"getExisting",value:function(t,e){var n=e&&e.context||this.scope.document,r=w.string(t),i=r?this.selectorMap[t]:t[this.scope.id];if(i)return bt(i,(function(e){return e._context===n&&(r||e.inContext(t))}))}},{key:"forEachMatch",value:function(t,e){for(var n=0,r=this.list;n<r.length;n++){var i=r[n],o=void 0;if((w.string(i.target)?w.element(t)&&R(t,i.target):t===i.target)&&i.inContext(t)&&(o=e(i)),void 0!==o)return o}}}]),t}();var sn=function(){function t(){var e=this;r(this,t),this.id="__interact_scope_".concat(Math.floor(100*Math.random())),this.isInitialized=!1,this.listenerMaps=[],this.browser=I,this.defaults=ge(Te),this.Eventable=Ve,this.actions={map:{},phases:{start:!0,move:!0,end:!0},methodDict:{},phaselessTypes:{}},this.interactStatic=function(t){var e=function e(n,r){var i=t.interactables.getExisting(n,r);return i||((i=t.interactables.new(n,r)).events.global=e.globalEvents),i};return e.getPointerAverage=lt,e.getTouchBBox=ut,e.getTouchDistance=pt,e.getTouchAngle=ft,e.getElementRect=L,e.getElementClientRect=Y,e.matchesSelector=R,e.closest=z,e.globalEvents={},e.version="1.10.27",e.scope=t,e.use=function(t,e){return this.scope.usePlugin(t,e),this},e.isSet=function(t,e){return!!this.scope.interactables.get(t,e&&e.context)},e.on=Nt((function(t,e,n){if(w.string(t)&&-1!==t.search(" ")&&(t=t.trim().split(/ +/)),w.array(t)){for(var r=0,i=t;r<i.length;r++){var o=i[r];this.on(o,e,n)}return this}if(w.object(t)){for(var a in t)this.on(a,t[a],e);return this}return ve(t,this.scope.actions)?this.globalEvents[t]?this.globalEvents[t].push(e):this.globalEvents[t]=[e]:this.scope.events.add(this.scope.document,t,e,{options:n}),this}),"The interact.on() method is being deprecated"),e.off=Nt((function(t,e,n){if(w.string(t)&&-1!==t.search(" ")&&(t=t.trim().split(/ +/)),w.array(t)){for(var r=0,i=t;r<i.length;r++){var o=i[r];this.off(o,e,n)}return this}if(w.object(t)){for(var a in t)this.off(a,t[a],e);return this}var s;return ve(t,this.scope.actions)?t in this.globalEvents&&-1!==(s=this.globalEvents[t].indexOf(e))&&this.globalEvents[t].splice(s,1):this.scope.events.remove(this.scope.document,t,e,n),this}),"The interact.off() method is being deprecated"),e.debug=function(){return this.scope},e.supportsTouch=function(){return I.supportsTouch},e.supportsPointerEvent=function(){return I.supportsPointerEvent},e.stop=function(){for(var t=0,e=this.scope.interactions.list;t<e.length;t++)e[t].stop();return this},e.pointerMoveTolerance=function(t){return w.number(t)?(this.scope.interactions.pointerMoveTolerance=t,this):this.scope.interactions.pointerMoveTolerance},e.addDocument=function(t,e){this.scope.addDocument(t,e)},e.removeDocument=function(t){this.scope.removeDocument(t)},e}(this),this.InteractEvent=Se,this.Interactable=void 0,this.interactables=new an(this),this._win=void 0,this.document=void 0,this.window=void 0,this.documents=[],this._plugins={list:[],map:{}},this.onWindowUnload=function(t){return e.removeDocument(t.target)};var n=this;this.Interactable=function(t){s(i,t);var e=p(i);function i(){return r(this,i),e.apply(this,arguments)}return o(i,[{key:"_defaults",get:function(){return n.defaults}},{key:"set",value:function(t){return f(c(i.prototype),"set",this).call(this,t),n.fire("interactable:set",{options:t,interactable:this}),this}},{key:"unset",value:function(){f(c(i.prototype),"unset",this).call(this);var t=n.interactables.list.indexOf(this);t<0||(n.interactables.list.splice(t,1),n.fire("interactable:unset",{interactable:this}))}}]),i}(on)}return o(t,[{key:"addListeners",value:function(t,e){this.listenerMaps.push({id:e,map:t})}},{key:"fire",value:function(t,e){for(var n=0,r=this.listenerMaps;n<r.length;n++){var i=r[n].map[t];if(i&&!1===i(e,this,t))return!1}}},{key:"init",value:function(t){return this.isInitialized?this:function(t,e){t.isInitialized=!0,w.window(e)&&m(e);return k.init(e),I.init(e),Lt.init(e),t.window=e,t.document=e.document,t.usePlugin(nn),t.usePlugin(Ue),t}(this,t)}},{key:"pluginIsInstalled",value:function(t){var e=t.id;return e?!!this._plugins.map[e]:-1!==this._plugins.list.indexOf(t)}},{key:"usePlugin",value:function(t,e){if(!this.isInitialized)return this;if(this.pluginIsInstalled(t))return this;if(t.id&&(this._plugins.map[t.id]=t),this._plugins.list.push(t),t.install&&t.install(this,e),t.listeners&&t.before){for(var n=0,r=this.listenerMaps.length,i=t.before.reduce((function(t,e){return t[e]=!0,t[cn(e)]=!0,t}),{});n<r;n++){var o=this.listenerMaps[n].id;if(o&&(i[o]||i[cn(o)]))break}this.listenerMaps.splice(n,0,{id:t.id,map:t.listeners})}else t.listeners&&this.listenerMaps.push({id:t.id,map:t.listeners});return this}},{key:"addDocument",value:function(t,e){if(-1!==this.getDocIndex(t))return!1;var n=y(t);e=e?V({},e):{},this.documents.push({doc:t,options:e}),this.events.documents.push(t),t!==this.document&&this.events.add(n,"unload",this.onWindowUnload),this.fire("scope:add-document",{doc:t,window:n,scope:this,options:e})}},{key:"removeDocument",value:function(t){var e=this.getDocIndex(t),n=y(t),r=this.documents[e].options;this.events.remove(n,"unload",this.onWindowUnload),this.documents.splice(e,1),this.events.documents.splice(e,1),this.fire("scope:remove-document",{doc:t,window:n,scope:this,options:r})}},{key:"getDocIndex",value:function(t){for(var e=0;e<this.documents.length;e++)if(this.documents[e].doc===t)return e;return-1}},{key:"getDocOptions",value:function(t){var e=this.getDocIndex(t);return-1===e?null:this.documents[e].options}},{key:"now",value:function(){return(this.window.Date||Date).now()}}]),t}();function cn(t){return t&&t.replace(/\/.*$/,"")}var ln=new sn,un=ln.interactStatic,pn="undefined"!=typeof globalThis?globalThis:window;ln.init(pn);var fn=Object.freeze({__proto__:null,edgeTarget:function(){},elements:function(){},grid:function(t){var e=[["x","y"],["left","top"],["right","bottom"],["width","height"]].filter((function(e){var n=e[0],r=e[1];return n in t||r in t})),n=function(n,r){for(var i=t.range,o=t.limits,a=void 0===o?{left:-1/0,right:1/0,top:-1/0,bottom:1/0}:o,s=t.offset,c=void 0===s?{x:0,y:0}:s,l={range:i,grid:t,x:null,y:null},u=0;u<e.length;u++){var p=e[u],f=p[0],d=p[1],h=Math.round((n-c.x)/t[f]),v=Math.round((r-c.y)/t[d]);l[f]=Math.max(a.left,Math.min(a.right,h*t[f]+c.x)),l[d]=Math.max(a.top,Math.min(a.bottom,v*t[d]+c.y))}return l};return n.grid=t,n.coordFields=e,n}}),dn={id:"snappers",install:function(t){var e=t.interactStatic;e.snappers=V(e.snappers||{},fn),e.createSnapGrid=e.snappers.grid}},hn=dn,vn={start:function(t){var n=t.state,r=t.rect,i=t.edges,o=t.pageCoords,a=n.options,s=a.ratio,c=a.enabled,l=n.options,u=l.equalDelta,p=l.modifiers;"preserve"===s&&(s=r.width/r.height),n.startCoords=V({},o),n.startRect=V({},r),n.ratio=s,n.equalDelta=u;var f=n.linkedEdges={top:i.top||i.left&&!i.bottom,left:i.left||i.top&&!i.right,bottom:i.bottom||i.right&&!i.top,right:i.right||i.bottom&&!i.left};if(n.xIsPrimaryAxis=!(!i.left&&!i.right),n.equalDelta){var d=(f.left?1:-1)*(f.top?1:-1);n.edgeSign={x:d,y:d}}else n.edgeSign={x:f.left?-1:1,y:f.top?-1:1};if(!1!==c&&V(i,f),null!=p&&p.length){var h=new me(t.interaction);h.copyFrom(t.interaction.modification),h.prepareStates(p),n.subModification=h,h.startAll(e({},t))}},set:function(t){var n=t.state,r=t.rect,i=t.coords,o=n.linkedEdges,a=V({},i),s=n.equalDelta?gn:mn;if(V(t.edges,o),s(n,n.xIsPrimaryAxis,i,r),!n.subModification)return null;var c=V({},r);H(o,c,{x:i.x-a.x,y:i.y-a.y});var l=n.subModification.setAll(e(e({},t),{},{rect:c,edges:o,pageCoords:i,prevCoords:i,prevRect:c})),u=l.delta;l.changed&&(s(n,Math.abs(u.x)>Math.abs(u.y),l.coords,l.rect),V(i,l.coords));return l.eventProps},defaults:{ratio:"preserve",equalDelta:!1,modifiers:[],enabled:!1}};function gn(t,e,n){var r=t.startCoords,i=t.edgeSign;e?n.y=r.y+(n.x-r.x)*i.y:n.x=r.x+(n.y-r.y)*i.x}function mn(t,e,n,r){var i=t.startRect,o=t.startCoords,a=t.ratio,s=t.edgeSign;if(e){var c=r.width/a;n.y=o.y+(c-i.height)*s.y}else{var l=r.height*a;n.x=o.x+(l-i.width)*s.x}}var yn=be(vn,"aspectRatio"),bn=function(){};bn._defaults={};var xn=bn;function wn(t,e,n){return w.func(t)?G(t,e.interactable,e.element,[n.x,n.y,e]):G(t,e.interactable,e.element)}var En={start:function(t){var e=t.rect,n=t.startOffset,r=t.state,i=t.interaction,o=t.pageCoords,a=r.options,s=a.elementRect,c=V({left:0,top:0,right:0,bottom:0},a.offset||{});if(e&&s){var l=wn(a.restriction,i,o);if(l){var u=l.right-l.left-e.width,p=l.bottom-l.top-e.height;u<0&&(c.left+=u,c.right+=u),p<0&&(c.top+=p,c.bottom+=p)}c.left+=n.left-e.width*s.left,c.top+=n.top-e.height*s.top,c.right+=n.right-e.width*(1-s.right),c.bottom+=n.bottom-e.height*(1-s.bottom)}r.offset=c},set:function(t){var e=t.coords,n=t.interaction,r=t.state,i=r.options,o=r.offset,a=wn(i.restriction,n,e);if(a){var s=function(t){return!t||"left"in t&&"top"in t||((t=V({},t)).left=t.x||0,t.top=t.y||0,t.right=t.right||t.left+t.width,t.bottom=t.bottom||t.top+t.height),t}(a);e.x=Math.max(Math.min(s.right-o.right,e.x),s.left+o.left),e.y=Math.max(Math.min(s.bottom-o.bottom,e.y),s.top+o.top)}},defaults:{restriction:null,elementRect:null,offset:null,endOnly:!1,enabled:!1}},Tn=be(En,"restrict"),Sn={top:1/0,left:1/0,bottom:-1/0,right:-1/0},_n={top:-1/0,left:-1/0,bottom:1/0,right:1/0};function Pn(t,e){for(var n=0,r=["top","left","bottom","right"];n<r.length;n++){var i=r[n];i in t||(t[i]=e[i])}return t}var On={noInner:Sn,noOuter:_n,start:function(t){var e,n=t.interaction,r=t.startOffset,i=t.state,o=i.options;o&&(e=N(wn(o.offset,n,n.coords.start.page))),e=e||{x:0,y:0},i.offset={top:e.y+r.top,left:e.x+r.left,bottom:e.y-r.bottom,right:e.x-r.right}},set:function(t){var e=t.coords,n=t.edges,r=t.interaction,i=t.state,o=i.offset,a=i.options;if(n){var s=V({},e),c=wn(a.inner,r,s)||{},l=wn(a.outer,r,s)||{};Pn(c,Sn),Pn(l,_n),n.top?e.y=Math.min(Math.max(l.top+o.top,s.y),c.top+o.top):n.bottom&&(e.y=Math.max(Math.min(l.bottom+o.bottom,s.y),c.bottom+o.bottom)),n.left?e.x=Math.min(Math.max(l.left+o.left,s.x),c.left+o.left):n.right&&(e.x=Math.max(Math.min(l.right+o.right,s.x),c.right+o.right))}},defaults:{inner:null,outer:null,offset:null,endOnly:!1,enabled:!1}},kn=be(On,"restrictEdges"),Dn=V({get elementRect(){return{top:0,left:0,bottom:1,right:1}},set elementRect(t){}},En.defaults),In=be({start:En.start,set:En.set,defaults:Dn},"restrictRect"),Mn={width:-1/0,height:-1/0},zn={width:1/0,height:1/0};var An=be({start:function(t){return On.start(t)},set:function(t){var e=t.interaction,n=t.state,r=t.rect,i=t.edges,o=n.options;if(i){var a=U(wn(o.min,e,t.coords))||Mn,s=U(wn(o.max,e,t.coords))||zn;n.options={endOnly:o.endOnly,inner:V({},On.noInner),outer:V({},On.noOuter)},i.top?(n.options.inner.top=r.bottom-a.height,n.options.outer.top=r.bottom-s.height):i.bottom&&(n.options.inner.bottom=r.top+a.height,n.options.outer.bottom=r.top+s.height),i.left?(n.options.inner.left=r.right-a.width,n.options.outer.left=r.right-s.width):i.right&&(n.options.inner.right=r.left+a.width,n.options.outer.right=r.left+s.width),On.set(t),n.options=o}},defaults:{min:null,max:null,endOnly:!1,enabled:!1}},"restrictSize");var Rn={start:function(t){var e,n=t.interaction,r=t.interactable,i=t.element,o=t.rect,a=t.state,s=t.startOffset,c=a.options,l=c.offsetWithOrigin?function(t){var e=t.interaction.element,n=N(G(t.state.options.origin,null,null,[e])),r=n||K(t.interactable,e,t.interaction.prepared.name);return r}(t):{x:0,y:0};if("startCoords"===c.offset)e={x:n.coords.start.page.x,y:n.coords.start.page.y};else{var u=G(c.offset,r,i,[n]);(e=N(u)||{x:0,y:0}).x+=l.x,e.y+=l.y}var p=c.relativePoints;a.offsets=o&&p&&p.length?p.map((function(t,n){return{index:n,relativePoint:t,x:s.left-o.width*t.x+e.x,y:s.top-o.height*t.y+e.y}})):[{index:0,relativePoint:null,x:e.x,y:e.y}]},set:function(t){var e=t.interaction,n=t.coords,r=t.state,i=r.options,o=r.offsets,a=K(e.interactable,e.element,e.prepared.name),s=V({},n),c=[];i.offsetWithOrigin||(s.x-=a.x,s.y-=a.y);for(var l=0,u=o;l<u.length;l++)for(var p=u[l],f=s.x-p.x,d=s.y-p.y,h=0,v=i.targets.length;h<v;h++){var g=i.targets[h],m=void 0;(m=w.func(g)?g(f,d,e._proxy,p,h):g)&&c.push({x:(w.number(m.x)?m.x:f)+p.x,y:(w.number(m.y)?m.y:d)+p.y,range:w.number(m.range)?m.range:i.range,source:g,index:h,offset:p})}for(var y={target:null,inRange:!1,distance:0,range:0,delta:{x:0,y:0}},b=0;b<c.length;b++){var x=c[b],E=x.range,T=x.x-s.x,S=x.y-s.y,_=Q(T,S),P=_<=E;E===1/0&&y.inRange&&y.range!==1/0&&(P=!1),y.target&&!(P?y.inRange&&E!==1/0?_/E<y.distance/y.range:E===1/0&&y.range!==1/0||_<y.distance:!y.inRange&&_<y.distance)||(y.target=x,y.distance=_,y.range=E,y.inRange=P,y.delta.x=T,y.delta.y=S)}return y.inRange&&(n.x=y.target.x,n.y=y.target.y),r.closest=y,y},defaults:{range:1/0,targets:null,offset:null,offsetWithOrigin:!0,origin:null,relativePoints:null,endOnly:!1,enabled:!1}},Cn=be(Rn,"snap");var jn={start:function(t){var e=t.state,n=t.edges,r=e.options;if(!n)return null;t.state={options:{targets:null,relativePoints:[{x:n.left?0:1,y:n.top?0:1}],offset:r.offset||"self",origin:{x:0,y:0},range:r.range}},e.targetFields=e.targetFields||[["width","height"],["x","y"]],Rn.start(t),e.offsets=t.state.offsets,t.state=e},set:function(t){var e=t.interaction,n=t.state,r=t.coords,i=n.options,o=n.offsets,a={x:r.x-o[0].x,y:r.y-o[0].y};n.options=V({},i),n.options.targets=[];for(var s=0,c=i.targets||[];s<c.length;s++){var l=c[s],u=void 0;if(u=w.func(l)?l(a.x,a.y,e):l){for(var p=0,f=n.targetFields;p<f.length;p++){var d=f[p],h=d[0],v=d[1];if(h in u||v in u){u.x=u[h],u.y=u[v];break}}n.options.targets.push(u)}}var g=Rn.set(t);return n.options=i,g},defaults:{range:1/0,targets:null,offset:null,endOnly:!1,enabled:!1}},Fn=be(jn,"snapSize");var Xn={aspectRatio:yn,restrictEdges:kn,restrict:Tn,restrictRect:In,restrictSize:An,snapEdges:be({start:function(t){var e=t.edges;return e?(t.state.targetFields=t.state.targetFields||[[e.left?"left":"right",e.top?"top":"bottom"]],jn.start(t)):null},set:jn.set,defaults:V(ge(jn.defaults),{targets:void 0,range:void 0,offset:{x:0,y:0}})},"snapEdges"),snap:Cn,snapSize:Fn,spring:xn,avoid:xn,transform:xn,rubberband:xn},Yn={id:"modifiers",install:function(t){var e=t.interactStatic;for(var n in t.usePlugin(Ee),t.usePlugin(hn),e.modifiers=Xn,Xn){var r=Xn[n],i=r._defaults,o=r._methods;i._methods=o,t.defaults.perAction[n]=i}}},Ln=Yn,qn=function(t){s(n,t);var e=p(n);function n(t,i,o,a,s,c){var l;if(r(this,n),tt(u(l=e.call(this,s)),o),o!==i&&tt(u(l),i),l.timeStamp=c,l.originalEvent=o,l.type=t,l.pointerId=at(i),l.pointerType=dt(i),l.target=a,l.currentTarget=null,"tap"===t){var p=s.getPointerIndex(i);l.dt=l.timeStamp-s.pointers[p].downTime;var f=l.timeStamp-s.tapTime;l.double=!!s.prevTap&&"doubletap"!==s.prevTap.type&&s.prevTap.target===l.target&&f<500}else"doubletap"===t&&(l.dt=i.timeStamp-s.tapTime,l.double=!0);return l}return o(n,[{key:"_subtractOrigin",value:function(t){var e=t.x,n=t.y;return this.pageX-=e,this.pageY-=n,this.clientX-=e,this.clientY-=n,this}},{key:"_addOrigin",value:function(t){var e=t.x,n=t.y;return this.pageX+=e,this.pageY+=n,this.clientX+=e,this.clientY+=n,this}},{key:"preventDefault",value:function(){this.originalEvent.preventDefault()}}]),n}(vt),Bn={id:"pointer-events/base",before:["inertia","modifiers","auto-start","actions"],install:function(t){t.pointerEvents=Bn,t.defaults.actions.pointerEvents=Bn.defaults,V(t.actions.phaselessTypes,Bn.types)},listeners:{"interactions:new":function(t){var e=t.interaction;e.prevTap=null,e.tapTime=0},"interactions:update-pointer":function(t){var e=t.down,n=t.pointerInfo;if(!e&&n.hold)return;n.hold={duration:1/0,timeout:null}},"interactions:move":function(t,e){var n=t.interaction,r=t.pointer,i=t.event,o=t.eventTarget;t.duplicate||n.pointerIsDown&&!n.pointerWasMoved||(n.pointerIsDown&&Gn(t),Vn({interaction:n,pointer:r,event:i,eventTarget:o,type:"move"},e))},"interactions:down":function(t,e){!function(t,e){for(var n=t.interaction,r=t.pointer,i=t.event,o=t.eventTarget,a=t.pointerIndex,s=n.pointers[a].hold,c=q(o),l={interaction:n,pointer:r,event:i,eventTarget:o,type:"hold",targets:[],path:c,node:null},u=0;u<c.length;u++){var p=c[u];l.node=p,e.fire("pointerEvents:collect-targets",l)}if(!l.targets.length)return;for(var f=1/0,d=0,h=l.targets;d<h.length;d++){var v=h[d].eventable.options.holdDuration;v<f&&(f=v)}s.duration=f,s.timeout=setTimeout((function(){Vn({interaction:n,eventTarget:o,pointer:r,event:i,type:"hold"},e)}),f)}(t,e),Vn(t,e)},"interactions:up":function(t,e){Gn(t),Vn(t,e),function(t,e){var n=t.interaction,r=t.pointer,i=t.event,o=t.eventTarget;n.pointerWasMoved||Vn({interaction:n,eventTarget:o,pointer:r,event:i,type:"tap"},e)}(t,e)},"interactions:cancel":function(t,e){Gn(t),Vn(t,e)}},PointerEvent:qn,fire:Vn,collectEventTargets:Wn,defaults:{holdDuration:600,ignoreFrom:null,allowFrom:null,origin:{x:0,y:0}},types:{down:!0,move:!0,up:!0,cancel:!0,tap:!0,doubletap:!0,hold:!0}};function Vn(t,e){var n=t.interaction,r=t.pointer,i=t.event,o=t.eventTarget,a=t.type,s=t.targets,c=void 0===s?Wn(t,e):s,l=new qn(a,r,i,o,n,e.now());e.fire("pointerEvents:new",{pointerEvent:l});for(var u={interaction:n,pointer:r,event:i,eventTarget:o,targets:c,type:a,pointerEvent:l},p=0;p<c.length;p++){var f=c[p];for(var d in f.props||{})l[d]=f.props[d];var h=K(f.eventable,f.node);if(l._subtractOrigin(h),l.eventable=f.eventable,l.currentTarget=f.node,f.eventable.fire(l),l._addOrigin(h),l.immediatePropagationStopped||l.propagationStopped&&p+1<c.length&&c[p+1].node!==l.currentTarget)break}if(e.fire("pointerEvents:fired",u),"tap"===a){var v=l.double?Vn({interaction:n,pointer:r,event:i,eventTarget:o,type:"doubletap"},e):l;n.prevTap=v,n.tapTime=v.timeStamp}return l}function Wn(t,e){var n=t.interaction,r=t.pointer,i=t.event,o=t.eventTarget,a=t.type,s=n.getPointerIndex(r),c=n.pointers[s];if("tap"===a&&(n.pointerWasMoved||!c||c.downTarget!==o))return[];for(var l=q(o),u={interaction:n,pointer:r,event:i,eventTarget:o,type:a,path:l,targets:[],node:null},p=0;p<l.length;p++){var f=l[p];u.node=f,e.fire("pointerEvents:collect-targets",u)}return"hold"===a&&(u.targets=u.targets.filter((function(t){var e,r;return t.eventable.options.holdDuration===(null==(e=n.pointers[s])||null==(r=e.hold)?void 0:r.duration)}))),u.targets}function Gn(t){var e=t.interaction,n=t.pointerIndex,r=e.pointers[n].hold;r&&r.timeout&&(clearTimeout(r.timeout),r.timeout=null)}var Nn=Object.freeze({__proto__:null,default:Bn});function Un(t){var e=t.interaction;e.holdIntervalHandle&&(clearInterval(e.holdIntervalHandle),e.holdIntervalHandle=null)}var Hn={id:"pointer-events/holdRepeat",install:function(t){t.usePlugin(Bn);var e=t.pointerEvents;e.defaults.holdRepeatInterval=0,e.types.holdrepeat=t.actions.phaselessTypes.holdrepeat=!0},listeners:["move","up","cancel","endall"].reduce((function(t,e){return t["pointerEvents:".concat(e)]=Un,t}),{"pointerEvents:new":function(t){var e=t.pointerEvent;"hold"===e.type&&(e.count=(e.count||0)+1)},"pointerEvents:fired":function(t,e){var n=t.interaction,r=t.pointerEvent,i=t.eventTarget,o=t.targets;if("hold"===r.type&&o.length){var a=o[0].eventable.options.holdRepeatInterval;a<=0||(n.holdIntervalHandle=setTimeout((function(){e.pointerEvents.fire({interaction:n,eventTarget:i,type:"hold",pointer:r,event:r},e)}),a))}}})},Kn=Hn;var $n={id:"pointer-events/interactableTargets",install:function(t){var e=t.Interactable;e.prototype.pointerEvents=function(t){return V(this.events.options,t),this};var n=e.prototype._backCompatOption;e.prototype._backCompatOption=function(t,e){var r=n.call(this,t,e);return r===this&&(this.events.options[t]=e),r}},listeners:{"pointerEvents:collect-targets":function(t,e){var n=t.targets,r=t.node,i=t.type,o=t.eventTarget;e.interactables.forEachMatch(r,(function(t){var e=t.events,a=e.options;e.types[i]&&e.types[i].length&&t.testIgnoreAllow(a,r,o)&&n.push({node:r,eventable:e,props:{interactable:t}})}))},"interactable:new":function(t){var e=t.interactable;e.events.getRect=function(t){return e.getRect(t)}},"interactable:set":function(t,e){var n=t.interactable,r=t.options;V(n.events.options,e.pointerEvents.defaults),V(n.events.options,r.pointerEvents||{})}}},Jn=$n,Qn={id:"pointer-events",install:function(t){t.usePlugin(Nn),t.usePlugin(Kn),t.usePlugin(Jn)}},Zn=Qn;var tr={id:"reflow",install:function(t){var e=t.Interactable;t.actions.phases.reflow=!0,e.prototype.reflow=function(e){return function(t,e,n){for(var r=t.getAllElements(),i=n.window.Promise,o=i?[]:null,a=function(){var a=r[s],c=t.getRect(a);if(!c)return 1;var l,u=bt(n.interactions.list,(function(n){return n.interacting()&&n.interactable===t&&n.element===a&&n.prepared.name===e.name}));if(u)u.move(),o&&(l=u._reflowPromise||new i((function(t){u._reflowResolve=t})));else{var p=U(c),f=function(t){return{coords:t,get page(){return this.coords.page},get client(){return this.coords.client},get timeStamp(){return this.coords.timeStamp},get pageX(){return this.coords.page.x},get pageY(){return this.coords.page.y},get clientX(){return this.coords.client.x},get clientY(){return this.coords.client.y},get pointerId(){return this.coords.pointerId},get target(){return this.coords.target},get type(){return this.coords.type},get pointerType(){return this.coords.pointerType},get buttons(){return this.coords.buttons},preventDefault:function(){}}}({page:{x:p.x,y:p.y},client:{x:p.x,y:p.y},timeStamp:n.now()});l=function(t,e,n,r,i){var o=t.interactions.new({pointerType:"reflow"}),a={interaction:o,event:i,pointer:i,eventTarget:n,phase:"reflow"};o.interactable=e,o.element=n,o.prevEvent=i,o.updatePointer(i,i,n,!0),nt(o.coords.delta),Ut(o.prepared,r),o._doPhase(a);var s=t.window,c=s.Promise,l=c?new c((function(t){o._reflowResolve=t})):void 0;o._reflowPromise=l,o.start(r,e,n),o._interacting?(o.move(a),o.end(i)):(o.stop(),o._reflowResolve());return o.removePointer(i,i),l}(n,t,a,e,f)}o&&o.push(l)},s=0;s<r.length&&!a();s++);return o&&i.all(o).then((function(){return t}))}(this,e,t)}},listeners:{"interactions:stop":function(t,e){var n=t.interaction;"reflow"===n.pointerType&&(n._reflowResolve&&n._reflowResolve(),function(t,e){t.splice(t.indexOf(e),1)}(e.interactions.list,n))}}},er=tr;if(un.use(he),un.use(Ce),un.use(Zn),un.use(qe),un.use(Ln),un.use(pe),un.use(Xt),un.use(Gt),un.use(er),un.default=un,"object"===( false?undefined:n(module))&&module)try{module.exports=un}catch(t){}return un.default=un,un}));
|
|
112
|
+
//# sourceMappingURL=interact.min.js.map
|
|
113
|
+
|
|
114
|
+
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__("62e4")(module)))
|
|
115
|
+
|
|
116
|
+
/***/ }),
|
|
117
|
+
|
|
118
|
+
/***/ "577e":
|
|
100
119
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
101
120
|
|
|
102
121
|
"use strict";
|
|
103
|
-
/* harmony import */ var
|
|
104
|
-
/* harmony import */ var
|
|
122
|
+
/* harmony import */ var _node_modules_mini_css_extract_plugin_dist_loader_js_ref_7_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_7_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_7_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_1_0_node_modules_vue_loader_lib_index_js_vue_loader_options_BokaHumanV2_vue_vue_type_style_index_0_id_334faf30_prod_scoped_true_lang_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("7638");
|
|
123
|
+
/* harmony import */ var _node_modules_mini_css_extract_plugin_dist_loader_js_ref_7_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_7_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_7_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_1_0_node_modules_vue_loader_lib_index_js_vue_loader_options_BokaHumanV2_vue_vue_type_style_index_0_id_334faf30_prod_scoped_true_lang_css__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_mini_css_extract_plugin_dist_loader_js_ref_7_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_7_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_7_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_1_0_node_modules_vue_loader_lib_index_js_vue_loader_options_BokaHumanV2_vue_vue_type_style_index_0_id_334faf30_prod_scoped_true_lang_css__WEBPACK_IMPORTED_MODULE_0__);
|
|
105
124
|
/* unused harmony reexport * */
|
|
106
125
|
|
|
107
126
|
|
|
127
|
+
/***/ }),
|
|
128
|
+
|
|
129
|
+
/***/ "62e4":
|
|
130
|
+
/***/ (function(module, exports) {
|
|
131
|
+
|
|
132
|
+
module.exports = function(module) {
|
|
133
|
+
if (!module.webpackPolyfill) {
|
|
134
|
+
module.deprecate = function() {};
|
|
135
|
+
module.paths = [];
|
|
136
|
+
// module.parent = undefined by default
|
|
137
|
+
if (!module.children) module.children = [];
|
|
138
|
+
Object.defineProperty(module, "loaded", {
|
|
139
|
+
enumerable: true,
|
|
140
|
+
get: function() {
|
|
141
|
+
return module.l;
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
Object.defineProperty(module, "id", {
|
|
145
|
+
enumerable: true,
|
|
146
|
+
get: function() {
|
|
147
|
+
return module.i;
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
module.webpackPolyfill = 1;
|
|
151
|
+
}
|
|
152
|
+
return module;
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
/***/ }),
|
|
157
|
+
|
|
158
|
+
/***/ "7638":
|
|
159
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
160
|
+
|
|
161
|
+
// extracted by mini-css-extract-plugin
|
|
162
|
+
|
|
163
|
+
/***/ }),
|
|
164
|
+
|
|
165
|
+
/***/ "c82c":
|
|
166
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
167
|
+
|
|
168
|
+
/*!
|
|
169
|
+
* Viewer.js v1.11.7
|
|
170
|
+
* https://fengyuanchen.github.io/viewerjs
|
|
171
|
+
*
|
|
172
|
+
* Copyright 2015-present Chen Fengyuan
|
|
173
|
+
* Released under the MIT license
|
|
174
|
+
*
|
|
175
|
+
* Date: 2024-11-24T04:32:19.116Z
|
|
176
|
+
*/
|
|
177
|
+
|
|
178
|
+
(function (global, factory) {
|
|
179
|
+
true ? module.exports = factory() :
|
|
180
|
+
undefined;
|
|
181
|
+
})(this, (function () { 'use strict';
|
|
182
|
+
|
|
183
|
+
function _classCallCheck(a, n) {
|
|
184
|
+
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
185
|
+
}
|
|
186
|
+
function _defineProperties(e, r) {
|
|
187
|
+
for (var t = 0; t < r.length; t++) {
|
|
188
|
+
var o = r[t];
|
|
189
|
+
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
function _createClass(e, r, t) {
|
|
193
|
+
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
|
|
194
|
+
writable: !1
|
|
195
|
+
}), e;
|
|
196
|
+
}
|
|
197
|
+
function _defineProperty(e, r, t) {
|
|
198
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
199
|
+
value: t,
|
|
200
|
+
enumerable: !0,
|
|
201
|
+
configurable: !0,
|
|
202
|
+
writable: !0
|
|
203
|
+
}) : e[r] = t, e;
|
|
204
|
+
}
|
|
205
|
+
function ownKeys(e, r) {
|
|
206
|
+
var t = Object.keys(e);
|
|
207
|
+
if (Object.getOwnPropertySymbols) {
|
|
208
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
209
|
+
r && (o = o.filter(function (r) {
|
|
210
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
211
|
+
})), t.push.apply(t, o);
|
|
212
|
+
}
|
|
213
|
+
return t;
|
|
214
|
+
}
|
|
215
|
+
function _objectSpread2(e) {
|
|
216
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
217
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
218
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
|
|
219
|
+
_defineProperty(e, r, t[r]);
|
|
220
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
221
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
return e;
|
|
225
|
+
}
|
|
226
|
+
function _toPrimitive(t, r) {
|
|
227
|
+
if ("object" != typeof t || !t) return t;
|
|
228
|
+
var e = t[Symbol.toPrimitive];
|
|
229
|
+
if (void 0 !== e) {
|
|
230
|
+
var i = e.call(t, r || "default");
|
|
231
|
+
if ("object" != typeof i) return i;
|
|
232
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
233
|
+
}
|
|
234
|
+
return ("string" === r ? String : Number)(t);
|
|
235
|
+
}
|
|
236
|
+
function _toPropertyKey(t) {
|
|
237
|
+
var i = _toPrimitive(t, "string");
|
|
238
|
+
return "symbol" == typeof i ? i : i + "";
|
|
239
|
+
}
|
|
240
|
+
function _typeof(o) {
|
|
241
|
+
"@babel/helpers - typeof";
|
|
242
|
+
|
|
243
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
244
|
+
return typeof o;
|
|
245
|
+
} : function (o) {
|
|
246
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
247
|
+
}, _typeof(o);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
var DEFAULTS = {
|
|
251
|
+
/**
|
|
252
|
+
* Enable a modal backdrop, specify `static` for a backdrop
|
|
253
|
+
* which doesn't close the modal on click.
|
|
254
|
+
* @type {boolean}
|
|
255
|
+
*/
|
|
256
|
+
backdrop: true,
|
|
257
|
+
/**
|
|
258
|
+
* Show the button on the top-right of the viewer.
|
|
259
|
+
* @type {boolean}
|
|
260
|
+
*/
|
|
261
|
+
button: true,
|
|
262
|
+
/**
|
|
263
|
+
* Show the navbar.
|
|
264
|
+
* @type {boolean | number}
|
|
265
|
+
*/
|
|
266
|
+
navbar: true,
|
|
267
|
+
/**
|
|
268
|
+
* Specify the visibility and the content of the title.
|
|
269
|
+
* @type {boolean | number | Function | Array}
|
|
270
|
+
*/
|
|
271
|
+
title: true,
|
|
272
|
+
/**
|
|
273
|
+
* Show the toolbar.
|
|
274
|
+
* @type {boolean | number | Object}
|
|
275
|
+
*/
|
|
276
|
+
toolbar: true,
|
|
277
|
+
/**
|
|
278
|
+
* Custom class name(s) to add to the viewer's root element.
|
|
279
|
+
* @type {string}
|
|
280
|
+
*/
|
|
281
|
+
className: '',
|
|
282
|
+
/**
|
|
283
|
+
* Define where to put the viewer in modal mode.
|
|
284
|
+
* @type {string | Element}
|
|
285
|
+
*/
|
|
286
|
+
container: 'body',
|
|
287
|
+
/**
|
|
288
|
+
* Filter the images for viewing. Return true if the image is viewable.
|
|
289
|
+
* @type {Function}
|
|
290
|
+
*/
|
|
291
|
+
filter: null,
|
|
292
|
+
/**
|
|
293
|
+
* Enable to request fullscreen when play.
|
|
294
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/API/FullscreenOptions}
|
|
295
|
+
* @type {boolean|FullscreenOptions}
|
|
296
|
+
*/
|
|
297
|
+
fullscreen: true,
|
|
298
|
+
/**
|
|
299
|
+
* Define the extra attributes to inherit from the original image.
|
|
300
|
+
* @type {Array}
|
|
301
|
+
*/
|
|
302
|
+
inheritedAttributes: ['crossOrigin', 'decoding', 'isMap', 'loading', 'referrerPolicy', 'sizes', 'srcset', 'useMap'],
|
|
303
|
+
/**
|
|
304
|
+
* Define the initial coverage of the viewing image.
|
|
305
|
+
* @type {number}
|
|
306
|
+
*/
|
|
307
|
+
initialCoverage: 0.9,
|
|
308
|
+
/**
|
|
309
|
+
* Define the initial index of the image for viewing.
|
|
310
|
+
* @type {number}
|
|
311
|
+
*/
|
|
312
|
+
initialViewIndex: 0,
|
|
313
|
+
/**
|
|
314
|
+
* Enable inline mode.
|
|
315
|
+
* @type {boolean}
|
|
316
|
+
*/
|
|
317
|
+
inline: false,
|
|
318
|
+
/**
|
|
319
|
+
* The amount of time to delay between automatically cycling an image when playing.
|
|
320
|
+
* @type {number}
|
|
321
|
+
*/
|
|
322
|
+
interval: 5000,
|
|
323
|
+
/**
|
|
324
|
+
* Enable keyboard support.
|
|
325
|
+
* @type {boolean}
|
|
326
|
+
*/
|
|
327
|
+
keyboard: true,
|
|
328
|
+
/**
|
|
329
|
+
* Focus the viewer when initialized.
|
|
330
|
+
* @type {boolean}
|
|
331
|
+
*/
|
|
332
|
+
focus: true,
|
|
333
|
+
/**
|
|
334
|
+
* Indicate if show a loading spinner when load image or not.
|
|
335
|
+
* @type {boolean}
|
|
336
|
+
*/
|
|
337
|
+
loading: true,
|
|
338
|
+
/**
|
|
339
|
+
* Indicate if enable loop viewing or not.
|
|
340
|
+
* @type {boolean}
|
|
341
|
+
*/
|
|
342
|
+
loop: true,
|
|
343
|
+
/**
|
|
344
|
+
* Min width of the viewer in inline mode.
|
|
345
|
+
* @type {number}
|
|
346
|
+
*/
|
|
347
|
+
minWidth: 200,
|
|
348
|
+
/**
|
|
349
|
+
* Min height of the viewer in inline mode.
|
|
350
|
+
* @type {number}
|
|
351
|
+
*/
|
|
352
|
+
minHeight: 100,
|
|
353
|
+
/**
|
|
354
|
+
* Enable to move the image.
|
|
355
|
+
* @type {boolean}
|
|
356
|
+
*/
|
|
357
|
+
movable: true,
|
|
358
|
+
/**
|
|
359
|
+
* Enable to rotate the image.
|
|
360
|
+
* @type {boolean}
|
|
361
|
+
*/
|
|
362
|
+
rotatable: true,
|
|
363
|
+
/**
|
|
364
|
+
* Enable to scale the image.
|
|
365
|
+
* @type {boolean}
|
|
366
|
+
*/
|
|
367
|
+
scalable: true,
|
|
368
|
+
/**
|
|
369
|
+
* Enable to zoom the image.
|
|
370
|
+
* @type {boolean}
|
|
371
|
+
*/
|
|
372
|
+
zoomable: true,
|
|
373
|
+
/**
|
|
374
|
+
* Enable to zoom the current image by dragging on the touch screen.
|
|
375
|
+
* @type {boolean}
|
|
376
|
+
*/
|
|
377
|
+
zoomOnTouch: true,
|
|
378
|
+
/**
|
|
379
|
+
* Enable to zoom the image by wheeling mouse.
|
|
380
|
+
* @type {boolean}
|
|
381
|
+
*/
|
|
382
|
+
zoomOnWheel: true,
|
|
383
|
+
/**
|
|
384
|
+
* Enable to slide to the next or previous image by swiping on the touch screen.
|
|
385
|
+
* @type {boolean}
|
|
386
|
+
*/
|
|
387
|
+
slideOnTouch: true,
|
|
388
|
+
/**
|
|
389
|
+
* Indicate if toggle the image size between its natural size
|
|
390
|
+
* and initial size when double click on the image or not.
|
|
391
|
+
* @type {boolean}
|
|
392
|
+
*/
|
|
393
|
+
toggleOnDblclick: true,
|
|
394
|
+
/**
|
|
395
|
+
* Show the tooltip with image ratio (percentage) when zoom in or zoom out.
|
|
396
|
+
* @type {boolean}
|
|
397
|
+
*/
|
|
398
|
+
tooltip: true,
|
|
399
|
+
/**
|
|
400
|
+
* Enable CSS3 Transition for some special elements.
|
|
401
|
+
* @type {boolean}
|
|
402
|
+
*/
|
|
403
|
+
transition: true,
|
|
404
|
+
/**
|
|
405
|
+
* Define the CSS `z-index` value of viewer in modal mode.
|
|
406
|
+
* @type {number}
|
|
407
|
+
*/
|
|
408
|
+
zIndex: 2015,
|
|
409
|
+
/**
|
|
410
|
+
* Define the CSS `z-index` value of viewer in inline mode.
|
|
411
|
+
* @type {number}
|
|
412
|
+
*/
|
|
413
|
+
zIndexInline: 0,
|
|
414
|
+
/**
|
|
415
|
+
* Define the ratio when zoom the image by wheeling mouse.
|
|
416
|
+
* @type {number}
|
|
417
|
+
*/
|
|
418
|
+
zoomRatio: 0.1,
|
|
419
|
+
/**
|
|
420
|
+
* Define the min ratio of the image when zoom out.
|
|
421
|
+
* @type {number}
|
|
422
|
+
*/
|
|
423
|
+
minZoomRatio: 0.01,
|
|
424
|
+
/**
|
|
425
|
+
* Define the max ratio of the image when zoom in.
|
|
426
|
+
* @type {number}
|
|
427
|
+
*/
|
|
428
|
+
maxZoomRatio: 100,
|
|
429
|
+
/**
|
|
430
|
+
* Define where to get the original image URL for viewing.
|
|
431
|
+
* @type {string | Function}
|
|
432
|
+
*/
|
|
433
|
+
url: 'src',
|
|
434
|
+
/**
|
|
435
|
+
* Event shortcuts.
|
|
436
|
+
* @type {Function}
|
|
437
|
+
*/
|
|
438
|
+
ready: null,
|
|
439
|
+
show: null,
|
|
440
|
+
shown: null,
|
|
441
|
+
hide: null,
|
|
442
|
+
hidden: null,
|
|
443
|
+
view: null,
|
|
444
|
+
viewed: null,
|
|
445
|
+
move: null,
|
|
446
|
+
moved: null,
|
|
447
|
+
rotate: null,
|
|
448
|
+
rotated: null,
|
|
449
|
+
scale: null,
|
|
450
|
+
scaled: null,
|
|
451
|
+
zoom: null,
|
|
452
|
+
zoomed: null,
|
|
453
|
+
play: null,
|
|
454
|
+
stop: null
|
|
455
|
+
};
|
|
456
|
+
|
|
457
|
+
var TEMPLATE = '<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>';
|
|
458
|
+
|
|
459
|
+
var IS_BROWSER = typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
460
|
+
var WINDOW = IS_BROWSER ? window : {};
|
|
461
|
+
var IS_TOUCH_DEVICE = IS_BROWSER && WINDOW.document.documentElement ? 'ontouchstart' in WINDOW.document.documentElement : false;
|
|
462
|
+
var HAS_POINTER_EVENT = IS_BROWSER ? 'PointerEvent' in WINDOW : false;
|
|
463
|
+
var NAMESPACE = 'viewer';
|
|
464
|
+
|
|
465
|
+
// Actions
|
|
466
|
+
var ACTION_MOVE = 'move';
|
|
467
|
+
var ACTION_SWITCH = 'switch';
|
|
468
|
+
var ACTION_ZOOM = 'zoom';
|
|
469
|
+
|
|
470
|
+
// Classes
|
|
471
|
+
var CLASS_ACTIVE = "".concat(NAMESPACE, "-active");
|
|
472
|
+
var CLASS_CLOSE = "".concat(NAMESPACE, "-close");
|
|
473
|
+
var CLASS_FADE = "".concat(NAMESPACE, "-fade");
|
|
474
|
+
var CLASS_FIXED = "".concat(NAMESPACE, "-fixed");
|
|
475
|
+
var CLASS_FULLSCREEN = "".concat(NAMESPACE, "-fullscreen");
|
|
476
|
+
var CLASS_FULLSCREEN_EXIT = "".concat(NAMESPACE, "-fullscreen-exit");
|
|
477
|
+
var CLASS_HIDE = "".concat(NAMESPACE, "-hide");
|
|
478
|
+
var CLASS_HIDE_MD_DOWN = "".concat(NAMESPACE, "-hide-md-down");
|
|
479
|
+
var CLASS_HIDE_SM_DOWN = "".concat(NAMESPACE, "-hide-sm-down");
|
|
480
|
+
var CLASS_HIDE_XS_DOWN = "".concat(NAMESPACE, "-hide-xs-down");
|
|
481
|
+
var CLASS_IN = "".concat(NAMESPACE, "-in");
|
|
482
|
+
var CLASS_INVISIBLE = "".concat(NAMESPACE, "-invisible");
|
|
483
|
+
var CLASS_LOADING = "".concat(NAMESPACE, "-loading");
|
|
484
|
+
var CLASS_MOVE = "".concat(NAMESPACE, "-move");
|
|
485
|
+
var CLASS_OPEN = "".concat(NAMESPACE, "-open");
|
|
486
|
+
var CLASS_SHOW = "".concat(NAMESPACE, "-show");
|
|
487
|
+
var CLASS_TRANSITION = "".concat(NAMESPACE, "-transition");
|
|
488
|
+
|
|
489
|
+
// Native events
|
|
490
|
+
var EVENT_CLICK = 'click';
|
|
491
|
+
var EVENT_DBLCLICK = 'dblclick';
|
|
492
|
+
var EVENT_DRAG_START = 'dragstart';
|
|
493
|
+
var EVENT_FOCUSIN = 'focusin';
|
|
494
|
+
var EVENT_KEY_DOWN = 'keydown';
|
|
495
|
+
var EVENT_LOAD = 'load';
|
|
496
|
+
var EVENT_ERROR = 'error';
|
|
497
|
+
var EVENT_TOUCH_END = IS_TOUCH_DEVICE ? 'touchend touchcancel' : 'mouseup';
|
|
498
|
+
var EVENT_TOUCH_MOVE = IS_TOUCH_DEVICE ? 'touchmove' : 'mousemove';
|
|
499
|
+
var EVENT_TOUCH_START = IS_TOUCH_DEVICE ? 'touchstart' : 'mousedown';
|
|
500
|
+
var EVENT_POINTER_DOWN = HAS_POINTER_EVENT ? 'pointerdown' : EVENT_TOUCH_START;
|
|
501
|
+
var EVENT_POINTER_MOVE = HAS_POINTER_EVENT ? 'pointermove' : EVENT_TOUCH_MOVE;
|
|
502
|
+
var EVENT_POINTER_UP = HAS_POINTER_EVENT ? 'pointerup pointercancel' : EVENT_TOUCH_END;
|
|
503
|
+
var EVENT_RESIZE = 'resize';
|
|
504
|
+
var EVENT_TRANSITION_END = 'transitionend';
|
|
505
|
+
var EVENT_WHEEL = 'wheel';
|
|
506
|
+
|
|
507
|
+
// Custom events
|
|
508
|
+
var EVENT_READY = 'ready';
|
|
509
|
+
var EVENT_SHOW = 'show';
|
|
510
|
+
var EVENT_SHOWN = 'shown';
|
|
511
|
+
var EVENT_HIDE = 'hide';
|
|
512
|
+
var EVENT_HIDDEN = 'hidden';
|
|
513
|
+
var EVENT_VIEW = 'view';
|
|
514
|
+
var EVENT_VIEWED = 'viewed';
|
|
515
|
+
var EVENT_MOVE = 'move';
|
|
516
|
+
var EVENT_MOVED = 'moved';
|
|
517
|
+
var EVENT_ROTATE = 'rotate';
|
|
518
|
+
var EVENT_ROTATED = 'rotated';
|
|
519
|
+
var EVENT_SCALE = 'scale';
|
|
520
|
+
var EVENT_SCALED = 'scaled';
|
|
521
|
+
var EVENT_ZOOM = 'zoom';
|
|
522
|
+
var EVENT_ZOOMED = 'zoomed';
|
|
523
|
+
var EVENT_PLAY = 'play';
|
|
524
|
+
var EVENT_STOP = 'stop';
|
|
525
|
+
|
|
526
|
+
// Data keys
|
|
527
|
+
var DATA_ACTION = "".concat(NAMESPACE, "Action");
|
|
528
|
+
|
|
529
|
+
// RegExps
|
|
530
|
+
var REGEXP_SPACES = /\s\s*/;
|
|
531
|
+
|
|
532
|
+
// Misc
|
|
533
|
+
var BUTTONS = ['zoom-in', 'zoom-out', 'one-to-one', 'reset', 'prev', 'play', 'next', 'rotate-left', 'rotate-right', 'flip-horizontal', 'flip-vertical'];
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* Check if the given value is a string.
|
|
537
|
+
* @param {*} value - The value to check.
|
|
538
|
+
* @returns {boolean} Returns `true` if the given value is a string, else `false`.
|
|
539
|
+
*/
|
|
540
|
+
function isString(value) {
|
|
541
|
+
return typeof value === 'string';
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Check if the given value is not a number.
|
|
546
|
+
*/
|
|
547
|
+
var isNaN = Number.isNaN || WINDOW.isNaN;
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* Check if the given value is a number.
|
|
551
|
+
* @param {*} value - The value to check.
|
|
552
|
+
* @returns {boolean} Returns `true` if the given value is a number, else `false`.
|
|
553
|
+
*/
|
|
554
|
+
function isNumber(value) {
|
|
555
|
+
return typeof value === 'number' && !isNaN(value);
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* Check if the given value is undefined.
|
|
560
|
+
* @param {*} value - The value to check.
|
|
561
|
+
* @returns {boolean} Returns `true` if the given value is undefined, else `false`.
|
|
562
|
+
*/
|
|
563
|
+
function isUndefined(value) {
|
|
564
|
+
return typeof value === 'undefined';
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* Check if the given value is an object.
|
|
569
|
+
* @param {*} value - The value to check.
|
|
570
|
+
* @returns {boolean} Returns `true` if the given value is an object, else `false`.
|
|
571
|
+
*/
|
|
572
|
+
function isObject(value) {
|
|
573
|
+
return _typeof(value) === 'object' && value !== null;
|
|
574
|
+
}
|
|
575
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* Check if the given value is a plain object.
|
|
579
|
+
* @param {*} value - The value to check.
|
|
580
|
+
* @returns {boolean} Returns `true` if the given value is a plain object, else `false`.
|
|
581
|
+
*/
|
|
582
|
+
function isPlainObject(value) {
|
|
583
|
+
if (!isObject(value)) {
|
|
584
|
+
return false;
|
|
585
|
+
}
|
|
586
|
+
try {
|
|
587
|
+
var _constructor = value.constructor;
|
|
588
|
+
var prototype = _constructor.prototype;
|
|
589
|
+
return _constructor && prototype && hasOwnProperty.call(prototype, 'isPrototypeOf');
|
|
590
|
+
} catch (error) {
|
|
591
|
+
return false;
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* Check if the given value is a function.
|
|
597
|
+
* @param {*} value - The value to check.
|
|
598
|
+
* @returns {boolean} Returns `true` if the given value is a function, else `false`.
|
|
599
|
+
*/
|
|
600
|
+
function isFunction(value) {
|
|
601
|
+
return typeof value === 'function';
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* Iterate the given data.
|
|
606
|
+
* @param {*} data - The data to iterate.
|
|
607
|
+
* @param {Function} callback - The process function for each element.
|
|
608
|
+
* @returns {*} The original data.
|
|
609
|
+
*/
|
|
610
|
+
function forEach(data, callback) {
|
|
611
|
+
if (data && isFunction(callback)) {
|
|
612
|
+
if (Array.isArray(data) || isNumber(data.length) /* array-like */) {
|
|
613
|
+
var length = data.length;
|
|
614
|
+
var i;
|
|
615
|
+
for (i = 0; i < length; i += 1) {
|
|
616
|
+
if (callback.call(data, data[i], i, data) === false) {
|
|
617
|
+
break;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
} else if (isObject(data)) {
|
|
621
|
+
Object.keys(data).forEach(function (key) {
|
|
622
|
+
callback.call(data, data[key], key, data);
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
return data;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
/**
|
|
630
|
+
* Extend the given object.
|
|
631
|
+
* @param {*} obj - The object to be extended.
|
|
632
|
+
* @param {*} args - The rest objects which will be merged to the first object.
|
|
633
|
+
* @returns {Object} The extended object.
|
|
634
|
+
*/
|
|
635
|
+
var assign = Object.assign || function assign(obj) {
|
|
636
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
637
|
+
args[_key - 1] = arguments[_key];
|
|
638
|
+
}
|
|
639
|
+
if (isObject(obj) && args.length > 0) {
|
|
640
|
+
args.forEach(function (arg) {
|
|
641
|
+
if (isObject(arg)) {
|
|
642
|
+
Object.keys(arg).forEach(function (key) {
|
|
643
|
+
obj[key] = arg[key];
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
return obj;
|
|
649
|
+
};
|
|
650
|
+
var REGEXP_SUFFIX = /^(?:width|height|left|top|marginLeft|marginTop)$/;
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* Apply styles to the given element.
|
|
654
|
+
* @param {Element} element - The target element.
|
|
655
|
+
* @param {Object} styles - The styles for applying.
|
|
656
|
+
*/
|
|
657
|
+
function setStyle(element, styles) {
|
|
658
|
+
var style = element.style;
|
|
659
|
+
forEach(styles, function (value, property) {
|
|
660
|
+
if (REGEXP_SUFFIX.test(property) && isNumber(value)) {
|
|
661
|
+
value += 'px';
|
|
662
|
+
}
|
|
663
|
+
style[property] = value;
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
/**
|
|
668
|
+
* Escape a string for using in HTML.
|
|
669
|
+
* @param {String} value - The string to escape.
|
|
670
|
+
* @returns {String} Returns the escaped string.
|
|
671
|
+
*/
|
|
672
|
+
function escapeHTMLEntities(value) {
|
|
673
|
+
return isString(value) ? value.replace(/&(?!amp;|quot;|#39;|lt;|gt;)/g, '&').replace(/"/g, '"').replace(/'/g, ''').replace(/</g, '<').replace(/>/g, '>') : value;
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
/**
|
|
677
|
+
* Check if the given element has a special class.
|
|
678
|
+
* @param {Element} element - The element to check.
|
|
679
|
+
* @param {string} value - The class to search.
|
|
680
|
+
* @returns {boolean} Returns `true` if the special class was found.
|
|
681
|
+
*/
|
|
682
|
+
function hasClass(element, value) {
|
|
683
|
+
if (!element || !value) {
|
|
684
|
+
return false;
|
|
685
|
+
}
|
|
686
|
+
return element.classList ? element.classList.contains(value) : element.className.indexOf(value) > -1;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
/**
|
|
690
|
+
* Add classes to the given element.
|
|
691
|
+
* @param {Element} element - The target element.
|
|
692
|
+
* @param {string} value - The classes to be added.
|
|
693
|
+
*/
|
|
694
|
+
function addClass(element, value) {
|
|
695
|
+
if (!element || !value) {
|
|
696
|
+
return;
|
|
697
|
+
}
|
|
698
|
+
if (isNumber(element.length)) {
|
|
699
|
+
forEach(element, function (elem) {
|
|
700
|
+
addClass(elem, value);
|
|
701
|
+
});
|
|
702
|
+
return;
|
|
703
|
+
}
|
|
704
|
+
if (element.classList) {
|
|
705
|
+
element.classList.add(value);
|
|
706
|
+
return;
|
|
707
|
+
}
|
|
708
|
+
var className = element.className.trim();
|
|
709
|
+
if (!className) {
|
|
710
|
+
element.className = value;
|
|
711
|
+
} else if (className.indexOf(value) < 0) {
|
|
712
|
+
element.className = "".concat(className, " ").concat(value);
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* Remove classes from the given element.
|
|
718
|
+
* @param {Element} element - The target element.
|
|
719
|
+
* @param {string} value - The classes to be removed.
|
|
720
|
+
*/
|
|
721
|
+
function removeClass(element, value) {
|
|
722
|
+
if (!element || !value) {
|
|
723
|
+
return;
|
|
724
|
+
}
|
|
725
|
+
if (isNumber(element.length)) {
|
|
726
|
+
forEach(element, function (elem) {
|
|
727
|
+
removeClass(elem, value);
|
|
728
|
+
});
|
|
729
|
+
return;
|
|
730
|
+
}
|
|
731
|
+
if (element.classList) {
|
|
732
|
+
element.classList.remove(value);
|
|
733
|
+
return;
|
|
734
|
+
}
|
|
735
|
+
if (element.className.indexOf(value) >= 0) {
|
|
736
|
+
element.className = element.className.replace(value, '');
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
/**
|
|
741
|
+
* Add or remove classes from the given element.
|
|
742
|
+
* @param {Element} element - The target element.
|
|
743
|
+
* @param {string} value - The classes to be toggled.
|
|
744
|
+
* @param {boolean} added - Add only.
|
|
745
|
+
*/
|
|
746
|
+
function toggleClass(element, value, added) {
|
|
747
|
+
if (!value) {
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
if (isNumber(element.length)) {
|
|
751
|
+
forEach(element, function (elem) {
|
|
752
|
+
toggleClass(elem, value, added);
|
|
753
|
+
});
|
|
754
|
+
return;
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
// IE10-11 doesn't support the second parameter of `classList.toggle`
|
|
758
|
+
if (added) {
|
|
759
|
+
addClass(element, value);
|
|
760
|
+
} else {
|
|
761
|
+
removeClass(element, value);
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
var REGEXP_HYPHENATE = /([a-z\d])([A-Z])/g;
|
|
765
|
+
|
|
766
|
+
/**
|
|
767
|
+
* Transform the given string from camelCase to kebab-case
|
|
768
|
+
* @param {string} value - The value to transform.
|
|
769
|
+
* @returns {string} The transformed value.
|
|
770
|
+
*/
|
|
771
|
+
function hyphenate(value) {
|
|
772
|
+
return value.replace(REGEXP_HYPHENATE, '$1-$2').toLowerCase();
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
/**
|
|
776
|
+
* Get data from the given element.
|
|
777
|
+
* @param {Element} element - The target element.
|
|
778
|
+
* @param {string} name - The data key to get.
|
|
779
|
+
* @returns {string} The data value.
|
|
780
|
+
*/
|
|
781
|
+
function getData(element, name) {
|
|
782
|
+
if (isObject(element[name])) {
|
|
783
|
+
return element[name];
|
|
784
|
+
}
|
|
785
|
+
if (element.dataset) {
|
|
786
|
+
return element.dataset[name];
|
|
787
|
+
}
|
|
788
|
+
return element.getAttribute("data-".concat(hyphenate(name)));
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
/**
|
|
792
|
+
* Set data to the given element.
|
|
793
|
+
* @param {Element} element - The target element.
|
|
794
|
+
* @param {string} name - The data key to set.
|
|
795
|
+
* @param {string} data - The data value.
|
|
796
|
+
*/
|
|
797
|
+
function setData(element, name, data) {
|
|
798
|
+
if (isObject(data)) {
|
|
799
|
+
element[name] = data;
|
|
800
|
+
} else if (element.dataset) {
|
|
801
|
+
element.dataset[name] = data;
|
|
802
|
+
} else {
|
|
803
|
+
element.setAttribute("data-".concat(hyphenate(name)), data);
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
var onceSupported = function () {
|
|
807
|
+
var supported = false;
|
|
808
|
+
if (IS_BROWSER) {
|
|
809
|
+
var once = false;
|
|
810
|
+
var listener = function listener() {};
|
|
811
|
+
var options = Object.defineProperty({}, 'once', {
|
|
812
|
+
get: function get() {
|
|
813
|
+
supported = true;
|
|
814
|
+
return once;
|
|
815
|
+
},
|
|
816
|
+
/**
|
|
817
|
+
* This setter can fix a `TypeError` in strict mode
|
|
818
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Getter_only}
|
|
819
|
+
* @param {boolean} value - The value to set
|
|
820
|
+
*/
|
|
821
|
+
set: function set(value) {
|
|
822
|
+
once = value;
|
|
823
|
+
}
|
|
824
|
+
});
|
|
825
|
+
WINDOW.addEventListener('test', listener, options);
|
|
826
|
+
WINDOW.removeEventListener('test', listener, options);
|
|
827
|
+
}
|
|
828
|
+
return supported;
|
|
829
|
+
}();
|
|
830
|
+
|
|
831
|
+
/**
|
|
832
|
+
* Remove event listener from the target element.
|
|
833
|
+
* @param {Element} element - The event target.
|
|
834
|
+
* @param {string} type - The event type(s).
|
|
835
|
+
* @param {Function} listener - The event listener.
|
|
836
|
+
* @param {Object} options - The event options.
|
|
837
|
+
*/
|
|
838
|
+
function removeListener(element, type, listener) {
|
|
839
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
840
|
+
var handler = listener;
|
|
841
|
+
type.trim().split(REGEXP_SPACES).forEach(function (event) {
|
|
842
|
+
if (!onceSupported) {
|
|
843
|
+
var listeners = element.listeners;
|
|
844
|
+
if (listeners && listeners[event] && listeners[event][listener]) {
|
|
845
|
+
handler = listeners[event][listener];
|
|
846
|
+
delete listeners[event][listener];
|
|
847
|
+
if (Object.keys(listeners[event]).length === 0) {
|
|
848
|
+
delete listeners[event];
|
|
849
|
+
}
|
|
850
|
+
if (Object.keys(listeners).length === 0) {
|
|
851
|
+
delete element.listeners;
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
element.removeEventListener(event, handler, options);
|
|
856
|
+
});
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
/**
|
|
860
|
+
* Add event listener to the target element.
|
|
861
|
+
* @param {Element} element - The event target.
|
|
862
|
+
* @param {string} type - The event type(s).
|
|
863
|
+
* @param {Function} listener - The event listener.
|
|
864
|
+
* @param {Object} options - The event options.
|
|
865
|
+
*/
|
|
866
|
+
function addListener(element, type, listener) {
|
|
867
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
868
|
+
var _handler = listener;
|
|
869
|
+
type.trim().split(REGEXP_SPACES).forEach(function (event) {
|
|
870
|
+
if (options.once && !onceSupported) {
|
|
871
|
+
var _element$listeners = element.listeners,
|
|
872
|
+
listeners = _element$listeners === void 0 ? {} : _element$listeners;
|
|
873
|
+
_handler = function handler() {
|
|
874
|
+
delete listeners[event][listener];
|
|
875
|
+
element.removeEventListener(event, _handler, options);
|
|
876
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
877
|
+
args[_key2] = arguments[_key2];
|
|
878
|
+
}
|
|
879
|
+
listener.apply(element, args);
|
|
880
|
+
};
|
|
881
|
+
if (!listeners[event]) {
|
|
882
|
+
listeners[event] = {};
|
|
883
|
+
}
|
|
884
|
+
if (listeners[event][listener]) {
|
|
885
|
+
element.removeEventListener(event, listeners[event][listener], options);
|
|
886
|
+
}
|
|
887
|
+
listeners[event][listener] = _handler;
|
|
888
|
+
element.listeners = listeners;
|
|
889
|
+
}
|
|
890
|
+
element.addEventListener(event, _handler, options);
|
|
891
|
+
});
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
/**
|
|
895
|
+
* Dispatch event on the target element.
|
|
896
|
+
* @param {Element} element - The event target.
|
|
897
|
+
* @param {string} type - The event type(s).
|
|
898
|
+
* @param {Object} data - The additional event data.
|
|
899
|
+
* @param {Object} options - The additional event options.
|
|
900
|
+
* @returns {boolean} Indicate if the event is default prevented or not.
|
|
901
|
+
*/
|
|
902
|
+
function dispatchEvent(element, type, data, options) {
|
|
903
|
+
var event;
|
|
904
|
+
|
|
905
|
+
// Event and CustomEvent on IE9-11 are global objects, not constructors
|
|
906
|
+
if (isFunction(Event) && isFunction(CustomEvent)) {
|
|
907
|
+
event = new CustomEvent(type, _objectSpread2({
|
|
908
|
+
bubbles: true,
|
|
909
|
+
cancelable: true,
|
|
910
|
+
detail: data
|
|
911
|
+
}, options));
|
|
912
|
+
} else {
|
|
913
|
+
event = document.createEvent('CustomEvent');
|
|
914
|
+
event.initCustomEvent(type, true, true, data);
|
|
915
|
+
}
|
|
916
|
+
return element.dispatchEvent(event);
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
/**
|
|
920
|
+
* Get the offset base on the document.
|
|
921
|
+
* @param {Element} element - The target element.
|
|
922
|
+
* @returns {Object} The offset data.
|
|
923
|
+
*/
|
|
924
|
+
function getOffset(element) {
|
|
925
|
+
var box = element.getBoundingClientRect();
|
|
926
|
+
return {
|
|
927
|
+
left: box.left + (window.pageXOffset - document.documentElement.clientLeft),
|
|
928
|
+
top: box.top + (window.pageYOffset - document.documentElement.clientTop)
|
|
929
|
+
};
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
/**
|
|
933
|
+
* Get transforms base on the given object.
|
|
934
|
+
* @param {Object} obj - The target object.
|
|
935
|
+
* @returns {string} A string contains transform values.
|
|
936
|
+
*/
|
|
937
|
+
function getTransforms(_ref) {
|
|
938
|
+
var rotate = _ref.rotate,
|
|
939
|
+
scaleX = _ref.scaleX,
|
|
940
|
+
scaleY = _ref.scaleY,
|
|
941
|
+
translateX = _ref.translateX,
|
|
942
|
+
translateY = _ref.translateY;
|
|
943
|
+
var values = [];
|
|
944
|
+
if (isNumber(translateX) && translateX !== 0) {
|
|
945
|
+
values.push("translateX(".concat(translateX, "px)"));
|
|
946
|
+
}
|
|
947
|
+
if (isNumber(translateY) && translateY !== 0) {
|
|
948
|
+
values.push("translateY(".concat(translateY, "px)"));
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
// Rotate should come first before scale to match orientation transform
|
|
952
|
+
if (isNumber(rotate) && rotate !== 0) {
|
|
953
|
+
values.push("rotate(".concat(rotate, "deg)"));
|
|
954
|
+
}
|
|
955
|
+
if (isNumber(scaleX) && scaleX !== 1) {
|
|
956
|
+
values.push("scaleX(".concat(scaleX, ")"));
|
|
957
|
+
}
|
|
958
|
+
if (isNumber(scaleY) && scaleY !== 1) {
|
|
959
|
+
values.push("scaleY(".concat(scaleY, ")"));
|
|
960
|
+
}
|
|
961
|
+
var transform = values.length ? values.join(' ') : 'none';
|
|
962
|
+
return {
|
|
963
|
+
WebkitTransform: transform,
|
|
964
|
+
msTransform: transform,
|
|
965
|
+
transform: transform
|
|
966
|
+
};
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
/**
|
|
970
|
+
* Get an image name from an image url.
|
|
971
|
+
* @param {string} url - The target url.
|
|
972
|
+
* @example
|
|
973
|
+
* // picture.jpg
|
|
974
|
+
* getImageNameFromURL('https://domain.com/path/to/picture.jpg?size=1280×960')
|
|
975
|
+
* @returns {string} A string contains the image name.
|
|
976
|
+
*/
|
|
977
|
+
function getImageNameFromURL(url) {
|
|
978
|
+
return isString(url) ? decodeURIComponent(url.replace(/^.*\//, '').replace(/[?&#].*$/, '')) : '';
|
|
979
|
+
}
|
|
980
|
+
var IS_SAFARI = WINDOW.navigator && /Version\/\d+(\.\d+)+?\s+Safari/i.test(WINDOW.navigator.userAgent);
|
|
981
|
+
|
|
982
|
+
/**
|
|
983
|
+
* Get an image's natural sizes.
|
|
984
|
+
* @param {string} image - The target image.
|
|
985
|
+
* @param {Object} options - The viewer options.
|
|
986
|
+
* @param {Function} callback - The callback function.
|
|
987
|
+
* @returns {HTMLImageElement} The new image.
|
|
988
|
+
*/
|
|
989
|
+
function getImageNaturalSizes(image, options, callback) {
|
|
990
|
+
var newImage = document.createElement('img');
|
|
991
|
+
|
|
992
|
+
// Modern browsers (except Safari)
|
|
993
|
+
if (image.naturalWidth && !IS_SAFARI) {
|
|
994
|
+
callback(image.naturalWidth, image.naturalHeight);
|
|
995
|
+
return newImage;
|
|
996
|
+
}
|
|
997
|
+
var body = document.body || document.documentElement;
|
|
998
|
+
newImage.onload = function () {
|
|
999
|
+
callback(newImage.width, newImage.height);
|
|
1000
|
+
if (!IS_SAFARI) {
|
|
1001
|
+
body.removeChild(newImage);
|
|
1002
|
+
}
|
|
1003
|
+
};
|
|
1004
|
+
forEach(options.inheritedAttributes, function (name) {
|
|
1005
|
+
var value = image.getAttribute(name);
|
|
1006
|
+
if (value !== null) {
|
|
1007
|
+
newImage.setAttribute(name, value);
|
|
1008
|
+
}
|
|
1009
|
+
});
|
|
1010
|
+
newImage.src = image.src;
|
|
1011
|
+
|
|
1012
|
+
// iOS Safari will convert the image automatically
|
|
1013
|
+
// with its orientation once append it into DOM
|
|
1014
|
+
if (!IS_SAFARI) {
|
|
1015
|
+
newImage.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;';
|
|
1016
|
+
body.appendChild(newImage);
|
|
1017
|
+
}
|
|
1018
|
+
return newImage;
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
/**
|
|
1022
|
+
* Get the related class name of a responsive type number.
|
|
1023
|
+
* @param {string} type - The responsive type.
|
|
1024
|
+
* @returns {string} The related class name.
|
|
1025
|
+
*/
|
|
1026
|
+
function getResponsiveClass(type) {
|
|
1027
|
+
switch (type) {
|
|
1028
|
+
case 2:
|
|
1029
|
+
return CLASS_HIDE_XS_DOWN;
|
|
1030
|
+
case 3:
|
|
1031
|
+
return CLASS_HIDE_SM_DOWN;
|
|
1032
|
+
case 4:
|
|
1033
|
+
return CLASS_HIDE_MD_DOWN;
|
|
1034
|
+
default:
|
|
1035
|
+
return '';
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
/**
|
|
1040
|
+
* Get the max ratio of a group of pointers.
|
|
1041
|
+
* @param {string} pointers - The target pointers.
|
|
1042
|
+
* @returns {number} The result ratio.
|
|
1043
|
+
*/
|
|
1044
|
+
function getMaxZoomRatio(pointers) {
|
|
1045
|
+
var pointers2 = _objectSpread2({}, pointers);
|
|
1046
|
+
var ratios = [];
|
|
1047
|
+
forEach(pointers, function (pointer, pointerId) {
|
|
1048
|
+
delete pointers2[pointerId];
|
|
1049
|
+
forEach(pointers2, function (pointer2) {
|
|
1050
|
+
var x1 = Math.abs(pointer.startX - pointer2.startX);
|
|
1051
|
+
var y1 = Math.abs(pointer.startY - pointer2.startY);
|
|
1052
|
+
var x2 = Math.abs(pointer.endX - pointer2.endX);
|
|
1053
|
+
var y2 = Math.abs(pointer.endY - pointer2.endY);
|
|
1054
|
+
var z1 = Math.sqrt(x1 * x1 + y1 * y1);
|
|
1055
|
+
var z2 = Math.sqrt(x2 * x2 + y2 * y2);
|
|
1056
|
+
var ratio = (z2 - z1) / z1;
|
|
1057
|
+
ratios.push(ratio);
|
|
1058
|
+
});
|
|
1059
|
+
});
|
|
1060
|
+
ratios.sort(function (a, b) {
|
|
1061
|
+
return Math.abs(a) < Math.abs(b);
|
|
1062
|
+
});
|
|
1063
|
+
return ratios[0];
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
/**
|
|
1067
|
+
* Get a pointer from an event object.
|
|
1068
|
+
* @param {Object} event - The target event object.
|
|
1069
|
+
* @param {boolean} endOnly - Indicates if only returns the end point coordinate or not.
|
|
1070
|
+
* @returns {Object} The result pointer contains start and/or end point coordinates.
|
|
1071
|
+
*/
|
|
1072
|
+
function getPointer(_ref2, endOnly) {
|
|
1073
|
+
var pageX = _ref2.pageX,
|
|
1074
|
+
pageY = _ref2.pageY;
|
|
1075
|
+
var end = {
|
|
1076
|
+
endX: pageX,
|
|
1077
|
+
endY: pageY
|
|
1078
|
+
};
|
|
1079
|
+
return endOnly ? end : _objectSpread2({
|
|
1080
|
+
timeStamp: Date.now(),
|
|
1081
|
+
startX: pageX,
|
|
1082
|
+
startY: pageY
|
|
1083
|
+
}, end);
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
/**
|
|
1087
|
+
* Get the center point coordinate of a group of pointers.
|
|
1088
|
+
* @param {Object} pointers - The target pointers.
|
|
1089
|
+
* @returns {Object} The center point coordinate.
|
|
1090
|
+
*/
|
|
1091
|
+
function getPointersCenter(pointers) {
|
|
1092
|
+
var pageX = 0;
|
|
1093
|
+
var pageY = 0;
|
|
1094
|
+
var count = 0;
|
|
1095
|
+
forEach(pointers, function (_ref3) {
|
|
1096
|
+
var startX = _ref3.startX,
|
|
1097
|
+
startY = _ref3.startY;
|
|
1098
|
+
pageX += startX;
|
|
1099
|
+
pageY += startY;
|
|
1100
|
+
count += 1;
|
|
1101
|
+
});
|
|
1102
|
+
pageX /= count;
|
|
1103
|
+
pageY /= count;
|
|
1104
|
+
return {
|
|
1105
|
+
pageX: pageX,
|
|
1106
|
+
pageY: pageY
|
|
1107
|
+
};
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
var render = {
|
|
1111
|
+
render: function render() {
|
|
1112
|
+
this.initContainer();
|
|
1113
|
+
this.initViewer();
|
|
1114
|
+
this.initList();
|
|
1115
|
+
this.renderViewer();
|
|
1116
|
+
},
|
|
1117
|
+
initBody: function initBody() {
|
|
1118
|
+
var ownerDocument = this.element.ownerDocument;
|
|
1119
|
+
var body = ownerDocument.body || ownerDocument.documentElement;
|
|
1120
|
+
this.body = body;
|
|
1121
|
+
this.scrollbarWidth = window.innerWidth - ownerDocument.documentElement.clientWidth;
|
|
1122
|
+
this.initialBodyPaddingRight = body.style.paddingRight;
|
|
1123
|
+
this.initialBodyComputedPaddingRight = window.getComputedStyle(body).paddingRight;
|
|
1124
|
+
},
|
|
1125
|
+
initContainer: function initContainer() {
|
|
1126
|
+
this.containerData = {
|
|
1127
|
+
width: window.innerWidth,
|
|
1128
|
+
height: window.innerHeight
|
|
1129
|
+
};
|
|
1130
|
+
},
|
|
1131
|
+
initViewer: function initViewer() {
|
|
1132
|
+
var options = this.options,
|
|
1133
|
+
parent = this.parent;
|
|
1134
|
+
var viewerData;
|
|
1135
|
+
if (options.inline) {
|
|
1136
|
+
viewerData = {
|
|
1137
|
+
width: Math.max(parent.offsetWidth, options.minWidth),
|
|
1138
|
+
height: Math.max(parent.offsetHeight, options.minHeight)
|
|
1139
|
+
};
|
|
1140
|
+
this.parentData = viewerData;
|
|
1141
|
+
}
|
|
1142
|
+
if (this.fulled || !viewerData) {
|
|
1143
|
+
viewerData = this.containerData;
|
|
1144
|
+
}
|
|
1145
|
+
this.viewerData = assign({}, viewerData);
|
|
1146
|
+
},
|
|
1147
|
+
renderViewer: function renderViewer() {
|
|
1148
|
+
if (this.options.inline && !this.fulled) {
|
|
1149
|
+
setStyle(this.viewer, this.viewerData);
|
|
1150
|
+
}
|
|
1151
|
+
},
|
|
1152
|
+
initList: function initList() {
|
|
1153
|
+
var _this = this;
|
|
1154
|
+
var element = this.element,
|
|
1155
|
+
options = this.options,
|
|
1156
|
+
list = this.list;
|
|
1157
|
+
var items = [];
|
|
1158
|
+
|
|
1159
|
+
// initList may be called in this.update, so should keep idempotent
|
|
1160
|
+
list.innerHTML = '';
|
|
1161
|
+
forEach(this.images, function (image, index) {
|
|
1162
|
+
var src = image.src;
|
|
1163
|
+
var alt = image.alt || getImageNameFromURL(src);
|
|
1164
|
+
var url = _this.getImageURL(image);
|
|
1165
|
+
if (src || url) {
|
|
1166
|
+
var item = document.createElement('li');
|
|
1167
|
+
var img = document.createElement('img');
|
|
1168
|
+
forEach(options.inheritedAttributes, function (name) {
|
|
1169
|
+
var value = image.getAttribute(name);
|
|
1170
|
+
if (value !== null) {
|
|
1171
|
+
img.setAttribute(name, value);
|
|
1172
|
+
}
|
|
1173
|
+
});
|
|
1174
|
+
if (options.navbar) {
|
|
1175
|
+
img.src = src || url;
|
|
1176
|
+
}
|
|
1177
|
+
img.alt = alt;
|
|
1178
|
+
img.setAttribute('data-original-url', url || src);
|
|
1179
|
+
item.setAttribute('data-index', index);
|
|
1180
|
+
item.setAttribute('data-viewer-action', 'view');
|
|
1181
|
+
item.setAttribute('role', 'button');
|
|
1182
|
+
if (options.keyboard) {
|
|
1183
|
+
item.setAttribute('tabindex', 0);
|
|
1184
|
+
}
|
|
1185
|
+
item.appendChild(img);
|
|
1186
|
+
list.appendChild(item);
|
|
1187
|
+
items.push(item);
|
|
1188
|
+
}
|
|
1189
|
+
});
|
|
1190
|
+
this.items = items;
|
|
1191
|
+
forEach(items, function (item) {
|
|
1192
|
+
var image = item.firstElementChild;
|
|
1193
|
+
var onLoad;
|
|
1194
|
+
var onError;
|
|
1195
|
+
setData(image, 'filled', true);
|
|
1196
|
+
if (options.loading) {
|
|
1197
|
+
addClass(item, CLASS_LOADING);
|
|
1198
|
+
}
|
|
1199
|
+
addListener(image, EVENT_LOAD, onLoad = function onLoad(event) {
|
|
1200
|
+
removeListener(image, EVENT_ERROR, onError);
|
|
1201
|
+
if (options.loading) {
|
|
1202
|
+
removeClass(item, CLASS_LOADING);
|
|
1203
|
+
}
|
|
1204
|
+
_this.loadImage(event);
|
|
1205
|
+
}, {
|
|
1206
|
+
once: true
|
|
1207
|
+
});
|
|
1208
|
+
addListener(image, EVENT_ERROR, onError = function onError() {
|
|
1209
|
+
removeListener(image, EVENT_LOAD, onLoad);
|
|
1210
|
+
if (options.loading) {
|
|
1211
|
+
removeClass(item, CLASS_LOADING);
|
|
1212
|
+
}
|
|
1213
|
+
}, {
|
|
1214
|
+
once: true
|
|
1215
|
+
});
|
|
1216
|
+
});
|
|
1217
|
+
if (options.transition) {
|
|
1218
|
+
addListener(element, EVENT_VIEWED, function () {
|
|
1219
|
+
addClass(list, CLASS_TRANSITION);
|
|
1220
|
+
}, {
|
|
1221
|
+
once: true
|
|
1222
|
+
});
|
|
1223
|
+
}
|
|
1224
|
+
},
|
|
1225
|
+
renderList: function renderList() {
|
|
1226
|
+
var index = this.index;
|
|
1227
|
+
var item = this.items[index];
|
|
1228
|
+
if (!item) {
|
|
1229
|
+
return;
|
|
1230
|
+
}
|
|
1231
|
+
var next = item.nextElementSibling;
|
|
1232
|
+
var gutter = parseInt(window.getComputedStyle(next || item).marginLeft, 10);
|
|
1233
|
+
var offsetWidth = item.offsetWidth;
|
|
1234
|
+
var outerWidth = offsetWidth + gutter;
|
|
1235
|
+
|
|
1236
|
+
// Place the active item in the center of the screen
|
|
1237
|
+
setStyle(this.list, assign({
|
|
1238
|
+
width: outerWidth * this.length - gutter
|
|
1239
|
+
}, getTransforms({
|
|
1240
|
+
translateX: (this.viewerData.width - offsetWidth) / 2 - outerWidth * index
|
|
1241
|
+
})));
|
|
1242
|
+
},
|
|
1243
|
+
resetList: function resetList() {
|
|
1244
|
+
var list = this.list;
|
|
1245
|
+
list.innerHTML = '';
|
|
1246
|
+
removeClass(list, CLASS_TRANSITION);
|
|
1247
|
+
setStyle(list, getTransforms({
|
|
1248
|
+
translateX: 0
|
|
1249
|
+
}));
|
|
1250
|
+
},
|
|
1251
|
+
initImage: function initImage(done) {
|
|
1252
|
+
var _this2 = this;
|
|
1253
|
+
var options = this.options,
|
|
1254
|
+
image = this.image,
|
|
1255
|
+
viewerData = this.viewerData;
|
|
1256
|
+
var footerHeight = this.footer.offsetHeight;
|
|
1257
|
+
var viewerWidth = viewerData.width;
|
|
1258
|
+
var viewerHeight = Math.max(viewerData.height - footerHeight, footerHeight);
|
|
1259
|
+
var oldImageData = this.imageData || {};
|
|
1260
|
+
var sizingImage;
|
|
1261
|
+
this.imageInitializing = {
|
|
1262
|
+
abort: function abort() {
|
|
1263
|
+
sizingImage.onload = null;
|
|
1264
|
+
}
|
|
1265
|
+
};
|
|
1266
|
+
sizingImage = getImageNaturalSizes(image, options, function (naturalWidth, naturalHeight) {
|
|
1267
|
+
var aspectRatio = naturalWidth / naturalHeight;
|
|
1268
|
+
var initialCoverage = Math.max(0, Math.min(1, options.initialCoverage));
|
|
1269
|
+
var width = viewerWidth;
|
|
1270
|
+
var height = viewerHeight;
|
|
1271
|
+
_this2.imageInitializing = false;
|
|
1272
|
+
if (viewerHeight * aspectRatio > viewerWidth) {
|
|
1273
|
+
height = viewerWidth / aspectRatio;
|
|
1274
|
+
} else {
|
|
1275
|
+
width = viewerHeight * aspectRatio;
|
|
1276
|
+
}
|
|
1277
|
+
initialCoverage = isNumber(initialCoverage) ? initialCoverage : 0.9;
|
|
1278
|
+
width = Math.min(width * initialCoverage, naturalWidth);
|
|
1279
|
+
height = Math.min(height * initialCoverage, naturalHeight);
|
|
1280
|
+
var left = (viewerWidth - width) / 2;
|
|
1281
|
+
var top = (viewerHeight - height) / 2;
|
|
1282
|
+
var imageData = {
|
|
1283
|
+
left: left,
|
|
1284
|
+
top: top,
|
|
1285
|
+
x: left,
|
|
1286
|
+
y: top,
|
|
1287
|
+
width: width,
|
|
1288
|
+
height: height,
|
|
1289
|
+
oldRatio: 1,
|
|
1290
|
+
ratio: width / naturalWidth,
|
|
1291
|
+
aspectRatio: aspectRatio,
|
|
1292
|
+
naturalWidth: naturalWidth,
|
|
1293
|
+
naturalHeight: naturalHeight
|
|
1294
|
+
};
|
|
1295
|
+
var initialImageData = assign({}, imageData);
|
|
1296
|
+
if (options.rotatable) {
|
|
1297
|
+
imageData.rotate = oldImageData.rotate || 0;
|
|
1298
|
+
initialImageData.rotate = 0;
|
|
1299
|
+
}
|
|
1300
|
+
if (options.scalable) {
|
|
1301
|
+
imageData.scaleX = oldImageData.scaleX || 1;
|
|
1302
|
+
imageData.scaleY = oldImageData.scaleY || 1;
|
|
1303
|
+
initialImageData.scaleX = 1;
|
|
1304
|
+
initialImageData.scaleY = 1;
|
|
1305
|
+
}
|
|
1306
|
+
_this2.imageData = imageData;
|
|
1307
|
+
_this2.initialImageData = initialImageData;
|
|
1308
|
+
if (done) {
|
|
1309
|
+
done();
|
|
1310
|
+
}
|
|
1311
|
+
});
|
|
1312
|
+
},
|
|
1313
|
+
renderImage: function renderImage(done) {
|
|
1314
|
+
var _this3 = this;
|
|
1315
|
+
var image = this.image,
|
|
1316
|
+
imageData = this.imageData;
|
|
1317
|
+
setStyle(image, assign({
|
|
1318
|
+
width: imageData.width,
|
|
1319
|
+
height: imageData.height,
|
|
1320
|
+
// XXX: Not to use translateX/Y to avoid image shaking when zooming
|
|
1321
|
+
marginLeft: imageData.x,
|
|
1322
|
+
marginTop: imageData.y
|
|
1323
|
+
}, getTransforms(imageData)));
|
|
1324
|
+
if (done) {
|
|
1325
|
+
if ((this.viewing || this.moving || this.rotating || this.scaling || this.zooming) && this.options.transition && hasClass(image, CLASS_TRANSITION)) {
|
|
1326
|
+
var onTransitionEnd = function onTransitionEnd() {
|
|
1327
|
+
_this3.imageRendering = false;
|
|
1328
|
+
done();
|
|
1329
|
+
};
|
|
1330
|
+
this.imageRendering = {
|
|
1331
|
+
abort: function abort() {
|
|
1332
|
+
removeListener(image, EVENT_TRANSITION_END, onTransitionEnd);
|
|
1333
|
+
}
|
|
1334
|
+
};
|
|
1335
|
+
addListener(image, EVENT_TRANSITION_END, onTransitionEnd, {
|
|
1336
|
+
once: true
|
|
1337
|
+
});
|
|
1338
|
+
} else {
|
|
1339
|
+
done();
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
},
|
|
1343
|
+
resetImage: function resetImage() {
|
|
1344
|
+
var image = this.image;
|
|
1345
|
+
if (image) {
|
|
1346
|
+
if (this.viewing) {
|
|
1347
|
+
this.viewing.abort();
|
|
1348
|
+
}
|
|
1349
|
+
image.parentNode.removeChild(image);
|
|
1350
|
+
this.image = null;
|
|
1351
|
+
this.title.innerHTML = '';
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
};
|
|
1355
|
+
|
|
1356
|
+
var events = {
|
|
1357
|
+
bind: function bind() {
|
|
1358
|
+
var options = this.options,
|
|
1359
|
+
viewer = this.viewer,
|
|
1360
|
+
canvas = this.canvas;
|
|
1361
|
+
var document = this.element.ownerDocument;
|
|
1362
|
+
addListener(viewer, EVENT_CLICK, this.onClick = this.click.bind(this));
|
|
1363
|
+
addListener(viewer, EVENT_DRAG_START, this.onDragStart = this.dragstart.bind(this));
|
|
1364
|
+
addListener(canvas, EVENT_POINTER_DOWN, this.onPointerDown = this.pointerdown.bind(this));
|
|
1365
|
+
addListener(document, EVENT_POINTER_MOVE, this.onPointerMove = this.pointermove.bind(this));
|
|
1366
|
+
addListener(document, EVENT_POINTER_UP, this.onPointerUp = this.pointerup.bind(this));
|
|
1367
|
+
addListener(document, EVENT_KEY_DOWN, this.onKeyDown = this.keydown.bind(this));
|
|
1368
|
+
addListener(window, EVENT_RESIZE, this.onResize = this.resize.bind(this));
|
|
1369
|
+
if (options.zoomable && options.zoomOnWheel) {
|
|
1370
|
+
addListener(viewer, EVENT_WHEEL, this.onWheel = this.wheel.bind(this), {
|
|
1371
|
+
passive: false,
|
|
1372
|
+
capture: true
|
|
1373
|
+
});
|
|
1374
|
+
}
|
|
1375
|
+
if (options.toggleOnDblclick) {
|
|
1376
|
+
addListener(canvas, EVENT_DBLCLICK, this.onDblclick = this.dblclick.bind(this));
|
|
1377
|
+
}
|
|
1378
|
+
},
|
|
1379
|
+
unbind: function unbind() {
|
|
1380
|
+
var options = this.options,
|
|
1381
|
+
viewer = this.viewer,
|
|
1382
|
+
canvas = this.canvas;
|
|
1383
|
+
var document = this.element.ownerDocument;
|
|
1384
|
+
removeListener(viewer, EVENT_CLICK, this.onClick);
|
|
1385
|
+
removeListener(viewer, EVENT_DRAG_START, this.onDragStart);
|
|
1386
|
+
removeListener(canvas, EVENT_POINTER_DOWN, this.onPointerDown);
|
|
1387
|
+
removeListener(document, EVENT_POINTER_MOVE, this.onPointerMove);
|
|
1388
|
+
removeListener(document, EVENT_POINTER_UP, this.onPointerUp);
|
|
1389
|
+
removeListener(document, EVENT_KEY_DOWN, this.onKeyDown);
|
|
1390
|
+
removeListener(window, EVENT_RESIZE, this.onResize);
|
|
1391
|
+
if (options.zoomable && options.zoomOnWheel) {
|
|
1392
|
+
removeListener(viewer, EVENT_WHEEL, this.onWheel, {
|
|
1393
|
+
passive: false,
|
|
1394
|
+
capture: true
|
|
1395
|
+
});
|
|
1396
|
+
}
|
|
1397
|
+
if (options.toggleOnDblclick) {
|
|
1398
|
+
removeListener(canvas, EVENT_DBLCLICK, this.onDblclick);
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
};
|
|
1402
|
+
|
|
1403
|
+
var handlers = {
|
|
1404
|
+
click: function click(event) {
|
|
1405
|
+
var options = this.options,
|
|
1406
|
+
imageData = this.imageData;
|
|
1407
|
+
var target = event.target;
|
|
1408
|
+
var action = getData(target, DATA_ACTION);
|
|
1409
|
+
if (!action && target.localName === 'img' && target.parentElement.localName === 'li') {
|
|
1410
|
+
target = target.parentElement;
|
|
1411
|
+
action = getData(target, DATA_ACTION);
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
// Cancel the emulated click when the native click event was triggered.
|
|
1415
|
+
if (IS_TOUCH_DEVICE && event.isTrusted && target === this.canvas) {
|
|
1416
|
+
clearTimeout(this.clickCanvasTimeout);
|
|
1417
|
+
}
|
|
1418
|
+
switch (action) {
|
|
1419
|
+
case 'mix':
|
|
1420
|
+
if (this.played) {
|
|
1421
|
+
this.stop();
|
|
1422
|
+
} else if (options.inline) {
|
|
1423
|
+
if (this.fulled) {
|
|
1424
|
+
this.exit();
|
|
1425
|
+
} else {
|
|
1426
|
+
this.full();
|
|
1427
|
+
}
|
|
1428
|
+
} else {
|
|
1429
|
+
this.hide();
|
|
1430
|
+
}
|
|
1431
|
+
break;
|
|
1432
|
+
case 'hide':
|
|
1433
|
+
if (!this.pointerMoved) {
|
|
1434
|
+
this.hide();
|
|
1435
|
+
}
|
|
1436
|
+
break;
|
|
1437
|
+
case 'view':
|
|
1438
|
+
this.view(getData(target, 'index'));
|
|
1439
|
+
break;
|
|
1440
|
+
case 'zoom-in':
|
|
1441
|
+
this.zoom(0.1, true);
|
|
1442
|
+
break;
|
|
1443
|
+
case 'zoom-out':
|
|
1444
|
+
this.zoom(-0.1, true);
|
|
1445
|
+
break;
|
|
1446
|
+
case 'one-to-one':
|
|
1447
|
+
this.toggle();
|
|
1448
|
+
break;
|
|
1449
|
+
case 'reset':
|
|
1450
|
+
this.reset();
|
|
1451
|
+
break;
|
|
1452
|
+
case 'prev':
|
|
1453
|
+
this.prev(options.loop);
|
|
1454
|
+
break;
|
|
1455
|
+
case 'play':
|
|
1456
|
+
this.play(options.fullscreen);
|
|
1457
|
+
break;
|
|
1458
|
+
case 'next':
|
|
1459
|
+
this.next(options.loop);
|
|
1460
|
+
break;
|
|
1461
|
+
case 'rotate-left':
|
|
1462
|
+
this.rotate(-90);
|
|
1463
|
+
break;
|
|
1464
|
+
case 'rotate-right':
|
|
1465
|
+
this.rotate(90);
|
|
1466
|
+
break;
|
|
1467
|
+
case 'flip-horizontal':
|
|
1468
|
+
this.scaleX(-imageData.scaleX || -1);
|
|
1469
|
+
break;
|
|
1470
|
+
case 'flip-vertical':
|
|
1471
|
+
this.scaleY(-imageData.scaleY || -1);
|
|
1472
|
+
break;
|
|
1473
|
+
default:
|
|
1474
|
+
if (this.played) {
|
|
1475
|
+
this.stop();
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
},
|
|
1479
|
+
dblclick: function dblclick(event) {
|
|
1480
|
+
event.preventDefault();
|
|
1481
|
+
if (this.viewed && event.target === this.image) {
|
|
1482
|
+
// Cancel the emulated double click when the native dblclick event was triggered.
|
|
1483
|
+
if (IS_TOUCH_DEVICE && event.isTrusted) {
|
|
1484
|
+
clearTimeout(this.doubleClickImageTimeout);
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
// XXX: No pageX/Y properties in custom event, fallback to the original event.
|
|
1488
|
+
this.toggle(event.isTrusted ? event : event.detail && event.detail.originalEvent);
|
|
1489
|
+
}
|
|
1490
|
+
},
|
|
1491
|
+
load: function load() {
|
|
1492
|
+
var _this = this;
|
|
1493
|
+
if (this.timeout) {
|
|
1494
|
+
clearTimeout(this.timeout);
|
|
1495
|
+
this.timeout = false;
|
|
1496
|
+
}
|
|
1497
|
+
var element = this.element,
|
|
1498
|
+
options = this.options,
|
|
1499
|
+
image = this.image,
|
|
1500
|
+
index = this.index,
|
|
1501
|
+
viewerData = this.viewerData;
|
|
1502
|
+
removeClass(image, CLASS_INVISIBLE);
|
|
1503
|
+
if (options.loading) {
|
|
1504
|
+
removeClass(this.canvas, CLASS_LOADING);
|
|
1505
|
+
}
|
|
1506
|
+
image.style.cssText = 'height:0;' + "margin-left:".concat(viewerData.width / 2, "px;") + "margin-top:".concat(viewerData.height / 2, "px;") + 'max-width:none!important;' + 'position:relative;' + 'width:0;';
|
|
1507
|
+
this.initImage(function () {
|
|
1508
|
+
toggleClass(image, CLASS_MOVE, options.movable);
|
|
1509
|
+
toggleClass(image, CLASS_TRANSITION, options.transition);
|
|
1510
|
+
_this.renderImage(function () {
|
|
1511
|
+
_this.viewed = true;
|
|
1512
|
+
_this.viewing = false;
|
|
1513
|
+
if (isFunction(options.viewed)) {
|
|
1514
|
+
addListener(element, EVENT_VIEWED, options.viewed, {
|
|
1515
|
+
once: true
|
|
1516
|
+
});
|
|
1517
|
+
}
|
|
1518
|
+
dispatchEvent(element, EVENT_VIEWED, {
|
|
1519
|
+
originalImage: _this.images[index],
|
|
1520
|
+
index: index,
|
|
1521
|
+
image: image
|
|
1522
|
+
}, {
|
|
1523
|
+
cancelable: false
|
|
1524
|
+
});
|
|
1525
|
+
});
|
|
1526
|
+
});
|
|
1527
|
+
},
|
|
1528
|
+
loadImage: function loadImage(event) {
|
|
1529
|
+
var image = event.target;
|
|
1530
|
+
var parent = image.parentNode;
|
|
1531
|
+
var parentWidth = parent.offsetWidth || 30;
|
|
1532
|
+
var parentHeight = parent.offsetHeight || 50;
|
|
1533
|
+
var filled = !!getData(image, 'filled');
|
|
1534
|
+
getImageNaturalSizes(image, this.options, function (naturalWidth, naturalHeight) {
|
|
1535
|
+
var aspectRatio = naturalWidth / naturalHeight;
|
|
1536
|
+
var width = parentWidth;
|
|
1537
|
+
var height = parentHeight;
|
|
1538
|
+
if (parentHeight * aspectRatio > parentWidth) {
|
|
1539
|
+
if (filled) {
|
|
1540
|
+
width = parentHeight * aspectRatio;
|
|
1541
|
+
} else {
|
|
1542
|
+
height = parentWidth / aspectRatio;
|
|
1543
|
+
}
|
|
1544
|
+
} else if (filled) {
|
|
1545
|
+
height = parentWidth / aspectRatio;
|
|
1546
|
+
} else {
|
|
1547
|
+
width = parentHeight * aspectRatio;
|
|
1548
|
+
}
|
|
1549
|
+
setStyle(image, assign({
|
|
1550
|
+
width: width,
|
|
1551
|
+
height: height
|
|
1552
|
+
}, getTransforms({
|
|
1553
|
+
translateX: (parentWidth - width) / 2,
|
|
1554
|
+
translateY: (parentHeight - height) / 2
|
|
1555
|
+
})));
|
|
1556
|
+
});
|
|
1557
|
+
},
|
|
1558
|
+
keydown: function keydown(event) {
|
|
1559
|
+
var options = this.options;
|
|
1560
|
+
if (!options.keyboard) {
|
|
1561
|
+
return;
|
|
1562
|
+
}
|
|
1563
|
+
var keyCode = event.keyCode || event.which || event.charCode;
|
|
1564
|
+
switch (keyCode) {
|
|
1565
|
+
// Enter
|
|
1566
|
+
case 13:
|
|
1567
|
+
if (this.viewer.contains(event.target)) {
|
|
1568
|
+
this.click(event);
|
|
1569
|
+
}
|
|
1570
|
+
break;
|
|
1571
|
+
}
|
|
1572
|
+
if (!this.fulled) {
|
|
1573
|
+
return;
|
|
1574
|
+
}
|
|
1575
|
+
switch (keyCode) {
|
|
1576
|
+
// Escape
|
|
1577
|
+
case 27:
|
|
1578
|
+
if (this.played) {
|
|
1579
|
+
this.stop();
|
|
1580
|
+
} else if (options.inline) {
|
|
1581
|
+
if (this.fulled) {
|
|
1582
|
+
this.exit();
|
|
1583
|
+
}
|
|
1584
|
+
} else {
|
|
1585
|
+
this.hide();
|
|
1586
|
+
}
|
|
1587
|
+
break;
|
|
1588
|
+
|
|
1589
|
+
// Space
|
|
1590
|
+
case 32:
|
|
1591
|
+
if (this.played) {
|
|
1592
|
+
this.stop();
|
|
1593
|
+
}
|
|
1594
|
+
break;
|
|
1595
|
+
|
|
1596
|
+
// ArrowLeft
|
|
1597
|
+
case 37:
|
|
1598
|
+
if (this.played && this.playing) {
|
|
1599
|
+
this.playing.prev();
|
|
1600
|
+
} else {
|
|
1601
|
+
this.prev(options.loop);
|
|
1602
|
+
}
|
|
1603
|
+
break;
|
|
1604
|
+
|
|
1605
|
+
// ArrowUp
|
|
1606
|
+
case 38:
|
|
1607
|
+
// Prevent scroll on Firefox
|
|
1608
|
+
event.preventDefault();
|
|
1609
|
+
|
|
1610
|
+
// Zoom in
|
|
1611
|
+
this.zoom(options.zoomRatio, true);
|
|
1612
|
+
break;
|
|
1613
|
+
|
|
1614
|
+
// ArrowRight
|
|
1615
|
+
case 39:
|
|
1616
|
+
if (this.played && this.playing) {
|
|
1617
|
+
this.playing.next();
|
|
1618
|
+
} else {
|
|
1619
|
+
this.next(options.loop);
|
|
1620
|
+
}
|
|
1621
|
+
break;
|
|
1622
|
+
|
|
1623
|
+
// ArrowDown
|
|
1624
|
+
case 40:
|
|
1625
|
+
// Prevent scroll on Firefox
|
|
1626
|
+
event.preventDefault();
|
|
1627
|
+
|
|
1628
|
+
// Zoom out
|
|
1629
|
+
this.zoom(-options.zoomRatio, true);
|
|
1630
|
+
break;
|
|
1631
|
+
|
|
1632
|
+
// Ctrl + 0
|
|
1633
|
+
case 48:
|
|
1634
|
+
// Fall through
|
|
1635
|
+
|
|
1636
|
+
// Ctrl + 1
|
|
1637
|
+
// eslint-disable-next-line no-fallthrough
|
|
1638
|
+
case 49:
|
|
1639
|
+
if (event.ctrlKey) {
|
|
1640
|
+
event.preventDefault();
|
|
1641
|
+
this.toggle();
|
|
1642
|
+
}
|
|
1643
|
+
break;
|
|
1644
|
+
}
|
|
1645
|
+
},
|
|
1646
|
+
dragstart: function dragstart(event) {
|
|
1647
|
+
if (event.target.localName === 'img') {
|
|
1648
|
+
event.preventDefault();
|
|
1649
|
+
}
|
|
1650
|
+
},
|
|
1651
|
+
pointerdown: function pointerdown(event) {
|
|
1652
|
+
var options = this.options,
|
|
1653
|
+
pointers = this.pointers;
|
|
1654
|
+
var buttons = event.buttons,
|
|
1655
|
+
button = event.button;
|
|
1656
|
+
this.pointerMoved = false;
|
|
1657
|
+
if (!this.viewed || this.showing || this.viewing || this.hiding
|
|
1658
|
+
|
|
1659
|
+
// Handle mouse event and pointer event and ignore touch event
|
|
1660
|
+
|| (event.type === 'mousedown' || event.type === 'pointerdown' && event.pointerType === 'mouse') && (
|
|
1661
|
+
// No primary button (Usually the left button)
|
|
1662
|
+
isNumber(buttons) && buttons !== 1 || isNumber(button) && button !== 0
|
|
1663
|
+
|
|
1664
|
+
// Open context menu
|
|
1665
|
+
|| event.ctrlKey)) {
|
|
1666
|
+
return;
|
|
1667
|
+
}
|
|
1668
|
+
|
|
1669
|
+
// Prevent default behaviours as page zooming in touch devices.
|
|
1670
|
+
event.preventDefault();
|
|
1671
|
+
if (event.changedTouches) {
|
|
1672
|
+
forEach(event.changedTouches, function (touch) {
|
|
1673
|
+
pointers[touch.identifier] = getPointer(touch);
|
|
1674
|
+
});
|
|
1675
|
+
} else {
|
|
1676
|
+
pointers[event.pointerId || 0] = getPointer(event);
|
|
1677
|
+
}
|
|
1678
|
+
var action = options.movable ? ACTION_MOVE : false;
|
|
1679
|
+
if (options.zoomOnTouch && options.zoomable && Object.keys(pointers).length > 1) {
|
|
1680
|
+
action = ACTION_ZOOM;
|
|
1681
|
+
} else if (options.slideOnTouch && (event.pointerType === 'touch' || event.type === 'touchstart') && this.isSwitchable()) {
|
|
1682
|
+
action = ACTION_SWITCH;
|
|
1683
|
+
}
|
|
1684
|
+
if (options.transition && (action === ACTION_MOVE || action === ACTION_ZOOM)) {
|
|
1685
|
+
removeClass(this.image, CLASS_TRANSITION);
|
|
1686
|
+
}
|
|
1687
|
+
this.action = action;
|
|
1688
|
+
},
|
|
1689
|
+
pointermove: function pointermove(event) {
|
|
1690
|
+
var pointers = this.pointers,
|
|
1691
|
+
action = this.action;
|
|
1692
|
+
if (!this.viewed || !action) {
|
|
1693
|
+
return;
|
|
1694
|
+
}
|
|
1695
|
+
event.preventDefault();
|
|
1696
|
+
if (event.changedTouches) {
|
|
1697
|
+
forEach(event.changedTouches, function (touch) {
|
|
1698
|
+
assign(pointers[touch.identifier] || {}, getPointer(touch, true));
|
|
1699
|
+
});
|
|
1700
|
+
} else {
|
|
1701
|
+
assign(pointers[event.pointerId || 0] || {}, getPointer(event, true));
|
|
1702
|
+
}
|
|
1703
|
+
this.change(event);
|
|
1704
|
+
},
|
|
1705
|
+
pointerup: function pointerup(event) {
|
|
1706
|
+
var _this2 = this;
|
|
1707
|
+
var options = this.options,
|
|
1708
|
+
action = this.action,
|
|
1709
|
+
pointers = this.pointers;
|
|
1710
|
+
var pointer;
|
|
1711
|
+
if (event.changedTouches) {
|
|
1712
|
+
forEach(event.changedTouches, function (touch) {
|
|
1713
|
+
pointer = pointers[touch.identifier];
|
|
1714
|
+
delete pointers[touch.identifier];
|
|
1715
|
+
});
|
|
1716
|
+
} else {
|
|
1717
|
+
pointer = pointers[event.pointerId || 0];
|
|
1718
|
+
delete pointers[event.pointerId || 0];
|
|
1719
|
+
}
|
|
1720
|
+
if (!action) {
|
|
1721
|
+
return;
|
|
1722
|
+
}
|
|
1723
|
+
event.preventDefault();
|
|
1724
|
+
if (options.transition && (action === ACTION_MOVE || action === ACTION_ZOOM)) {
|
|
1725
|
+
addClass(this.image, CLASS_TRANSITION);
|
|
1726
|
+
}
|
|
1727
|
+
this.action = false;
|
|
1728
|
+
|
|
1729
|
+
// Emulate click and double click in touch devices to support backdrop and image zooming (#210).
|
|
1730
|
+
if (IS_TOUCH_DEVICE && action !== ACTION_ZOOM && pointer && Date.now() - pointer.timeStamp < 500) {
|
|
1731
|
+
clearTimeout(this.clickCanvasTimeout);
|
|
1732
|
+
clearTimeout(this.doubleClickImageTimeout);
|
|
1733
|
+
if (options.toggleOnDblclick && this.viewed && event.target === this.image) {
|
|
1734
|
+
if (this.imageClicked) {
|
|
1735
|
+
this.imageClicked = false;
|
|
1736
|
+
|
|
1737
|
+
// This timeout will be cleared later when a native dblclick event is triggering
|
|
1738
|
+
this.doubleClickImageTimeout = setTimeout(function () {
|
|
1739
|
+
dispatchEvent(_this2.image, EVENT_DBLCLICK, {
|
|
1740
|
+
originalEvent: event
|
|
1741
|
+
});
|
|
1742
|
+
}, 50);
|
|
1743
|
+
} else {
|
|
1744
|
+
this.imageClicked = true;
|
|
1745
|
+
|
|
1746
|
+
// The default timing of a double click in Windows is 500 ms
|
|
1747
|
+
this.doubleClickImageTimeout = setTimeout(function () {
|
|
1748
|
+
_this2.imageClicked = false;
|
|
1749
|
+
}, 500);
|
|
1750
|
+
}
|
|
1751
|
+
} else {
|
|
1752
|
+
this.imageClicked = false;
|
|
1753
|
+
if (options.backdrop && options.backdrop !== 'static' && event.target === this.canvas) {
|
|
1754
|
+
// This timeout will be cleared later when a native click event is triggering
|
|
1755
|
+
this.clickCanvasTimeout = setTimeout(function () {
|
|
1756
|
+
dispatchEvent(_this2.canvas, EVENT_CLICK, {
|
|
1757
|
+
originalEvent: event
|
|
1758
|
+
});
|
|
1759
|
+
}, 50);
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
}
|
|
1763
|
+
},
|
|
1764
|
+
resize: function resize() {
|
|
1765
|
+
var _this3 = this;
|
|
1766
|
+
if (!this.isShown || this.hiding) {
|
|
1767
|
+
return;
|
|
1768
|
+
}
|
|
1769
|
+
if (this.fulled) {
|
|
1770
|
+
this.close();
|
|
1771
|
+
this.initBody();
|
|
1772
|
+
this.open();
|
|
1773
|
+
}
|
|
1774
|
+
this.initContainer();
|
|
1775
|
+
this.initViewer();
|
|
1776
|
+
this.renderViewer();
|
|
1777
|
+
this.renderList();
|
|
1778
|
+
if (this.viewed) {
|
|
1779
|
+
this.initImage(function () {
|
|
1780
|
+
_this3.renderImage();
|
|
1781
|
+
});
|
|
1782
|
+
}
|
|
1783
|
+
if (this.played) {
|
|
1784
|
+
if (this.options.fullscreen && this.fulled && !(document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement)) {
|
|
1785
|
+
this.stop();
|
|
1786
|
+
return;
|
|
1787
|
+
}
|
|
1788
|
+
forEach(this.player.getElementsByTagName('img'), function (image) {
|
|
1789
|
+
addListener(image, EVENT_LOAD, _this3.loadImage.bind(_this3), {
|
|
1790
|
+
once: true
|
|
1791
|
+
});
|
|
1792
|
+
dispatchEvent(image, EVENT_LOAD);
|
|
1793
|
+
});
|
|
1794
|
+
}
|
|
1795
|
+
},
|
|
1796
|
+
wheel: function wheel(event) {
|
|
1797
|
+
var _this4 = this;
|
|
1798
|
+
if (!this.viewed) {
|
|
1799
|
+
return;
|
|
1800
|
+
}
|
|
1801
|
+
event.preventDefault();
|
|
1802
|
+
|
|
1803
|
+
// Limit wheel speed to prevent zoom too fast
|
|
1804
|
+
if (this.wheeling) {
|
|
1805
|
+
return;
|
|
1806
|
+
}
|
|
1807
|
+
this.wheeling = true;
|
|
1808
|
+
setTimeout(function () {
|
|
1809
|
+
_this4.wheeling = false;
|
|
1810
|
+
}, 50);
|
|
1811
|
+
var ratio = Number(this.options.zoomRatio) || 0.1;
|
|
1812
|
+
var delta = 1;
|
|
1813
|
+
if (event.deltaY) {
|
|
1814
|
+
delta = event.deltaY > 0 ? 1 : -1;
|
|
1815
|
+
} else if (event.wheelDelta) {
|
|
1816
|
+
delta = -event.wheelDelta / 120;
|
|
1817
|
+
} else if (event.detail) {
|
|
1818
|
+
delta = event.detail > 0 ? 1 : -1;
|
|
1819
|
+
}
|
|
1820
|
+
this.zoom(-delta * ratio, true, null, event);
|
|
1821
|
+
}
|
|
1822
|
+
};
|
|
1823
|
+
|
|
1824
|
+
var methods = {
|
|
1825
|
+
/** Show the viewer (only available in modal mode)
|
|
1826
|
+
* @param {boolean} [immediate=false] - Indicates if show the viewer immediately or not.
|
|
1827
|
+
* @returns {Viewer} this
|
|
1828
|
+
*/
|
|
1829
|
+
show: function show() {
|
|
1830
|
+
var immediate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
1831
|
+
var element = this.element,
|
|
1832
|
+
options = this.options;
|
|
1833
|
+
if (options.inline || this.showing || this.isShown || this.showing) {
|
|
1834
|
+
return this;
|
|
1835
|
+
}
|
|
1836
|
+
if (!this.ready) {
|
|
1837
|
+
this.build();
|
|
1838
|
+
if (this.ready) {
|
|
1839
|
+
this.show(immediate);
|
|
1840
|
+
}
|
|
1841
|
+
return this;
|
|
1842
|
+
}
|
|
1843
|
+
if (isFunction(options.show)) {
|
|
1844
|
+
addListener(element, EVENT_SHOW, options.show, {
|
|
1845
|
+
once: true
|
|
1846
|
+
});
|
|
1847
|
+
}
|
|
1848
|
+
if (dispatchEvent(element, EVENT_SHOW) === false || !this.ready) {
|
|
1849
|
+
return this;
|
|
1850
|
+
}
|
|
1851
|
+
if (this.hiding) {
|
|
1852
|
+
this.transitioning.abort();
|
|
1853
|
+
}
|
|
1854
|
+
this.showing = true;
|
|
1855
|
+
this.open();
|
|
1856
|
+
var viewer = this.viewer;
|
|
1857
|
+
removeClass(viewer, CLASS_HIDE);
|
|
1858
|
+
viewer.setAttribute('role', 'dialog');
|
|
1859
|
+
viewer.setAttribute('aria-labelledby', this.title.id);
|
|
1860
|
+
viewer.setAttribute('aria-modal', true);
|
|
1861
|
+
viewer.removeAttribute('aria-hidden');
|
|
1862
|
+
if (options.transition && !immediate) {
|
|
1863
|
+
var shown = this.shown.bind(this);
|
|
1864
|
+
this.transitioning = {
|
|
1865
|
+
abort: function abort() {
|
|
1866
|
+
removeListener(viewer, EVENT_TRANSITION_END, shown);
|
|
1867
|
+
removeClass(viewer, CLASS_IN);
|
|
1868
|
+
}
|
|
1869
|
+
};
|
|
1870
|
+
addClass(viewer, CLASS_TRANSITION);
|
|
1871
|
+
|
|
1872
|
+
// Force reflow to enable CSS3 transition
|
|
1873
|
+
viewer.initialOffsetWidth = viewer.offsetWidth;
|
|
1874
|
+
addListener(viewer, EVENT_TRANSITION_END, shown, {
|
|
1875
|
+
once: true
|
|
1876
|
+
});
|
|
1877
|
+
addClass(viewer, CLASS_IN);
|
|
1878
|
+
} else {
|
|
1879
|
+
addClass(viewer, CLASS_IN);
|
|
1880
|
+
this.shown();
|
|
1881
|
+
}
|
|
1882
|
+
return this;
|
|
1883
|
+
},
|
|
1884
|
+
/**
|
|
1885
|
+
* Hide the viewer (only available in modal mode)
|
|
1886
|
+
* @param {boolean} [immediate=false] - Indicates if hide the viewer immediately or not.
|
|
1887
|
+
* @returns {Viewer} this
|
|
1888
|
+
*/
|
|
1889
|
+
hide: function hide() {
|
|
1890
|
+
var _this = this;
|
|
1891
|
+
var immediate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
1892
|
+
var element = this.element,
|
|
1893
|
+
options = this.options;
|
|
1894
|
+
if (options.inline || this.hiding || !(this.isShown || this.showing)) {
|
|
1895
|
+
return this;
|
|
1896
|
+
}
|
|
1897
|
+
if (isFunction(options.hide)) {
|
|
1898
|
+
addListener(element, EVENT_HIDE, options.hide, {
|
|
1899
|
+
once: true
|
|
1900
|
+
});
|
|
1901
|
+
}
|
|
1902
|
+
if (dispatchEvent(element, EVENT_HIDE) === false) {
|
|
1903
|
+
return this;
|
|
1904
|
+
}
|
|
1905
|
+
if (this.showing) {
|
|
1906
|
+
this.transitioning.abort();
|
|
1907
|
+
}
|
|
1908
|
+
this.hiding = true;
|
|
1909
|
+
if (this.played) {
|
|
1910
|
+
this.stop();
|
|
1911
|
+
} else if (this.viewing) {
|
|
1912
|
+
this.viewing.abort();
|
|
1913
|
+
}
|
|
1914
|
+
var viewer = this.viewer,
|
|
1915
|
+
image = this.image;
|
|
1916
|
+
var hideImmediately = function hideImmediately() {
|
|
1917
|
+
removeClass(viewer, CLASS_IN);
|
|
1918
|
+
_this.hidden();
|
|
1919
|
+
};
|
|
1920
|
+
if (options.transition && !immediate) {
|
|
1921
|
+
var _onViewerTransitionEnd = function onViewerTransitionEnd(event) {
|
|
1922
|
+
// Ignore all propagating `transitionend` events (#275).
|
|
1923
|
+
if (event && event.target === viewer) {
|
|
1924
|
+
removeListener(viewer, EVENT_TRANSITION_END, _onViewerTransitionEnd);
|
|
1925
|
+
_this.hidden();
|
|
1926
|
+
}
|
|
1927
|
+
};
|
|
1928
|
+
var onImageTransitionEnd = function onImageTransitionEnd() {
|
|
1929
|
+
// In case of show the viewer by `viewer.show(true)` previously (#407).
|
|
1930
|
+
if (hasClass(viewer, CLASS_TRANSITION)) {
|
|
1931
|
+
addListener(viewer, EVENT_TRANSITION_END, _onViewerTransitionEnd);
|
|
1932
|
+
removeClass(viewer, CLASS_IN);
|
|
1933
|
+
} else {
|
|
1934
|
+
hideImmediately();
|
|
1935
|
+
}
|
|
1936
|
+
};
|
|
1937
|
+
this.transitioning = {
|
|
1938
|
+
abort: function abort() {
|
|
1939
|
+
if (_this.viewed && hasClass(image, CLASS_TRANSITION)) {
|
|
1940
|
+
removeListener(image, EVENT_TRANSITION_END, onImageTransitionEnd);
|
|
1941
|
+
} else if (hasClass(viewer, CLASS_TRANSITION)) {
|
|
1942
|
+
removeListener(viewer, EVENT_TRANSITION_END, _onViewerTransitionEnd);
|
|
1943
|
+
}
|
|
1944
|
+
}
|
|
1945
|
+
};
|
|
1946
|
+
|
|
1947
|
+
// In case of hiding the viewer when holding on the image (#255),
|
|
1948
|
+
// note that the `CLASS_TRANSITION` class will be removed on pointer down.
|
|
1949
|
+
if (this.viewed && hasClass(image, CLASS_TRANSITION)) {
|
|
1950
|
+
addListener(image, EVENT_TRANSITION_END, onImageTransitionEnd, {
|
|
1951
|
+
once: true
|
|
1952
|
+
});
|
|
1953
|
+
this.zoomTo(0, false, null, null, true);
|
|
1954
|
+
} else {
|
|
1955
|
+
onImageTransitionEnd();
|
|
1956
|
+
}
|
|
1957
|
+
} else {
|
|
1958
|
+
hideImmediately();
|
|
1959
|
+
}
|
|
1960
|
+
return this;
|
|
1961
|
+
},
|
|
1962
|
+
/**
|
|
1963
|
+
* View one of the images with image's index
|
|
1964
|
+
* @param {number} index - The index of the image to view.
|
|
1965
|
+
* @returns {Viewer} this
|
|
1966
|
+
*/
|
|
1967
|
+
view: function view() {
|
|
1968
|
+
var _this2 = this;
|
|
1969
|
+
var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.options.initialViewIndex;
|
|
1970
|
+
index = Number(index) || 0;
|
|
1971
|
+
if (this.hiding || this.played || index < 0 || index >= this.length || this.viewed && index === this.index) {
|
|
1972
|
+
return this;
|
|
1973
|
+
}
|
|
1974
|
+
if (!this.isShown) {
|
|
1975
|
+
this.index = index;
|
|
1976
|
+
return this.show();
|
|
1977
|
+
}
|
|
1978
|
+
if (this.viewing) {
|
|
1979
|
+
this.viewing.abort();
|
|
1980
|
+
}
|
|
1981
|
+
var element = this.element,
|
|
1982
|
+
options = this.options,
|
|
1983
|
+
title = this.title,
|
|
1984
|
+
canvas = this.canvas;
|
|
1985
|
+
var item = this.items[index];
|
|
1986
|
+
var img = item.querySelector('img');
|
|
1987
|
+
var url = getData(img, 'originalUrl');
|
|
1988
|
+
var alt = img.getAttribute('alt');
|
|
1989
|
+
var image = document.createElement('img');
|
|
1990
|
+
forEach(options.inheritedAttributes, function (name) {
|
|
1991
|
+
var value = img.getAttribute(name);
|
|
1992
|
+
if (value !== null) {
|
|
1993
|
+
image.setAttribute(name, value);
|
|
1994
|
+
}
|
|
1995
|
+
});
|
|
1996
|
+
image.src = url;
|
|
1997
|
+
image.alt = alt;
|
|
1998
|
+
if (isFunction(options.view)) {
|
|
1999
|
+
addListener(element, EVENT_VIEW, options.view, {
|
|
2000
|
+
once: true
|
|
2001
|
+
});
|
|
2002
|
+
}
|
|
2003
|
+
if (dispatchEvent(element, EVENT_VIEW, {
|
|
2004
|
+
originalImage: this.images[index],
|
|
2005
|
+
index: index,
|
|
2006
|
+
image: image
|
|
2007
|
+
}) === false || !this.isShown || this.hiding || this.played) {
|
|
2008
|
+
return this;
|
|
2009
|
+
}
|
|
2010
|
+
var activeItem = this.items[this.index];
|
|
2011
|
+
if (activeItem) {
|
|
2012
|
+
removeClass(activeItem, CLASS_ACTIVE);
|
|
2013
|
+
activeItem.removeAttribute('aria-selected');
|
|
2014
|
+
}
|
|
2015
|
+
addClass(item, CLASS_ACTIVE);
|
|
2016
|
+
item.setAttribute('aria-selected', true);
|
|
2017
|
+
if (options.focus) {
|
|
2018
|
+
item.focus();
|
|
2019
|
+
}
|
|
2020
|
+
this.image = image;
|
|
2021
|
+
this.viewed = false;
|
|
2022
|
+
this.index = index;
|
|
2023
|
+
this.imageData = {};
|
|
2024
|
+
addClass(image, CLASS_INVISIBLE);
|
|
2025
|
+
if (options.loading) {
|
|
2026
|
+
addClass(canvas, CLASS_LOADING);
|
|
2027
|
+
}
|
|
2028
|
+
canvas.innerHTML = '';
|
|
2029
|
+
canvas.appendChild(image);
|
|
2030
|
+
|
|
2031
|
+
// Center current item
|
|
2032
|
+
this.renderList();
|
|
2033
|
+
|
|
2034
|
+
// Clear title
|
|
2035
|
+
title.innerHTML = '';
|
|
2036
|
+
|
|
2037
|
+
// Generate title after viewed
|
|
2038
|
+
var onViewed = function onViewed() {
|
|
2039
|
+
var imageData = _this2.imageData;
|
|
2040
|
+
var render = Array.isArray(options.title) ? options.title[1] : options.title;
|
|
2041
|
+
title.innerHTML = escapeHTMLEntities(isFunction(render) ? render.call(_this2, image, imageData) : "".concat(alt, " (").concat(imageData.naturalWidth, " \xD7 ").concat(imageData.naturalHeight, ")"));
|
|
2042
|
+
};
|
|
2043
|
+
var onLoad;
|
|
2044
|
+
var onError;
|
|
2045
|
+
addListener(element, EVENT_VIEWED, onViewed, {
|
|
2046
|
+
once: true
|
|
2047
|
+
});
|
|
2048
|
+
this.viewing = {
|
|
2049
|
+
abort: function abort() {
|
|
2050
|
+
removeListener(element, EVENT_VIEWED, onViewed);
|
|
2051
|
+
if (image.complete) {
|
|
2052
|
+
if (_this2.imageRendering) {
|
|
2053
|
+
_this2.imageRendering.abort();
|
|
2054
|
+
} else if (_this2.imageInitializing) {
|
|
2055
|
+
_this2.imageInitializing.abort();
|
|
2056
|
+
}
|
|
2057
|
+
} else {
|
|
2058
|
+
// Cancel download to save bandwidth.
|
|
2059
|
+
image.src = '';
|
|
2060
|
+
removeListener(image, EVENT_LOAD, onLoad);
|
|
2061
|
+
if (_this2.timeout) {
|
|
2062
|
+
clearTimeout(_this2.timeout);
|
|
2063
|
+
}
|
|
2064
|
+
}
|
|
2065
|
+
}
|
|
2066
|
+
};
|
|
2067
|
+
if (image.complete) {
|
|
2068
|
+
this.load();
|
|
2069
|
+
} else {
|
|
2070
|
+
addListener(image, EVENT_LOAD, onLoad = function onLoad() {
|
|
2071
|
+
removeListener(image, EVENT_ERROR, onError);
|
|
2072
|
+
_this2.load();
|
|
2073
|
+
}, {
|
|
2074
|
+
once: true
|
|
2075
|
+
});
|
|
2076
|
+
addListener(image, EVENT_ERROR, onError = function onError() {
|
|
2077
|
+
removeListener(image, EVENT_LOAD, onLoad);
|
|
2078
|
+
if (_this2.timeout) {
|
|
2079
|
+
clearTimeout(_this2.timeout);
|
|
2080
|
+
_this2.timeout = false;
|
|
2081
|
+
}
|
|
2082
|
+
removeClass(image, CLASS_INVISIBLE);
|
|
2083
|
+
if (options.loading) {
|
|
2084
|
+
removeClass(_this2.canvas, CLASS_LOADING);
|
|
2085
|
+
}
|
|
2086
|
+
}, {
|
|
2087
|
+
once: true
|
|
2088
|
+
});
|
|
2089
|
+
if (this.timeout) {
|
|
2090
|
+
clearTimeout(this.timeout);
|
|
2091
|
+
}
|
|
2092
|
+
|
|
2093
|
+
// Make the image visible if it fails to load within 1s
|
|
2094
|
+
this.timeout = setTimeout(function () {
|
|
2095
|
+
removeClass(image, CLASS_INVISIBLE);
|
|
2096
|
+
_this2.timeout = false;
|
|
2097
|
+
}, 1000);
|
|
2098
|
+
}
|
|
2099
|
+
return this;
|
|
2100
|
+
},
|
|
2101
|
+
/**
|
|
2102
|
+
* View the previous image
|
|
2103
|
+
* @param {boolean} [loop=false] - Indicate if view the last one
|
|
2104
|
+
* when it is the first one at present.
|
|
2105
|
+
* @returns {Viewer} this
|
|
2106
|
+
*/
|
|
2107
|
+
prev: function prev() {
|
|
2108
|
+
var loop = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
2109
|
+
var index = this.index - 1;
|
|
2110
|
+
if (index < 0) {
|
|
2111
|
+
index = loop ? this.length - 1 : 0;
|
|
2112
|
+
}
|
|
2113
|
+
this.view(index);
|
|
2114
|
+
return this;
|
|
2115
|
+
},
|
|
2116
|
+
/**
|
|
2117
|
+
* View the next image
|
|
2118
|
+
* @param {boolean} [loop=false] - Indicate if view the first one
|
|
2119
|
+
* when it is the last one at present.
|
|
2120
|
+
* @returns {Viewer} this
|
|
2121
|
+
*/
|
|
2122
|
+
next: function next() {
|
|
2123
|
+
var loop = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
2124
|
+
var maxIndex = this.length - 1;
|
|
2125
|
+
var index = this.index + 1;
|
|
2126
|
+
if (index > maxIndex) {
|
|
2127
|
+
index = loop ? 0 : maxIndex;
|
|
2128
|
+
}
|
|
2129
|
+
this.view(index);
|
|
2130
|
+
return this;
|
|
2131
|
+
},
|
|
2132
|
+
/**
|
|
2133
|
+
* Move the image with relative offsets.
|
|
2134
|
+
* @param {number} x - The moving distance in the horizontal direction.
|
|
2135
|
+
* @param {number} [y=x] The moving distance in the vertical direction.
|
|
2136
|
+
* @returns {Viewer} this
|
|
2137
|
+
*/
|
|
2138
|
+
move: function move(x) {
|
|
2139
|
+
var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : x;
|
|
2140
|
+
var imageData = this.imageData;
|
|
2141
|
+
this.moveTo(isUndefined(x) ? x : imageData.x + Number(x), isUndefined(y) ? y : imageData.y + Number(y));
|
|
2142
|
+
return this;
|
|
2143
|
+
},
|
|
2144
|
+
/**
|
|
2145
|
+
* Move the image to an absolute point.
|
|
2146
|
+
* @param {number} x - The new position in the horizontal direction.
|
|
2147
|
+
* @param {number} [y=x] - The new position in the vertical direction.
|
|
2148
|
+
* @param {Event} [_originalEvent=null] - The original event if any.
|
|
2149
|
+
* @returns {Viewer} this
|
|
2150
|
+
*/
|
|
2151
|
+
moveTo: function moveTo(x) {
|
|
2152
|
+
var _this3 = this;
|
|
2153
|
+
var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : x;
|
|
2154
|
+
var _originalEvent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
2155
|
+
var element = this.element,
|
|
2156
|
+
options = this.options,
|
|
2157
|
+
imageData = this.imageData;
|
|
2158
|
+
x = Number(x);
|
|
2159
|
+
y = Number(y);
|
|
2160
|
+
if (this.viewed && !this.played && options.movable) {
|
|
2161
|
+
var oldX = imageData.x;
|
|
2162
|
+
var oldY = imageData.y;
|
|
2163
|
+
var changed = false;
|
|
2164
|
+
if (isNumber(x)) {
|
|
2165
|
+
changed = true;
|
|
2166
|
+
} else {
|
|
2167
|
+
x = oldX;
|
|
2168
|
+
}
|
|
2169
|
+
if (isNumber(y)) {
|
|
2170
|
+
changed = true;
|
|
2171
|
+
} else {
|
|
2172
|
+
y = oldY;
|
|
2173
|
+
}
|
|
2174
|
+
if (changed) {
|
|
2175
|
+
if (isFunction(options.move)) {
|
|
2176
|
+
addListener(element, EVENT_MOVE, options.move, {
|
|
2177
|
+
once: true
|
|
2178
|
+
});
|
|
2179
|
+
}
|
|
2180
|
+
if (dispatchEvent(element, EVENT_MOVE, {
|
|
2181
|
+
x: x,
|
|
2182
|
+
y: y,
|
|
2183
|
+
oldX: oldX,
|
|
2184
|
+
oldY: oldY,
|
|
2185
|
+
originalEvent: _originalEvent
|
|
2186
|
+
}) === false) {
|
|
2187
|
+
return this;
|
|
2188
|
+
}
|
|
2189
|
+
imageData.x = x;
|
|
2190
|
+
imageData.y = y;
|
|
2191
|
+
imageData.left = x;
|
|
2192
|
+
imageData.top = y;
|
|
2193
|
+
this.moving = true;
|
|
2194
|
+
this.renderImage(function () {
|
|
2195
|
+
_this3.moving = false;
|
|
2196
|
+
if (isFunction(options.moved)) {
|
|
2197
|
+
addListener(element, EVENT_MOVED, options.moved, {
|
|
2198
|
+
once: true
|
|
2199
|
+
});
|
|
2200
|
+
}
|
|
2201
|
+
dispatchEvent(element, EVENT_MOVED, {
|
|
2202
|
+
x: x,
|
|
2203
|
+
y: y,
|
|
2204
|
+
oldX: oldX,
|
|
2205
|
+
oldY: oldY,
|
|
2206
|
+
originalEvent: _originalEvent
|
|
2207
|
+
}, {
|
|
2208
|
+
cancelable: false
|
|
2209
|
+
});
|
|
2210
|
+
});
|
|
2211
|
+
}
|
|
2212
|
+
}
|
|
2213
|
+
return this;
|
|
2214
|
+
},
|
|
2215
|
+
/**
|
|
2216
|
+
* Rotate the image with a relative degree.
|
|
2217
|
+
* @param {number} degree - The rotate degree.
|
|
2218
|
+
* @returns {Viewer} this
|
|
2219
|
+
*/
|
|
2220
|
+
rotate: function rotate(degree) {
|
|
2221
|
+
this.rotateTo((this.imageData.rotate || 0) + Number(degree));
|
|
2222
|
+
return this;
|
|
2223
|
+
},
|
|
2224
|
+
/**
|
|
2225
|
+
* Rotate the image to an absolute degree.
|
|
2226
|
+
* @param {number} degree - The rotate degree.
|
|
2227
|
+
* @returns {Viewer} this
|
|
2228
|
+
*/
|
|
2229
|
+
rotateTo: function rotateTo(degree) {
|
|
2230
|
+
var _this4 = this;
|
|
2231
|
+
var element = this.element,
|
|
2232
|
+
options = this.options,
|
|
2233
|
+
imageData = this.imageData;
|
|
2234
|
+
degree = Number(degree);
|
|
2235
|
+
if (isNumber(degree) && this.viewed && !this.played && options.rotatable) {
|
|
2236
|
+
var oldDegree = imageData.rotate;
|
|
2237
|
+
if (isFunction(options.rotate)) {
|
|
2238
|
+
addListener(element, EVENT_ROTATE, options.rotate, {
|
|
2239
|
+
once: true
|
|
2240
|
+
});
|
|
2241
|
+
}
|
|
2242
|
+
if (dispatchEvent(element, EVENT_ROTATE, {
|
|
2243
|
+
degree: degree,
|
|
2244
|
+
oldDegree: oldDegree
|
|
2245
|
+
}) === false) {
|
|
2246
|
+
return this;
|
|
2247
|
+
}
|
|
2248
|
+
imageData.rotate = degree;
|
|
2249
|
+
this.rotating = true;
|
|
2250
|
+
this.renderImage(function () {
|
|
2251
|
+
_this4.rotating = false;
|
|
2252
|
+
if (isFunction(options.rotated)) {
|
|
2253
|
+
addListener(element, EVENT_ROTATED, options.rotated, {
|
|
2254
|
+
once: true
|
|
2255
|
+
});
|
|
2256
|
+
}
|
|
2257
|
+
dispatchEvent(element, EVENT_ROTATED, {
|
|
2258
|
+
degree: degree,
|
|
2259
|
+
oldDegree: oldDegree
|
|
2260
|
+
}, {
|
|
2261
|
+
cancelable: false
|
|
2262
|
+
});
|
|
2263
|
+
});
|
|
2264
|
+
}
|
|
2265
|
+
return this;
|
|
2266
|
+
},
|
|
2267
|
+
/**
|
|
2268
|
+
* Scale the image on the x-axis.
|
|
2269
|
+
* @param {number} scaleX - The scale ratio on the x-axis.
|
|
2270
|
+
* @returns {Viewer} this
|
|
2271
|
+
*/
|
|
2272
|
+
scaleX: function scaleX(_scaleX) {
|
|
2273
|
+
this.scale(_scaleX, this.imageData.scaleY);
|
|
2274
|
+
return this;
|
|
2275
|
+
},
|
|
2276
|
+
/**
|
|
2277
|
+
* Scale the image on the y-axis.
|
|
2278
|
+
* @param {number} scaleY - The scale ratio on the y-axis.
|
|
2279
|
+
* @returns {Viewer} this
|
|
2280
|
+
*/
|
|
2281
|
+
scaleY: function scaleY(_scaleY) {
|
|
2282
|
+
this.scale(this.imageData.scaleX, _scaleY);
|
|
2283
|
+
return this;
|
|
2284
|
+
},
|
|
2285
|
+
/**
|
|
2286
|
+
* Scale the image.
|
|
2287
|
+
* @param {number} scaleX - The scale ratio on the x-axis.
|
|
2288
|
+
* @param {number} [scaleY=scaleX] - The scale ratio on the y-axis.
|
|
2289
|
+
* @returns {Viewer} this
|
|
2290
|
+
*/
|
|
2291
|
+
scale: function scale(scaleX) {
|
|
2292
|
+
var _this5 = this;
|
|
2293
|
+
var scaleY = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : scaleX;
|
|
2294
|
+
var element = this.element,
|
|
2295
|
+
options = this.options,
|
|
2296
|
+
imageData = this.imageData;
|
|
2297
|
+
scaleX = Number(scaleX);
|
|
2298
|
+
scaleY = Number(scaleY);
|
|
2299
|
+
if (this.viewed && !this.played && options.scalable) {
|
|
2300
|
+
var oldScaleX = imageData.scaleX;
|
|
2301
|
+
var oldScaleY = imageData.scaleY;
|
|
2302
|
+
var changed = false;
|
|
2303
|
+
if (isNumber(scaleX)) {
|
|
2304
|
+
changed = true;
|
|
2305
|
+
} else {
|
|
2306
|
+
scaleX = oldScaleX;
|
|
2307
|
+
}
|
|
2308
|
+
if (isNumber(scaleY)) {
|
|
2309
|
+
changed = true;
|
|
2310
|
+
} else {
|
|
2311
|
+
scaleY = oldScaleY;
|
|
2312
|
+
}
|
|
2313
|
+
if (changed) {
|
|
2314
|
+
if (isFunction(options.scale)) {
|
|
2315
|
+
addListener(element, EVENT_SCALE, options.scale, {
|
|
2316
|
+
once: true
|
|
2317
|
+
});
|
|
2318
|
+
}
|
|
2319
|
+
if (dispatchEvent(element, EVENT_SCALE, {
|
|
2320
|
+
scaleX: scaleX,
|
|
2321
|
+
scaleY: scaleY,
|
|
2322
|
+
oldScaleX: oldScaleX,
|
|
2323
|
+
oldScaleY: oldScaleY
|
|
2324
|
+
}) === false) {
|
|
2325
|
+
return this;
|
|
2326
|
+
}
|
|
2327
|
+
imageData.scaleX = scaleX;
|
|
2328
|
+
imageData.scaleY = scaleY;
|
|
2329
|
+
this.scaling = true;
|
|
2330
|
+
this.renderImage(function () {
|
|
2331
|
+
_this5.scaling = false;
|
|
2332
|
+
if (isFunction(options.scaled)) {
|
|
2333
|
+
addListener(element, EVENT_SCALED, options.scaled, {
|
|
2334
|
+
once: true
|
|
2335
|
+
});
|
|
2336
|
+
}
|
|
2337
|
+
dispatchEvent(element, EVENT_SCALED, {
|
|
2338
|
+
scaleX: scaleX,
|
|
2339
|
+
scaleY: scaleY,
|
|
2340
|
+
oldScaleX: oldScaleX,
|
|
2341
|
+
oldScaleY: oldScaleY
|
|
2342
|
+
}, {
|
|
2343
|
+
cancelable: false
|
|
2344
|
+
});
|
|
2345
|
+
});
|
|
2346
|
+
}
|
|
2347
|
+
}
|
|
2348
|
+
return this;
|
|
2349
|
+
},
|
|
2350
|
+
/**
|
|
2351
|
+
* Zoom the image with a relative ratio.
|
|
2352
|
+
* @param {number} ratio - The target ratio.
|
|
2353
|
+
* @param {boolean} [showTooltip=false] - Indicates whether to show the tooltip.
|
|
2354
|
+
* @param {Object} [pivot] - The pivot point coordinate for zooming.
|
|
2355
|
+
* @param {Event} [_originalEvent=null] - The original event if any.
|
|
2356
|
+
* @returns {Viewer} this
|
|
2357
|
+
*/
|
|
2358
|
+
zoom: function zoom(ratio) {
|
|
2359
|
+
var showTooltip = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
2360
|
+
var pivot = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
2361
|
+
var _originalEvent = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
2362
|
+
var imageData = this.imageData;
|
|
2363
|
+
ratio = Number(ratio);
|
|
2364
|
+
if (ratio < 0) {
|
|
2365
|
+
ratio = 1 / (1 - ratio);
|
|
2366
|
+
} else {
|
|
2367
|
+
ratio = 1 + ratio;
|
|
2368
|
+
}
|
|
2369
|
+
this.zoomTo(imageData.width * ratio / imageData.naturalWidth, showTooltip, pivot, _originalEvent);
|
|
2370
|
+
return this;
|
|
2371
|
+
},
|
|
2372
|
+
/**
|
|
2373
|
+
* Zoom the image to an absolute ratio.
|
|
2374
|
+
* @param {number} ratio - The target ratio.
|
|
2375
|
+
* @param {boolean} [showTooltip] - Indicates whether to show the tooltip.
|
|
2376
|
+
* @param {Object} [pivot] - The pivot point coordinate for zooming.
|
|
2377
|
+
* @param {Event} [_originalEvent=null] - The original event if any.
|
|
2378
|
+
* @param {Event} [_zoomable=false] - Indicates if the current zoom is available or not.
|
|
2379
|
+
* @returns {Viewer} this
|
|
2380
|
+
*/
|
|
2381
|
+
zoomTo: function zoomTo(ratio) {
|
|
2382
|
+
var _this6 = this;
|
|
2383
|
+
var showTooltip = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
2384
|
+
var pivot = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
2385
|
+
var _originalEvent = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
2386
|
+
var _zoomable = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
2387
|
+
var element = this.element,
|
|
2388
|
+
options = this.options,
|
|
2389
|
+
pointers = this.pointers,
|
|
2390
|
+
imageData = this.imageData;
|
|
2391
|
+
var x = imageData.x,
|
|
2392
|
+
y = imageData.y,
|
|
2393
|
+
width = imageData.width,
|
|
2394
|
+
height = imageData.height,
|
|
2395
|
+
naturalWidth = imageData.naturalWidth,
|
|
2396
|
+
naturalHeight = imageData.naturalHeight;
|
|
2397
|
+
ratio = Math.max(0, ratio);
|
|
2398
|
+
if (isNumber(ratio) && this.viewed && !this.played && (_zoomable || options.zoomable)) {
|
|
2399
|
+
if (!_zoomable) {
|
|
2400
|
+
var minZoomRatio = Math.max(0.01, options.minZoomRatio);
|
|
2401
|
+
var maxZoomRatio = Math.min(100, options.maxZoomRatio);
|
|
2402
|
+
ratio = Math.min(Math.max(ratio, minZoomRatio), maxZoomRatio);
|
|
2403
|
+
}
|
|
2404
|
+
if (_originalEvent) {
|
|
2405
|
+
switch (_originalEvent.type) {
|
|
2406
|
+
case 'wheel':
|
|
2407
|
+
if (options.zoomRatio >= 0.055 && ratio > 0.95 && ratio < 1.05) {
|
|
2408
|
+
ratio = 1;
|
|
2409
|
+
}
|
|
2410
|
+
break;
|
|
2411
|
+
case 'pointermove':
|
|
2412
|
+
case 'touchmove':
|
|
2413
|
+
case 'mousemove':
|
|
2414
|
+
if (ratio > 0.99 && ratio < 1.01) {
|
|
2415
|
+
ratio = 1;
|
|
2416
|
+
}
|
|
2417
|
+
break;
|
|
2418
|
+
}
|
|
2419
|
+
}
|
|
2420
|
+
var newWidth = naturalWidth * ratio;
|
|
2421
|
+
var newHeight = naturalHeight * ratio;
|
|
2422
|
+
var offsetWidth = newWidth - width;
|
|
2423
|
+
var offsetHeight = newHeight - height;
|
|
2424
|
+
var oldRatio = imageData.ratio;
|
|
2425
|
+
if (isFunction(options.zoom)) {
|
|
2426
|
+
addListener(element, EVENT_ZOOM, options.zoom, {
|
|
2427
|
+
once: true
|
|
2428
|
+
});
|
|
2429
|
+
}
|
|
2430
|
+
if (dispatchEvent(element, EVENT_ZOOM, {
|
|
2431
|
+
ratio: ratio,
|
|
2432
|
+
oldRatio: oldRatio,
|
|
2433
|
+
originalEvent: _originalEvent
|
|
2434
|
+
}) === false) {
|
|
2435
|
+
return this;
|
|
2436
|
+
}
|
|
2437
|
+
this.zooming = true;
|
|
2438
|
+
if (_originalEvent) {
|
|
2439
|
+
var offset = getOffset(this.viewer);
|
|
2440
|
+
var center = pointers && Object.keys(pointers).length > 0 ? getPointersCenter(pointers) : {
|
|
2441
|
+
pageX: _originalEvent.pageX,
|
|
2442
|
+
pageY: _originalEvent.pageY
|
|
2443
|
+
};
|
|
2444
|
+
|
|
2445
|
+
// Zoom from the triggering point of the event
|
|
2446
|
+
imageData.x -= offsetWidth * ((center.pageX - offset.left - x) / width);
|
|
2447
|
+
imageData.y -= offsetHeight * ((center.pageY - offset.top - y) / height);
|
|
2448
|
+
} else if (isPlainObject(pivot) && isNumber(pivot.x) && isNumber(pivot.y)) {
|
|
2449
|
+
imageData.x -= offsetWidth * ((pivot.x - x) / width);
|
|
2450
|
+
imageData.y -= offsetHeight * ((pivot.y - y) / height);
|
|
2451
|
+
} else {
|
|
2452
|
+
// Zoom from the center of the image
|
|
2453
|
+
imageData.x -= offsetWidth / 2;
|
|
2454
|
+
imageData.y -= offsetHeight / 2;
|
|
2455
|
+
}
|
|
2456
|
+
imageData.left = imageData.x;
|
|
2457
|
+
imageData.top = imageData.y;
|
|
2458
|
+
imageData.width = newWidth;
|
|
2459
|
+
imageData.height = newHeight;
|
|
2460
|
+
imageData.oldRatio = oldRatio;
|
|
2461
|
+
imageData.ratio = ratio;
|
|
2462
|
+
this.renderImage(function () {
|
|
2463
|
+
_this6.zooming = false;
|
|
2464
|
+
if (isFunction(options.zoomed)) {
|
|
2465
|
+
addListener(element, EVENT_ZOOMED, options.zoomed, {
|
|
2466
|
+
once: true
|
|
2467
|
+
});
|
|
2468
|
+
}
|
|
2469
|
+
dispatchEvent(element, EVENT_ZOOMED, {
|
|
2470
|
+
ratio: ratio,
|
|
2471
|
+
oldRatio: oldRatio,
|
|
2472
|
+
originalEvent: _originalEvent
|
|
2473
|
+
}, {
|
|
2474
|
+
cancelable: false
|
|
2475
|
+
});
|
|
2476
|
+
});
|
|
2477
|
+
if (showTooltip) {
|
|
2478
|
+
this.tooltip();
|
|
2479
|
+
}
|
|
2480
|
+
}
|
|
2481
|
+
return this;
|
|
2482
|
+
},
|
|
2483
|
+
/**
|
|
2484
|
+
* Play the images
|
|
2485
|
+
* @param {boolean|FullscreenOptions} [fullscreen=false] - Indicate if request fullscreen or not.
|
|
2486
|
+
* @returns {Viewer} this
|
|
2487
|
+
*/
|
|
2488
|
+
play: function play() {
|
|
2489
|
+
var _this7 = this;
|
|
2490
|
+
var fullscreen = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
2491
|
+
if (!this.isShown || this.played) {
|
|
2492
|
+
return this;
|
|
2493
|
+
}
|
|
2494
|
+
var element = this.element,
|
|
2495
|
+
options = this.options;
|
|
2496
|
+
if (isFunction(options.play)) {
|
|
2497
|
+
addListener(element, EVENT_PLAY, options.play, {
|
|
2498
|
+
once: true
|
|
2499
|
+
});
|
|
2500
|
+
}
|
|
2501
|
+
if (dispatchEvent(element, EVENT_PLAY) === false) {
|
|
2502
|
+
return this;
|
|
2503
|
+
}
|
|
2504
|
+
var player = this.player;
|
|
2505
|
+
var onLoad = this.loadImage.bind(this);
|
|
2506
|
+
var list = [];
|
|
2507
|
+
var total = 0;
|
|
2508
|
+
var index = 0;
|
|
2509
|
+
this.played = true;
|
|
2510
|
+
this.onLoadWhenPlay = onLoad;
|
|
2511
|
+
if (fullscreen) {
|
|
2512
|
+
this.requestFullscreen(fullscreen);
|
|
2513
|
+
}
|
|
2514
|
+
addClass(player, CLASS_SHOW);
|
|
2515
|
+
forEach(this.items, function (item, i) {
|
|
2516
|
+
var img = item.querySelector('img');
|
|
2517
|
+
var image = document.createElement('img');
|
|
2518
|
+
image.src = getData(img, 'originalUrl');
|
|
2519
|
+
image.alt = img.getAttribute('alt');
|
|
2520
|
+
image.referrerPolicy = img.referrerPolicy;
|
|
2521
|
+
total += 1;
|
|
2522
|
+
addClass(image, CLASS_FADE);
|
|
2523
|
+
toggleClass(image, CLASS_TRANSITION, options.transition);
|
|
2524
|
+
if (hasClass(item, CLASS_ACTIVE)) {
|
|
2525
|
+
addClass(image, CLASS_IN);
|
|
2526
|
+
index = i;
|
|
2527
|
+
}
|
|
2528
|
+
list.push(image);
|
|
2529
|
+
addListener(image, EVENT_LOAD, onLoad, {
|
|
2530
|
+
once: true
|
|
2531
|
+
});
|
|
2532
|
+
player.appendChild(image);
|
|
2533
|
+
});
|
|
2534
|
+
if (isNumber(options.interval) && options.interval > 0) {
|
|
2535
|
+
var _prev = function prev() {
|
|
2536
|
+
clearTimeout(_this7.playing.timeout);
|
|
2537
|
+
removeClass(list[index], CLASS_IN);
|
|
2538
|
+
index -= 1;
|
|
2539
|
+
index = index >= 0 ? index : total - 1;
|
|
2540
|
+
addClass(list[index], CLASS_IN);
|
|
2541
|
+
_this7.playing.timeout = setTimeout(_prev, options.interval);
|
|
2542
|
+
};
|
|
2543
|
+
var _next = function next() {
|
|
2544
|
+
clearTimeout(_this7.playing.timeout);
|
|
2545
|
+
removeClass(list[index], CLASS_IN);
|
|
2546
|
+
index += 1;
|
|
2547
|
+
index = index < total ? index : 0;
|
|
2548
|
+
addClass(list[index], CLASS_IN);
|
|
2549
|
+
_this7.playing.timeout = setTimeout(_next, options.interval);
|
|
2550
|
+
};
|
|
2551
|
+
if (total > 1) {
|
|
2552
|
+
this.playing = {
|
|
2553
|
+
prev: _prev,
|
|
2554
|
+
next: _next,
|
|
2555
|
+
timeout: setTimeout(_next, options.interval)
|
|
2556
|
+
};
|
|
2557
|
+
}
|
|
2558
|
+
}
|
|
2559
|
+
return this;
|
|
2560
|
+
},
|
|
2561
|
+
// Stop play
|
|
2562
|
+
stop: function stop() {
|
|
2563
|
+
var _this8 = this;
|
|
2564
|
+
if (!this.played) {
|
|
2565
|
+
return this;
|
|
2566
|
+
}
|
|
2567
|
+
var element = this.element,
|
|
2568
|
+
options = this.options;
|
|
2569
|
+
if (isFunction(options.stop)) {
|
|
2570
|
+
addListener(element, EVENT_STOP, options.stop, {
|
|
2571
|
+
once: true
|
|
2572
|
+
});
|
|
2573
|
+
}
|
|
2574
|
+
if (dispatchEvent(element, EVENT_STOP) === false) {
|
|
2575
|
+
return this;
|
|
2576
|
+
}
|
|
2577
|
+
var player = this.player;
|
|
2578
|
+
clearTimeout(this.playing.timeout);
|
|
2579
|
+
this.playing = false;
|
|
2580
|
+
this.played = false;
|
|
2581
|
+
forEach(player.getElementsByTagName('img'), function (image) {
|
|
2582
|
+
removeListener(image, EVENT_LOAD, _this8.onLoadWhenPlay);
|
|
2583
|
+
});
|
|
2584
|
+
removeClass(player, CLASS_SHOW);
|
|
2585
|
+
player.innerHTML = '';
|
|
2586
|
+
this.exitFullscreen();
|
|
2587
|
+
return this;
|
|
2588
|
+
},
|
|
2589
|
+
// Enter modal mode (only available in inline mode)
|
|
2590
|
+
full: function full() {
|
|
2591
|
+
var _this9 = this;
|
|
2592
|
+
var options = this.options,
|
|
2593
|
+
viewer = this.viewer,
|
|
2594
|
+
image = this.image,
|
|
2595
|
+
list = this.list;
|
|
2596
|
+
if (!this.isShown || this.played || this.fulled || !options.inline) {
|
|
2597
|
+
return this;
|
|
2598
|
+
}
|
|
2599
|
+
this.fulled = true;
|
|
2600
|
+
this.open();
|
|
2601
|
+
addClass(this.button, CLASS_FULLSCREEN_EXIT);
|
|
2602
|
+
if (options.transition) {
|
|
2603
|
+
removeClass(list, CLASS_TRANSITION);
|
|
2604
|
+
if (this.viewed) {
|
|
2605
|
+
removeClass(image, CLASS_TRANSITION);
|
|
2606
|
+
}
|
|
2607
|
+
}
|
|
2608
|
+
addClass(viewer, CLASS_FIXED);
|
|
2609
|
+
viewer.setAttribute('role', 'dialog');
|
|
2610
|
+
viewer.setAttribute('aria-labelledby', this.title.id);
|
|
2611
|
+
viewer.setAttribute('aria-modal', true);
|
|
2612
|
+
viewer.removeAttribute('style');
|
|
2613
|
+
setStyle(viewer, {
|
|
2614
|
+
zIndex: options.zIndex
|
|
2615
|
+
});
|
|
2616
|
+
if (options.focus) {
|
|
2617
|
+
this.enforceFocus();
|
|
2618
|
+
}
|
|
2619
|
+
this.initContainer();
|
|
2620
|
+
this.viewerData = assign({}, this.containerData);
|
|
2621
|
+
this.renderList();
|
|
2622
|
+
if (this.viewed) {
|
|
2623
|
+
this.initImage(function () {
|
|
2624
|
+
_this9.renderImage(function () {
|
|
2625
|
+
if (options.transition) {
|
|
2626
|
+
setTimeout(function () {
|
|
2627
|
+
addClass(image, CLASS_TRANSITION);
|
|
2628
|
+
addClass(list, CLASS_TRANSITION);
|
|
2629
|
+
}, 0);
|
|
2630
|
+
}
|
|
2631
|
+
});
|
|
2632
|
+
});
|
|
2633
|
+
}
|
|
2634
|
+
return this;
|
|
2635
|
+
},
|
|
2636
|
+
// Exit modal mode (only available in inline mode)
|
|
2637
|
+
exit: function exit() {
|
|
2638
|
+
var _this10 = this;
|
|
2639
|
+
var options = this.options,
|
|
2640
|
+
viewer = this.viewer,
|
|
2641
|
+
image = this.image,
|
|
2642
|
+
list = this.list;
|
|
2643
|
+
if (!this.isShown || this.played || !this.fulled || !options.inline) {
|
|
2644
|
+
return this;
|
|
2645
|
+
}
|
|
2646
|
+
this.fulled = false;
|
|
2647
|
+
this.close();
|
|
2648
|
+
removeClass(this.button, CLASS_FULLSCREEN_EXIT);
|
|
2649
|
+
if (options.transition) {
|
|
2650
|
+
removeClass(list, CLASS_TRANSITION);
|
|
2651
|
+
if (this.viewed) {
|
|
2652
|
+
removeClass(image, CLASS_TRANSITION);
|
|
2653
|
+
}
|
|
2654
|
+
}
|
|
2655
|
+
if (options.focus) {
|
|
2656
|
+
this.clearEnforceFocus();
|
|
2657
|
+
}
|
|
2658
|
+
viewer.removeAttribute('role');
|
|
2659
|
+
viewer.removeAttribute('aria-labelledby');
|
|
2660
|
+
viewer.removeAttribute('aria-modal');
|
|
2661
|
+
removeClass(viewer, CLASS_FIXED);
|
|
2662
|
+
setStyle(viewer, {
|
|
2663
|
+
zIndex: options.zIndexInline
|
|
2664
|
+
});
|
|
2665
|
+
this.viewerData = assign({}, this.parentData);
|
|
2666
|
+
this.renderViewer();
|
|
2667
|
+
this.renderList();
|
|
2668
|
+
if (this.viewed) {
|
|
2669
|
+
this.initImage(function () {
|
|
2670
|
+
_this10.renderImage(function () {
|
|
2671
|
+
if (options.transition) {
|
|
2672
|
+
setTimeout(function () {
|
|
2673
|
+
addClass(image, CLASS_TRANSITION);
|
|
2674
|
+
addClass(list, CLASS_TRANSITION);
|
|
2675
|
+
}, 0);
|
|
2676
|
+
}
|
|
2677
|
+
});
|
|
2678
|
+
});
|
|
2679
|
+
}
|
|
2680
|
+
return this;
|
|
2681
|
+
},
|
|
2682
|
+
// Show the current ratio of the image with percentage
|
|
2683
|
+
tooltip: function tooltip() {
|
|
2684
|
+
var _this11 = this;
|
|
2685
|
+
var options = this.options,
|
|
2686
|
+
tooltipBox = this.tooltipBox,
|
|
2687
|
+
imageData = this.imageData;
|
|
2688
|
+
if (!this.viewed || this.played || !options.tooltip) {
|
|
2689
|
+
return this;
|
|
2690
|
+
}
|
|
2691
|
+
tooltipBox.textContent = "".concat(Math.round(imageData.ratio * 100), "%");
|
|
2692
|
+
if (!this.tooltipping) {
|
|
2693
|
+
if (options.transition) {
|
|
2694
|
+
if (this.fading) {
|
|
2695
|
+
dispatchEvent(tooltipBox, EVENT_TRANSITION_END);
|
|
2696
|
+
}
|
|
2697
|
+
addClass(tooltipBox, CLASS_SHOW);
|
|
2698
|
+
addClass(tooltipBox, CLASS_FADE);
|
|
2699
|
+
addClass(tooltipBox, CLASS_TRANSITION);
|
|
2700
|
+
tooltipBox.removeAttribute('aria-hidden');
|
|
2701
|
+
|
|
2702
|
+
// Force reflow to enable CSS3 transition
|
|
2703
|
+
tooltipBox.initialOffsetWidth = tooltipBox.offsetWidth;
|
|
2704
|
+
addClass(tooltipBox, CLASS_IN);
|
|
2705
|
+
} else {
|
|
2706
|
+
addClass(tooltipBox, CLASS_SHOW);
|
|
2707
|
+
tooltipBox.removeAttribute('aria-hidden');
|
|
2708
|
+
}
|
|
2709
|
+
} else {
|
|
2710
|
+
clearTimeout(this.tooltipping);
|
|
2711
|
+
}
|
|
2712
|
+
this.tooltipping = setTimeout(function () {
|
|
2713
|
+
if (options.transition) {
|
|
2714
|
+
addListener(tooltipBox, EVENT_TRANSITION_END, function () {
|
|
2715
|
+
removeClass(tooltipBox, CLASS_SHOW);
|
|
2716
|
+
removeClass(tooltipBox, CLASS_FADE);
|
|
2717
|
+
removeClass(tooltipBox, CLASS_TRANSITION);
|
|
2718
|
+
tooltipBox.setAttribute('aria-hidden', true);
|
|
2719
|
+
_this11.fading = false;
|
|
2720
|
+
}, {
|
|
2721
|
+
once: true
|
|
2722
|
+
});
|
|
2723
|
+
removeClass(tooltipBox, CLASS_IN);
|
|
2724
|
+
_this11.fading = true;
|
|
2725
|
+
} else {
|
|
2726
|
+
removeClass(tooltipBox, CLASS_SHOW);
|
|
2727
|
+
tooltipBox.setAttribute('aria-hidden', true);
|
|
2728
|
+
}
|
|
2729
|
+
_this11.tooltipping = false;
|
|
2730
|
+
}, 1000);
|
|
2731
|
+
return this;
|
|
2732
|
+
},
|
|
2733
|
+
/**
|
|
2734
|
+
* Toggle the image size between its current size and natural size
|
|
2735
|
+
* @param {Event} [_originalEvent=null] - The original event if any.
|
|
2736
|
+
* @returns {Viewer} this
|
|
2737
|
+
*/
|
|
2738
|
+
toggle: function toggle() {
|
|
2739
|
+
var _originalEvent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
2740
|
+
if (this.imageData.ratio === 1) {
|
|
2741
|
+
this.zoomTo(this.imageData.oldRatio, true, null, _originalEvent);
|
|
2742
|
+
} else {
|
|
2743
|
+
this.zoomTo(1, true, null, _originalEvent);
|
|
2744
|
+
}
|
|
2745
|
+
return this;
|
|
2746
|
+
},
|
|
2747
|
+
// Reset the image to its initial state
|
|
2748
|
+
reset: function reset() {
|
|
2749
|
+
if (this.viewed && !this.played) {
|
|
2750
|
+
this.imageData = assign({}, this.initialImageData);
|
|
2751
|
+
this.renderImage();
|
|
2752
|
+
}
|
|
2753
|
+
return this;
|
|
2754
|
+
},
|
|
2755
|
+
// Update viewer when images changed
|
|
2756
|
+
update: function update() {
|
|
2757
|
+
var _this12 = this;
|
|
2758
|
+
var element = this.element,
|
|
2759
|
+
options = this.options,
|
|
2760
|
+
isImg = this.isImg;
|
|
2761
|
+
|
|
2762
|
+
// Destroy viewer if the target image was deleted
|
|
2763
|
+
if (isImg && !element.parentNode) {
|
|
2764
|
+
return this.destroy();
|
|
2765
|
+
}
|
|
2766
|
+
var images = [];
|
|
2767
|
+
forEach(isImg ? [element] : element.querySelectorAll('img'), function (image) {
|
|
2768
|
+
if (isFunction(options.filter)) {
|
|
2769
|
+
if (options.filter.call(_this12, image)) {
|
|
2770
|
+
images.push(image);
|
|
2771
|
+
}
|
|
2772
|
+
} else if (_this12.getImageURL(image)) {
|
|
2773
|
+
images.push(image);
|
|
2774
|
+
}
|
|
2775
|
+
});
|
|
2776
|
+
if (!images.length) {
|
|
2777
|
+
return this;
|
|
2778
|
+
}
|
|
2779
|
+
this.images = images;
|
|
2780
|
+
this.length = images.length;
|
|
2781
|
+
if (this.ready) {
|
|
2782
|
+
var changedIndexes = [];
|
|
2783
|
+
forEach(this.items, function (item, i) {
|
|
2784
|
+
var img = item.querySelector('img');
|
|
2785
|
+
var image = images[i];
|
|
2786
|
+
if (image && img) {
|
|
2787
|
+
if (image.src !== img.src
|
|
2788
|
+
|
|
2789
|
+
// Title changed (#408)
|
|
2790
|
+
|| image.alt !== img.alt) {
|
|
2791
|
+
changedIndexes.push(i);
|
|
2792
|
+
}
|
|
2793
|
+
} else {
|
|
2794
|
+
changedIndexes.push(i);
|
|
2795
|
+
}
|
|
2796
|
+
});
|
|
2797
|
+
setStyle(this.list, {
|
|
2798
|
+
width: 'auto'
|
|
2799
|
+
});
|
|
2800
|
+
this.initList();
|
|
2801
|
+
if (this.isShown) {
|
|
2802
|
+
if (this.length) {
|
|
2803
|
+
if (this.viewed) {
|
|
2804
|
+
var changedIndex = changedIndexes.indexOf(this.index);
|
|
2805
|
+
if (changedIndex >= 0) {
|
|
2806
|
+
this.viewed = false;
|
|
2807
|
+
this.view(Math.max(Math.min(this.index - changedIndex, this.length - 1), 0));
|
|
2808
|
+
} else {
|
|
2809
|
+
var activeItem = this.items[this.index];
|
|
2810
|
+
|
|
2811
|
+
// Reactivate the current viewing item after reset the list.
|
|
2812
|
+
addClass(activeItem, CLASS_ACTIVE);
|
|
2813
|
+
activeItem.setAttribute('aria-selected', true);
|
|
2814
|
+
}
|
|
2815
|
+
}
|
|
2816
|
+
} else {
|
|
2817
|
+
this.image = null;
|
|
2818
|
+
this.viewed = false;
|
|
2819
|
+
this.index = 0;
|
|
2820
|
+
this.imageData = {};
|
|
2821
|
+
this.canvas.innerHTML = '';
|
|
2822
|
+
this.title.innerHTML = '';
|
|
2823
|
+
}
|
|
2824
|
+
}
|
|
2825
|
+
} else {
|
|
2826
|
+
this.build();
|
|
2827
|
+
}
|
|
2828
|
+
return this;
|
|
2829
|
+
},
|
|
2830
|
+
// Destroy the viewer
|
|
2831
|
+
destroy: function destroy() {
|
|
2832
|
+
var element = this.element,
|
|
2833
|
+
options = this.options;
|
|
2834
|
+
if (!element[NAMESPACE]) {
|
|
2835
|
+
return this;
|
|
2836
|
+
}
|
|
2837
|
+
this.destroyed = true;
|
|
2838
|
+
if (this.ready) {
|
|
2839
|
+
if (this.played) {
|
|
2840
|
+
this.stop();
|
|
2841
|
+
}
|
|
2842
|
+
if (options.inline) {
|
|
2843
|
+
if (this.fulled) {
|
|
2844
|
+
this.exit();
|
|
2845
|
+
}
|
|
2846
|
+
this.unbind();
|
|
2847
|
+
} else if (this.isShown) {
|
|
2848
|
+
if (this.viewing) {
|
|
2849
|
+
if (this.imageRendering) {
|
|
2850
|
+
this.imageRendering.abort();
|
|
2851
|
+
} else if (this.imageInitializing) {
|
|
2852
|
+
this.imageInitializing.abort();
|
|
2853
|
+
}
|
|
2854
|
+
}
|
|
2855
|
+
if (this.hiding) {
|
|
2856
|
+
this.transitioning.abort();
|
|
2857
|
+
}
|
|
2858
|
+
this.hidden();
|
|
2859
|
+
} else if (this.showing) {
|
|
2860
|
+
this.transitioning.abort();
|
|
2861
|
+
this.hidden();
|
|
2862
|
+
}
|
|
2863
|
+
this.ready = false;
|
|
2864
|
+
this.viewer.parentNode.removeChild(this.viewer);
|
|
2865
|
+
} else if (options.inline) {
|
|
2866
|
+
if (this.delaying) {
|
|
2867
|
+
this.delaying.abort();
|
|
2868
|
+
} else if (this.initializing) {
|
|
2869
|
+
this.initializing.abort();
|
|
2870
|
+
}
|
|
2871
|
+
}
|
|
2872
|
+
if (!options.inline) {
|
|
2873
|
+
removeListener(element, EVENT_CLICK, this.onStart);
|
|
2874
|
+
}
|
|
2875
|
+
element[NAMESPACE] = undefined;
|
|
2876
|
+
return this;
|
|
2877
|
+
}
|
|
2878
|
+
};
|
|
2879
|
+
|
|
2880
|
+
var others = {
|
|
2881
|
+
getImageURL: function getImageURL(image) {
|
|
2882
|
+
var url = this.options.url;
|
|
2883
|
+
if (isString(url)) {
|
|
2884
|
+
url = image.getAttribute(url);
|
|
2885
|
+
} else if (isFunction(url)) {
|
|
2886
|
+
url = url.call(this, image);
|
|
2887
|
+
} else {
|
|
2888
|
+
url = '';
|
|
2889
|
+
}
|
|
2890
|
+
return url;
|
|
2891
|
+
},
|
|
2892
|
+
enforceFocus: function enforceFocus() {
|
|
2893
|
+
var _this = this;
|
|
2894
|
+
this.clearEnforceFocus();
|
|
2895
|
+
addListener(document, EVENT_FOCUSIN, this.onFocusin = function (event) {
|
|
2896
|
+
var viewer = _this.viewer;
|
|
2897
|
+
var target = event.target;
|
|
2898
|
+
if (target === document || target === viewer || viewer.contains(target)) {
|
|
2899
|
+
return;
|
|
2900
|
+
}
|
|
2901
|
+
while (target) {
|
|
2902
|
+
// Avoid conflicts with other modals (#474, #540)
|
|
2903
|
+
if (target.getAttribute('tabindex') !== null || target.getAttribute('aria-modal') === 'true') {
|
|
2904
|
+
return;
|
|
2905
|
+
}
|
|
2906
|
+
target = target.parentElement;
|
|
2907
|
+
}
|
|
2908
|
+
viewer.focus();
|
|
2909
|
+
});
|
|
2910
|
+
},
|
|
2911
|
+
clearEnforceFocus: function clearEnforceFocus() {
|
|
2912
|
+
if (this.onFocusin) {
|
|
2913
|
+
removeListener(document, EVENT_FOCUSIN, this.onFocusin);
|
|
2914
|
+
this.onFocusin = null;
|
|
2915
|
+
}
|
|
2916
|
+
},
|
|
2917
|
+
open: function open() {
|
|
2918
|
+
var body = this.body;
|
|
2919
|
+
addClass(body, CLASS_OPEN);
|
|
2920
|
+
if (this.scrollbarWidth > 0) {
|
|
2921
|
+
body.style.paddingRight = "".concat(this.scrollbarWidth + (parseFloat(this.initialBodyComputedPaddingRight) || 0), "px");
|
|
2922
|
+
}
|
|
2923
|
+
},
|
|
2924
|
+
close: function close() {
|
|
2925
|
+
var body = this.body;
|
|
2926
|
+
removeClass(body, CLASS_OPEN);
|
|
2927
|
+
if (this.scrollbarWidth > 0) {
|
|
2928
|
+
body.style.paddingRight = this.initialBodyPaddingRight;
|
|
2929
|
+
}
|
|
2930
|
+
},
|
|
2931
|
+
shown: function shown() {
|
|
2932
|
+
var element = this.element,
|
|
2933
|
+
options = this.options,
|
|
2934
|
+
viewer = this.viewer;
|
|
2935
|
+
this.fulled = true;
|
|
2936
|
+
this.isShown = true;
|
|
2937
|
+
this.render();
|
|
2938
|
+
this.bind();
|
|
2939
|
+
this.showing = false;
|
|
2940
|
+
if (options.focus) {
|
|
2941
|
+
viewer.focus();
|
|
2942
|
+
this.enforceFocus();
|
|
2943
|
+
}
|
|
2944
|
+
if (isFunction(options.shown)) {
|
|
2945
|
+
addListener(element, EVENT_SHOWN, options.shown, {
|
|
2946
|
+
once: true
|
|
2947
|
+
});
|
|
2948
|
+
}
|
|
2949
|
+
if (dispatchEvent(element, EVENT_SHOWN) === false) {
|
|
2950
|
+
return;
|
|
2951
|
+
}
|
|
2952
|
+
if (this.ready && this.isShown && !this.hiding) {
|
|
2953
|
+
this.view(this.index);
|
|
2954
|
+
}
|
|
2955
|
+
},
|
|
2956
|
+
hidden: function hidden() {
|
|
2957
|
+
var element = this.element,
|
|
2958
|
+
options = this.options,
|
|
2959
|
+
viewer = this.viewer;
|
|
2960
|
+
if (options.fucus) {
|
|
2961
|
+
this.clearEnforceFocus();
|
|
2962
|
+
}
|
|
2963
|
+
this.close();
|
|
2964
|
+
this.unbind();
|
|
2965
|
+
addClass(viewer, CLASS_HIDE);
|
|
2966
|
+
viewer.removeAttribute('role');
|
|
2967
|
+
viewer.removeAttribute('aria-labelledby');
|
|
2968
|
+
viewer.removeAttribute('aria-modal');
|
|
2969
|
+
viewer.setAttribute('aria-hidden', true);
|
|
2970
|
+
this.resetList();
|
|
2971
|
+
this.resetImage();
|
|
2972
|
+
this.fulled = false;
|
|
2973
|
+
this.viewed = false;
|
|
2974
|
+
this.isShown = false;
|
|
2975
|
+
this.hiding = false;
|
|
2976
|
+
if (!this.destroyed) {
|
|
2977
|
+
if (isFunction(options.hidden)) {
|
|
2978
|
+
addListener(element, EVENT_HIDDEN, options.hidden, {
|
|
2979
|
+
once: true
|
|
2980
|
+
});
|
|
2981
|
+
}
|
|
2982
|
+
dispatchEvent(element, EVENT_HIDDEN, null, {
|
|
2983
|
+
cancelable: false
|
|
2984
|
+
});
|
|
2985
|
+
}
|
|
2986
|
+
},
|
|
2987
|
+
requestFullscreen: function requestFullscreen(options) {
|
|
2988
|
+
var document = this.element.ownerDocument;
|
|
2989
|
+
if (this.fulled && !(document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement)) {
|
|
2990
|
+
var documentElement = document.documentElement;
|
|
2991
|
+
|
|
2992
|
+
// Element.requestFullscreen()
|
|
2993
|
+
if (documentElement.requestFullscreen) {
|
|
2994
|
+
// Avoid TypeError when convert `options` to dictionary
|
|
2995
|
+
if (isPlainObject(options)) {
|
|
2996
|
+
documentElement.requestFullscreen(options);
|
|
2997
|
+
} else {
|
|
2998
|
+
documentElement.requestFullscreen();
|
|
2999
|
+
}
|
|
3000
|
+
} else if (documentElement.webkitRequestFullscreen) {
|
|
3001
|
+
documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
|
|
3002
|
+
} else if (documentElement.mozRequestFullScreen) {
|
|
3003
|
+
documentElement.mozRequestFullScreen();
|
|
3004
|
+
} else if (documentElement.msRequestFullscreen) {
|
|
3005
|
+
documentElement.msRequestFullscreen();
|
|
3006
|
+
}
|
|
3007
|
+
}
|
|
3008
|
+
},
|
|
3009
|
+
exitFullscreen: function exitFullscreen() {
|
|
3010
|
+
var document = this.element.ownerDocument;
|
|
3011
|
+
if (this.fulled && (document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement)) {
|
|
3012
|
+
// Document.exitFullscreen()
|
|
3013
|
+
if (document.exitFullscreen) {
|
|
3014
|
+
document.exitFullscreen();
|
|
3015
|
+
} else if (document.webkitExitFullscreen) {
|
|
3016
|
+
document.webkitExitFullscreen();
|
|
3017
|
+
} else if (document.mozCancelFullScreen) {
|
|
3018
|
+
document.mozCancelFullScreen();
|
|
3019
|
+
} else if (document.msExitFullscreen) {
|
|
3020
|
+
document.msExitFullscreen();
|
|
3021
|
+
}
|
|
3022
|
+
}
|
|
3023
|
+
},
|
|
3024
|
+
change: function change(event) {
|
|
3025
|
+
var options = this.options,
|
|
3026
|
+
pointers = this.pointers;
|
|
3027
|
+
var pointer = pointers[Object.keys(pointers)[0]];
|
|
3028
|
+
|
|
3029
|
+
// In the case of the `pointers` object is empty (#421)
|
|
3030
|
+
if (!pointer) {
|
|
3031
|
+
return;
|
|
3032
|
+
}
|
|
3033
|
+
var offsetX = pointer.endX - pointer.startX;
|
|
3034
|
+
var offsetY = pointer.endY - pointer.startY;
|
|
3035
|
+
switch (this.action) {
|
|
3036
|
+
// Move the current image
|
|
3037
|
+
case ACTION_MOVE:
|
|
3038
|
+
if (offsetX !== 0 || offsetY !== 0) {
|
|
3039
|
+
this.pointerMoved = true;
|
|
3040
|
+
this.move(offsetX, offsetY, event);
|
|
3041
|
+
}
|
|
3042
|
+
break;
|
|
3043
|
+
|
|
3044
|
+
// Zoom the current image
|
|
3045
|
+
case ACTION_ZOOM:
|
|
3046
|
+
this.zoom(getMaxZoomRatio(pointers), false, null, event);
|
|
3047
|
+
break;
|
|
3048
|
+
case ACTION_SWITCH:
|
|
3049
|
+
{
|
|
3050
|
+
this.action = 'switched';
|
|
3051
|
+
var absoluteOffsetX = Math.abs(offsetX);
|
|
3052
|
+
if (absoluteOffsetX > 1 && absoluteOffsetX > Math.abs(offsetY)) {
|
|
3053
|
+
// Empty `pointers` as `touchend` event will not be fired after swiped in iOS browsers.
|
|
3054
|
+
this.pointers = {};
|
|
3055
|
+
if (offsetX > 1) {
|
|
3056
|
+
this.prev(options.loop);
|
|
3057
|
+
} else if (offsetX < -1) {
|
|
3058
|
+
this.next(options.loop);
|
|
3059
|
+
}
|
|
3060
|
+
}
|
|
3061
|
+
break;
|
|
3062
|
+
}
|
|
3063
|
+
}
|
|
3064
|
+
|
|
3065
|
+
// Override
|
|
3066
|
+
forEach(pointers, function (p) {
|
|
3067
|
+
p.startX = p.endX;
|
|
3068
|
+
p.startY = p.endY;
|
|
3069
|
+
});
|
|
3070
|
+
},
|
|
3071
|
+
isSwitchable: function isSwitchable() {
|
|
3072
|
+
var imageData = this.imageData,
|
|
3073
|
+
viewerData = this.viewerData;
|
|
3074
|
+
return this.length > 1 && imageData.x >= 0 && imageData.y >= 0 && imageData.width <= viewerData.width && imageData.height <= viewerData.height;
|
|
3075
|
+
}
|
|
3076
|
+
};
|
|
3077
|
+
|
|
3078
|
+
var AnotherViewer = WINDOW.Viewer;
|
|
3079
|
+
var getUniqueID = function (id) {
|
|
3080
|
+
return function () {
|
|
3081
|
+
id += 1;
|
|
3082
|
+
return id;
|
|
3083
|
+
};
|
|
3084
|
+
}(-1);
|
|
3085
|
+
var Viewer = /*#__PURE__*/function () {
|
|
3086
|
+
/**
|
|
3087
|
+
* Create a new Viewer.
|
|
3088
|
+
* @param {Element} element - The target element for viewing.
|
|
3089
|
+
* @param {Object} [options={}] - The configuration options.
|
|
3090
|
+
*/
|
|
3091
|
+
function Viewer(element) {
|
|
3092
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
3093
|
+
_classCallCheck(this, Viewer);
|
|
3094
|
+
if (!element || element.nodeType !== 1) {
|
|
3095
|
+
throw new Error('The first argument is required and must be an element.');
|
|
3096
|
+
}
|
|
3097
|
+
this.element = element;
|
|
3098
|
+
this.options = assign({}, DEFAULTS, isPlainObject(options) && options);
|
|
3099
|
+
this.action = false;
|
|
3100
|
+
this.fading = false;
|
|
3101
|
+
this.fulled = false;
|
|
3102
|
+
this.hiding = false;
|
|
3103
|
+
this.imageClicked = false;
|
|
3104
|
+
this.imageData = {};
|
|
3105
|
+
this.index = this.options.initialViewIndex;
|
|
3106
|
+
this.isImg = false;
|
|
3107
|
+
this.isShown = false;
|
|
3108
|
+
this.length = 0;
|
|
3109
|
+
this.moving = false;
|
|
3110
|
+
this.played = false;
|
|
3111
|
+
this.playing = false;
|
|
3112
|
+
this.pointers = {};
|
|
3113
|
+
this.ready = false;
|
|
3114
|
+
this.rotating = false;
|
|
3115
|
+
this.scaling = false;
|
|
3116
|
+
this.showing = false;
|
|
3117
|
+
this.timeout = false;
|
|
3118
|
+
this.tooltipping = false;
|
|
3119
|
+
this.viewed = false;
|
|
3120
|
+
this.viewing = false;
|
|
3121
|
+
this.wheeling = false;
|
|
3122
|
+
this.zooming = false;
|
|
3123
|
+
this.pointerMoved = false;
|
|
3124
|
+
this.id = getUniqueID();
|
|
3125
|
+
this.init();
|
|
3126
|
+
}
|
|
3127
|
+
return _createClass(Viewer, [{
|
|
3128
|
+
key: "init",
|
|
3129
|
+
value: function init() {
|
|
3130
|
+
var _this = this;
|
|
3131
|
+
var element = this.element,
|
|
3132
|
+
options = this.options;
|
|
3133
|
+
if (element[NAMESPACE]) {
|
|
3134
|
+
return;
|
|
3135
|
+
}
|
|
3136
|
+
element[NAMESPACE] = this;
|
|
3137
|
+
|
|
3138
|
+
// The `focus` option requires the `keyboard` option set to `true`.
|
|
3139
|
+
if (options.focus && !options.keyboard) {
|
|
3140
|
+
options.focus = false;
|
|
3141
|
+
}
|
|
3142
|
+
var isImg = element.localName === 'img';
|
|
3143
|
+
var images = [];
|
|
3144
|
+
forEach(isImg ? [element] : element.querySelectorAll('img'), function (image) {
|
|
3145
|
+
if (isFunction(options.filter)) {
|
|
3146
|
+
if (options.filter.call(_this, image)) {
|
|
3147
|
+
images.push(image);
|
|
3148
|
+
}
|
|
3149
|
+
} else if (_this.getImageURL(image)) {
|
|
3150
|
+
images.push(image);
|
|
3151
|
+
}
|
|
3152
|
+
});
|
|
3153
|
+
this.isImg = isImg;
|
|
3154
|
+
this.length = images.length;
|
|
3155
|
+
this.images = images;
|
|
3156
|
+
this.initBody();
|
|
3157
|
+
|
|
3158
|
+
// Override `transition` option if it is not supported
|
|
3159
|
+
if (isUndefined(document.createElement(NAMESPACE).style.transition)) {
|
|
3160
|
+
options.transition = false;
|
|
3161
|
+
}
|
|
3162
|
+
if (options.inline) {
|
|
3163
|
+
var count = 0;
|
|
3164
|
+
var progress = function progress() {
|
|
3165
|
+
count += 1;
|
|
3166
|
+
if (count === _this.length) {
|
|
3167
|
+
var timeout;
|
|
3168
|
+
_this.initializing = false;
|
|
3169
|
+
_this.delaying = {
|
|
3170
|
+
abort: function abort() {
|
|
3171
|
+
clearTimeout(timeout);
|
|
3172
|
+
}
|
|
3173
|
+
};
|
|
3174
|
+
|
|
3175
|
+
// build asynchronously to keep `this.viewer` is accessible in `ready` event handler.
|
|
3176
|
+
timeout = setTimeout(function () {
|
|
3177
|
+
_this.delaying = false;
|
|
3178
|
+
_this.build();
|
|
3179
|
+
}, 0);
|
|
3180
|
+
}
|
|
3181
|
+
};
|
|
3182
|
+
this.initializing = {
|
|
3183
|
+
abort: function abort() {
|
|
3184
|
+
forEach(images, function (image) {
|
|
3185
|
+
if (!image.complete) {
|
|
3186
|
+
removeListener(image, EVENT_LOAD, progress);
|
|
3187
|
+
removeListener(image, EVENT_ERROR, progress);
|
|
3188
|
+
}
|
|
3189
|
+
});
|
|
3190
|
+
}
|
|
3191
|
+
};
|
|
3192
|
+
forEach(images, function (image) {
|
|
3193
|
+
if (image.complete) {
|
|
3194
|
+
progress();
|
|
3195
|
+
} else {
|
|
3196
|
+
var onLoad;
|
|
3197
|
+
var onError;
|
|
3198
|
+
addListener(image, EVENT_LOAD, onLoad = function onLoad() {
|
|
3199
|
+
removeListener(image, EVENT_ERROR, onError);
|
|
3200
|
+
progress();
|
|
3201
|
+
}, {
|
|
3202
|
+
once: true
|
|
3203
|
+
});
|
|
3204
|
+
addListener(image, EVENT_ERROR, onError = function onError() {
|
|
3205
|
+
removeListener(image, EVENT_LOAD, onLoad);
|
|
3206
|
+
progress();
|
|
3207
|
+
}, {
|
|
3208
|
+
once: true
|
|
3209
|
+
});
|
|
3210
|
+
}
|
|
3211
|
+
});
|
|
3212
|
+
} else {
|
|
3213
|
+
addListener(element, EVENT_CLICK, this.onStart = function (_ref) {
|
|
3214
|
+
var target = _ref.target;
|
|
3215
|
+
if (target.localName === 'img' && (!isFunction(options.filter) || options.filter.call(_this, target))) {
|
|
3216
|
+
_this.view(_this.images.indexOf(target));
|
|
3217
|
+
}
|
|
3218
|
+
});
|
|
3219
|
+
}
|
|
3220
|
+
}
|
|
3221
|
+
}, {
|
|
3222
|
+
key: "build",
|
|
3223
|
+
value: function build() {
|
|
3224
|
+
if (this.ready) {
|
|
3225
|
+
return;
|
|
3226
|
+
}
|
|
3227
|
+
var element = this.element,
|
|
3228
|
+
options = this.options;
|
|
3229
|
+
var parent = element.parentNode;
|
|
3230
|
+
var template = document.createElement('div');
|
|
3231
|
+
template.innerHTML = TEMPLATE;
|
|
3232
|
+
var viewer = template.querySelector(".".concat(NAMESPACE, "-container"));
|
|
3233
|
+
var title = viewer.querySelector(".".concat(NAMESPACE, "-title"));
|
|
3234
|
+
var toolbar = viewer.querySelector(".".concat(NAMESPACE, "-toolbar"));
|
|
3235
|
+
var navbar = viewer.querySelector(".".concat(NAMESPACE, "-navbar"));
|
|
3236
|
+
var button = viewer.querySelector(".".concat(NAMESPACE, "-button"));
|
|
3237
|
+
var canvas = viewer.querySelector(".".concat(NAMESPACE, "-canvas"));
|
|
3238
|
+
this.parent = parent;
|
|
3239
|
+
this.viewer = viewer;
|
|
3240
|
+
this.title = title;
|
|
3241
|
+
this.toolbar = toolbar;
|
|
3242
|
+
this.navbar = navbar;
|
|
3243
|
+
this.button = button;
|
|
3244
|
+
this.canvas = canvas;
|
|
3245
|
+
this.footer = viewer.querySelector(".".concat(NAMESPACE, "-footer"));
|
|
3246
|
+
this.tooltipBox = viewer.querySelector(".".concat(NAMESPACE, "-tooltip"));
|
|
3247
|
+
this.player = viewer.querySelector(".".concat(NAMESPACE, "-player"));
|
|
3248
|
+
this.list = viewer.querySelector(".".concat(NAMESPACE, "-list"));
|
|
3249
|
+
viewer.id = "".concat(NAMESPACE).concat(this.id);
|
|
3250
|
+
title.id = "".concat(NAMESPACE, "Title").concat(this.id);
|
|
3251
|
+
addClass(title, !options.title ? CLASS_HIDE : getResponsiveClass(Array.isArray(options.title) ? options.title[0] : options.title));
|
|
3252
|
+
addClass(navbar, !options.navbar ? CLASS_HIDE : getResponsiveClass(options.navbar));
|
|
3253
|
+
toggleClass(button, CLASS_HIDE, !options.button);
|
|
3254
|
+
if (options.keyboard) {
|
|
3255
|
+
button.setAttribute('tabindex', 0);
|
|
3256
|
+
}
|
|
3257
|
+
if (options.backdrop) {
|
|
3258
|
+
addClass(viewer, "".concat(NAMESPACE, "-backdrop"));
|
|
3259
|
+
if (!options.inline && options.backdrop !== 'static') {
|
|
3260
|
+
setData(canvas, DATA_ACTION, 'hide');
|
|
3261
|
+
}
|
|
3262
|
+
}
|
|
3263
|
+
if (isString(options.className) && options.className) {
|
|
3264
|
+
// In case there are multiple class names
|
|
3265
|
+
options.className.split(REGEXP_SPACES).forEach(function (className) {
|
|
3266
|
+
addClass(viewer, className);
|
|
3267
|
+
});
|
|
3268
|
+
}
|
|
3269
|
+
if (options.toolbar) {
|
|
3270
|
+
var list = document.createElement('ul');
|
|
3271
|
+
var custom = isPlainObject(options.toolbar);
|
|
3272
|
+
var zoomButtons = BUTTONS.slice(0, 3);
|
|
3273
|
+
var rotateButtons = BUTTONS.slice(7, 9);
|
|
3274
|
+
var scaleButtons = BUTTONS.slice(9);
|
|
3275
|
+
if (!custom) {
|
|
3276
|
+
addClass(toolbar, getResponsiveClass(options.toolbar));
|
|
3277
|
+
}
|
|
3278
|
+
forEach(custom ? options.toolbar : BUTTONS, function (value, index) {
|
|
3279
|
+
var deep = custom && isPlainObject(value);
|
|
3280
|
+
var name = custom ? hyphenate(index) : value;
|
|
3281
|
+
var show = deep && !isUndefined(value.show) ? value.show : value;
|
|
3282
|
+
if (!show || !options.zoomable && zoomButtons.indexOf(name) !== -1 || !options.rotatable && rotateButtons.indexOf(name) !== -1 || !options.scalable && scaleButtons.indexOf(name) !== -1) {
|
|
3283
|
+
return;
|
|
3284
|
+
}
|
|
3285
|
+
var size = deep && !isUndefined(value.size) ? value.size : value;
|
|
3286
|
+
var click = deep && !isUndefined(value.click) ? value.click : value;
|
|
3287
|
+
var item = document.createElement('li');
|
|
3288
|
+
if (options.keyboard) {
|
|
3289
|
+
item.setAttribute('tabindex', 0);
|
|
3290
|
+
}
|
|
3291
|
+
item.setAttribute('role', 'button');
|
|
3292
|
+
addClass(item, "".concat(NAMESPACE, "-").concat(name));
|
|
3293
|
+
if (!isFunction(click)) {
|
|
3294
|
+
setData(item, DATA_ACTION, name);
|
|
3295
|
+
}
|
|
3296
|
+
if (isNumber(show)) {
|
|
3297
|
+
addClass(item, getResponsiveClass(show));
|
|
3298
|
+
}
|
|
3299
|
+
if (['small', 'large'].indexOf(size) !== -1) {
|
|
3300
|
+
addClass(item, "".concat(NAMESPACE, "-").concat(size));
|
|
3301
|
+
} else if (name === 'play') {
|
|
3302
|
+
addClass(item, "".concat(NAMESPACE, "-large"));
|
|
3303
|
+
}
|
|
3304
|
+
if (isFunction(click)) {
|
|
3305
|
+
addListener(item, EVENT_CLICK, click);
|
|
3306
|
+
}
|
|
3307
|
+
list.appendChild(item);
|
|
3308
|
+
});
|
|
3309
|
+
toolbar.appendChild(list);
|
|
3310
|
+
} else {
|
|
3311
|
+
addClass(toolbar, CLASS_HIDE);
|
|
3312
|
+
}
|
|
3313
|
+
if (!options.rotatable) {
|
|
3314
|
+
var rotates = toolbar.querySelectorAll('li[class*="rotate"]');
|
|
3315
|
+
addClass(rotates, CLASS_INVISIBLE);
|
|
3316
|
+
forEach(rotates, function (rotate) {
|
|
3317
|
+
toolbar.appendChild(rotate);
|
|
3318
|
+
});
|
|
3319
|
+
}
|
|
3320
|
+
if (options.inline) {
|
|
3321
|
+
addClass(button, CLASS_FULLSCREEN);
|
|
3322
|
+
setStyle(viewer, {
|
|
3323
|
+
zIndex: options.zIndexInline
|
|
3324
|
+
});
|
|
3325
|
+
if (window.getComputedStyle(parent).position === 'static') {
|
|
3326
|
+
setStyle(parent, {
|
|
3327
|
+
position: 'relative'
|
|
3328
|
+
});
|
|
3329
|
+
}
|
|
3330
|
+
parent.insertBefore(viewer, element.nextSibling);
|
|
3331
|
+
} else {
|
|
3332
|
+
addClass(button, CLASS_CLOSE);
|
|
3333
|
+
addClass(viewer, CLASS_FIXED);
|
|
3334
|
+
addClass(viewer, CLASS_FADE);
|
|
3335
|
+
addClass(viewer, CLASS_HIDE);
|
|
3336
|
+
setStyle(viewer, {
|
|
3337
|
+
zIndex: options.zIndex
|
|
3338
|
+
});
|
|
3339
|
+
var container = options.container;
|
|
3340
|
+
if (isString(container)) {
|
|
3341
|
+
container = element.ownerDocument.querySelector(container);
|
|
3342
|
+
}
|
|
3343
|
+
if (!container) {
|
|
3344
|
+
container = this.body;
|
|
3345
|
+
}
|
|
3346
|
+
container.appendChild(viewer);
|
|
3347
|
+
}
|
|
3348
|
+
if (options.inline) {
|
|
3349
|
+
this.render();
|
|
3350
|
+
this.bind();
|
|
3351
|
+
this.isShown = true;
|
|
3352
|
+
}
|
|
3353
|
+
this.ready = true;
|
|
3354
|
+
if (isFunction(options.ready)) {
|
|
3355
|
+
addListener(element, EVENT_READY, options.ready, {
|
|
3356
|
+
once: true
|
|
3357
|
+
});
|
|
3358
|
+
}
|
|
3359
|
+
if (dispatchEvent(element, EVENT_READY) === false) {
|
|
3360
|
+
this.ready = false;
|
|
3361
|
+
return;
|
|
3362
|
+
}
|
|
3363
|
+
if (this.ready && options.inline) {
|
|
3364
|
+
this.view(this.index);
|
|
3365
|
+
}
|
|
3366
|
+
}
|
|
3367
|
+
|
|
3368
|
+
/**
|
|
3369
|
+
* Get the no conflict viewer class.
|
|
3370
|
+
* @returns {Viewer} The viewer class.
|
|
3371
|
+
*/
|
|
3372
|
+
}], [{
|
|
3373
|
+
key: "noConflict",
|
|
3374
|
+
value: function noConflict() {
|
|
3375
|
+
window.Viewer = AnotherViewer;
|
|
3376
|
+
return Viewer;
|
|
3377
|
+
}
|
|
3378
|
+
|
|
3379
|
+
/**
|
|
3380
|
+
* Change the default options.
|
|
3381
|
+
* @param {Object} options - The new default options.
|
|
3382
|
+
*/
|
|
3383
|
+
}, {
|
|
3384
|
+
key: "setDefaults",
|
|
3385
|
+
value: function setDefaults(options) {
|
|
3386
|
+
assign(DEFAULTS, isPlainObject(options) && options);
|
|
3387
|
+
}
|
|
3388
|
+
}]);
|
|
3389
|
+
}();
|
|
3390
|
+
assign(Viewer.prototype, render, events, handlers, methods, others);
|
|
3391
|
+
|
|
3392
|
+
return Viewer;
|
|
3393
|
+
|
|
3394
|
+
}));
|
|
3395
|
+
|
|
3396
|
+
|
|
108
3397
|
/***/ }),
|
|
109
3398
|
|
|
110
3399
|
/***/ "fb15":
|
|
@@ -130,30 +3419,189 @@ if (typeof window !== 'undefined') {
|
|
|
130
3419
|
// Indicate to webpack that this file can be concatenated
|
|
131
3420
|
/* harmony default export */ var setPublicPath = (null);
|
|
132
3421
|
|
|
133
|
-
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"
|
|
134
|
-
var render = function render(){var _vm=this,_c=_vm._self._c;return _c('div',{staticClass:"boka-human-v2"},[_c('
|
|
3422
|
+
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"9b08f294-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??ref--5!./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader/lib??vue-loader-options!./src/BokaHumanV2.vue?vue&type=template&id=334faf30&scoped=true
|
|
3423
|
+
var render = function render(){var _vm=this,_c=_vm._self._c;return _c('div',{staticClass:"boka-human-v2"},[_c('div',{staticClass:"icon",attrs:{"id":"icon"},on:{"click":function($event){_vm.visible=!_vm.visible}}},[_vm._v(_vm._s(_vm.visible ? '隐藏' : '显示'))]),_c('div',{directives:[{name:"show",rawName:"v-show",value:(_vm.visible),expression:"visible"}],staticClass:"humanMainView"},[_c('div',{staticClass:"humanMainHeader my-dialog__header"},[_c('div',{staticClass:"humanMainHeaderLeft"}),_c('div',{staticClass:"humanMainHeaderCenter"},[_vm._v("客服")]),_c('div',{staticClass:"humanMainHeaderRight"},[_c('span',{on:{"click":function($event){_vm.visible=!_vm.visible}}},[_vm._v("隐藏")])])]),_c('iframe',{attrs:{"src":_vm.src,"frameborder":"0","allowfullscreen":""}})])])
|
|
135
3424
|
}
|
|
136
3425
|
var staticRenderFns = []
|
|
137
3426
|
|
|
138
3427
|
|
|
139
|
-
// CONCATENATED MODULE: ./src/BokaHumanV2.vue?vue&type=template&id=
|
|
3428
|
+
// CONCATENATED MODULE: ./src/BokaHumanV2.vue?vue&type=template&id=334faf30&scoped=true
|
|
3429
|
+
|
|
3430
|
+
// EXTERNAL MODULE: ./node_modules/interactjs/dist/interact.min.js
|
|
3431
|
+
var interact_min = __webpack_require__("5014");
|
|
3432
|
+
var interact_min_default = /*#__PURE__*/__webpack_require__.n(interact_min);
|
|
3433
|
+
|
|
3434
|
+
// EXTERNAL MODULE: ./node_modules/viewerjs/dist/viewer.js
|
|
3435
|
+
var viewer = __webpack_require__("c82c");
|
|
3436
|
+
var viewer_default = /*#__PURE__*/__webpack_require__.n(viewer);
|
|
3437
|
+
|
|
3438
|
+
// EXTERNAL MODULE: ./node_modules/viewerjs/dist/viewer.css
|
|
3439
|
+
var dist_viewer = __webpack_require__("0808");
|
|
140
3440
|
|
|
141
3441
|
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader/lib??vue-loader-options!./src/BokaHumanV2.vue?vue&type=script&lang=js
|
|
142
3442
|
|
|
3443
|
+
|
|
3444
|
+
|
|
3445
|
+
|
|
3446
|
+
|
|
143
3447
|
/* harmony default export */ var BokaHumanV2vue_type_script_lang_js = ({
|
|
144
3448
|
name: 'boka-human-v2',
|
|
145
3449
|
props: {
|
|
146
|
-
|
|
3450
|
+
token: {
|
|
147
3451
|
type: String,
|
|
148
|
-
default: '
|
|
3452
|
+
default: ''
|
|
3453
|
+
},
|
|
3454
|
+
product: {
|
|
3455
|
+
type: String,
|
|
3456
|
+
default: ''
|
|
3457
|
+
},
|
|
3458
|
+
subCustType: {
|
|
3459
|
+
type: String,
|
|
3460
|
+
default: ''
|
|
3461
|
+
},
|
|
3462
|
+
source: {
|
|
3463
|
+
type: String,
|
|
3464
|
+
default: ''
|
|
3465
|
+
}
|
|
3466
|
+
},
|
|
3467
|
+
computed: {
|
|
3468
|
+
src(){
|
|
3469
|
+
let {token,product,subCustType} = this;
|
|
3470
|
+
return `https://human.shboka.com/?token=${token}&product=${product}&subCustType=${subCustType}&human=1&isIFrame=true`;
|
|
3471
|
+
}
|
|
3472
|
+
},
|
|
3473
|
+
data() {
|
|
3474
|
+
return {
|
|
3475
|
+
visible: false
|
|
3476
|
+
}
|
|
3477
|
+
},
|
|
3478
|
+
mounted() {
|
|
3479
|
+
this.icon();
|
|
3480
|
+
this.chatMainInitDrag();
|
|
3481
|
+
/*//告诉内嵌页面是 frame 方式存在
|
|
3482
|
+
window.postMessage({human:1,isIFrame:true}, 'https://human.shboka.com');
|
|
3483
|
+
window.addEventListener('humanInnerMessage', (event) => {
|
|
3484
|
+
// 检查消息来源
|
|
3485
|
+
if (event.origin !== 'https://human.shboka.com') return;
|
|
3486
|
+
|
|
3487
|
+
console.log('收到来自 iframe 的消息:', event.data);
|
|
3488
|
+
});*/
|
|
3489
|
+
},
|
|
3490
|
+
methods:{
|
|
3491
|
+
showImg(url,messageItem){
|
|
3492
|
+
let a = new Image();
|
|
3493
|
+
a.src = url;
|
|
3494
|
+
new viewer_default.a(a, {
|
|
3495
|
+
// 可选配置,例如:
|
|
3496
|
+
inline: false,
|
|
3497
|
+
navbar:false,
|
|
3498
|
+
title:false
|
|
3499
|
+
}).show();
|
|
3500
|
+
},
|
|
3501
|
+
showVideo(url,messageItem){
|
|
3502
|
+
const video = document.createElement('video');
|
|
3503
|
+
video.src = url;
|
|
3504
|
+
video.controls = true;
|
|
3505
|
+
new viewer_default.a(video, {
|
|
3506
|
+
// 可选配置,例如:
|
|
3507
|
+
inline: false,
|
|
3508
|
+
navbar:false,
|
|
3509
|
+
title:false
|
|
3510
|
+
}).show();
|
|
3511
|
+
},
|
|
3512
|
+
icon(){
|
|
3513
|
+
const container = document.body;
|
|
3514
|
+
interact_min_default()('.icon')
|
|
3515
|
+
.on('tap', function (event) {
|
|
3516
|
+
event.preventDefault()
|
|
3517
|
+
}).draggable({
|
|
3518
|
+
inertia: true,
|
|
3519
|
+
modifiers: [
|
|
3520
|
+
interact_min_default.a.modifiers.restrictRect({
|
|
3521
|
+
restriction: 'body',
|
|
3522
|
+
endOnly: true
|
|
3523
|
+
})
|
|
3524
|
+
],
|
|
3525
|
+
autoScroll: true,
|
|
3526
|
+
listeners: {
|
|
3527
|
+
move: (event)=>{
|
|
3528
|
+
var target = event.target
|
|
3529
|
+
var x = (parseFloat(target.getAttribute('data-x')) || 0) + event.dx
|
|
3530
|
+
var y = (parseFloat(target.getAttribute('data-y')) || 0) + event.dy
|
|
3531
|
+
|
|
3532
|
+
// 限制纵向位置在容器内
|
|
3533
|
+
if (y < 0) {
|
|
3534
|
+
y = 0;
|
|
3535
|
+
}
|
|
3536
|
+
if (y > container.clientHeight - target.offsetHeight) {
|
|
3537
|
+
y = container.clientHeight - target.offsetHeight;
|
|
3538
|
+
}
|
|
3539
|
+
|
|
3540
|
+
// 横向限制:不允许停留在中间,拖动时允许在左侧区和右侧区之间滑动
|
|
3541
|
+
// 这里允许水平拖动到左右边界之间,但不允许停留中间,拖动结束时自动吸附
|
|
3542
|
+
// 但为了拖动顺畅,这里不限制x,吸附逻辑放在 dragend 事件
|
|
3543
|
+
|
|
3544
|
+
target.style.transform = `translate(${x}px, ${y}px)`;
|
|
3545
|
+
|
|
3546
|
+
// update the posiion attributes
|
|
3547
|
+
target.setAttribute('data-x', x)
|
|
3548
|
+
target.setAttribute('data-y', y)
|
|
3549
|
+
},
|
|
3550
|
+
end(event) {
|
|
3551
|
+
var target = event.target;
|
|
3552
|
+
var x = (parseFloat(target.getAttribute('data-x')) || 0)
|
|
3553
|
+
var y = (parseFloat(target.getAttribute('data-y')) || 0)
|
|
3554
|
+
const middleX = container.clientWidth / 2;
|
|
3555
|
+
const leftX = 0;
|
|
3556
|
+
const rightX = container.clientWidth - target.offsetWidth;
|
|
3557
|
+
if (x + target.offsetWidth / 2 < middleX) {
|
|
3558
|
+
// 靠左吸附
|
|
3559
|
+
x = leftX;
|
|
3560
|
+
} else {
|
|
3561
|
+
// 靠右吸附
|
|
3562
|
+
x = rightX;
|
|
3563
|
+
}
|
|
3564
|
+
target.setAttribute('data-x', x)
|
|
3565
|
+
target.setAttribute('data-y', y)
|
|
3566
|
+
target.style.transform = `translate(${x}px, ${y}px)`;
|
|
3567
|
+
}
|
|
3568
|
+
}
|
|
3569
|
+
})
|
|
3570
|
+
},
|
|
3571
|
+
chatMainInitDrag(){
|
|
3572
|
+
interact_min_default()('.humanMainView').draggable({
|
|
3573
|
+
inertia: true,
|
|
3574
|
+
modifiers: [
|
|
3575
|
+
interact_min_default.a.modifiers.restrictRect({
|
|
3576
|
+
restriction: 'body',
|
|
3577
|
+
endOnly: true
|
|
3578
|
+
})
|
|
3579
|
+
],
|
|
3580
|
+
autoScroll: true,
|
|
3581
|
+
listeners: {
|
|
3582
|
+
move: (event)=>{
|
|
3583
|
+
var target = event.target
|
|
3584
|
+
var x = (parseFloat(target.getAttribute('data-x')) || 0) + event.dx
|
|
3585
|
+
var y = (parseFloat(target.getAttribute('data-y')) || 0) + event.dy
|
|
3586
|
+
|
|
3587
|
+
target.style.transform = 'translate(' + x + 'px, ' + y + 'px)'
|
|
3588
|
+
|
|
3589
|
+
// update the posiion attributes
|
|
3590
|
+
target.setAttribute('data-x', x)
|
|
3591
|
+
target.setAttribute('data-y', y)
|
|
3592
|
+
},
|
|
3593
|
+
end(event) {
|
|
3594
|
+
}
|
|
3595
|
+
}
|
|
3596
|
+
})
|
|
149
3597
|
}
|
|
150
3598
|
}
|
|
151
3599
|
});
|
|
152
3600
|
|
|
153
3601
|
// CONCATENATED MODULE: ./src/BokaHumanV2.vue?vue&type=script&lang=js
|
|
154
3602
|
/* harmony default export */ var src_BokaHumanV2vue_type_script_lang_js = (BokaHumanV2vue_type_script_lang_js);
|
|
155
|
-
// EXTERNAL MODULE: ./src/BokaHumanV2.vue?vue&type=style&index=0&id=
|
|
156
|
-
var
|
|
3603
|
+
// EXTERNAL MODULE: ./src/BokaHumanV2.vue?vue&type=style&index=0&id=334faf30&prod&scoped=true&lang=css
|
|
3604
|
+
var BokaHumanV2vue_type_style_index_0_id_334faf30_prod_scoped_true_lang_css = __webpack_require__("577e");
|
|
157
3605
|
|
|
158
3606
|
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
|
|
159
3607
|
/* globals __VUE_SSR_CONTEXT__ */
|
|
@@ -268,7 +3716,7 @@ var component = normalizeComponent(
|
|
|
268
3716
|
staticRenderFns,
|
|
269
3717
|
false,
|
|
270
3718
|
null,
|
|
271
|
-
"
|
|
3719
|
+
"334faf30",
|
|
272
3720
|
null
|
|
273
3721
|
|
|
274
3722
|
)
|
|
@@ -286,13 +3734,6 @@ var component = normalizeComponent(
|
|
|
286
3734
|
|
|
287
3735
|
|
|
288
3736
|
|
|
289
|
-
/***/ }),
|
|
290
|
-
|
|
291
|
-
/***/ "ffcf":
|
|
292
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
293
|
-
|
|
294
|
-
// extracted by mini-css-extract-plugin
|
|
295
|
-
|
|
296
3737
|
/***/ })
|
|
297
3738
|
|
|
298
3739
|
/******/ });
|