diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..a91f0ce Binary files /dev/null and b/.DS_Store differ diff --git a/CHANGELOG.md b/CHANGELOG.md index e78fedc..0420211 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## 2.1.1 (2021-12-05) + +### Features + +* cache Bezier + + ## 2.0.0 (2021-07-19) * Refactoring using WebGL. diff --git a/example/image-preview/index.html b/example/image-preview/index.html index f6de274..5db4b11 100644 --- a/example/image-preview/index.html +++ b/example/image-preview/index.html @@ -76,7 +76,7 @@ hm.src = "https://hm.baidu.com/hm.js?e301069b9a5d63dcc7066a0a140f2195"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); - })();

🌲image preview example

1.Generated by query selector

HTML:

+    })();

🌲image preview example

1.Generated by query selector

HTML:

         <div class="imageWraper">
             <img data-src="/testImage/main_body3.png" src="/testImage/main_body3.png">
             <img data-src="/testImage/phone20190624.png" src="/testImage/phone20190624.png">
diff --git a/example/image-preview/test2.1.1.js b/example/image-preview/test2.1.1.js
new file mode 100644
index 0000000..36d9d9c
--- /dev/null
+++ b/example/image-preview/test2.1.1.js
@@ -0,0 +1 @@
+(()=>{var t={572:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Rotate=e.Zoom=e.Move=void 0;var n=i(730);Object.defineProperty(e,"Move",{enumerable:!0,get:function(){return n.Move}});var r=i(704);Object.defineProperty(e,"Zoom",{enumerable:!0,get:function(){return r.Zoom}});var o=i(841);Object.defineProperty(e,"Rotate",{enumerable:!0,get:function(){return o.Rotate}})},730:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Move=void 0;var i=function(){function t(){}return t.prototype.handleMove=function(t){var e=this;if(t.preventDefault(),2==t.touches.length)return clearTimeout(this.performerClick),void this.handleZoom(t);var i=this.actionExecutor.IsBoundaryLeft,n=this.actionExecutor.isBoundaryRight,r=i||n;if(t.touches[0].clientX-this.startXForDirection!=0){var o=t.touches[0].clientX-this.startXForDirection>0?"right":"left",s=this.actionExecutor.viewRect,a=s.left,h=s.right,c=this.actionExecutor.viewWidth/this.actionExecutor.dpr;if(this.fingerDirection)if(this.actionExecutor.isEnlargement)if(a>=0&&h<=c)if("right"!=o&&"left"!=o&&!this.isEnlargeMove||"horizontal"!=this.fingerDirection)this.handleMoveEnlage(t);else{this.isEnlargeMove=!0,this.handleMoveNormal(t);var l="resetEnlargeMove";this.addTouchEndTask(l,{priority:1,callback:function(){e.isEnlargeMove=!1}})}else i&&"right"==o||n&&"left"==o||this.isEnlargeMove?(this.isEnlargeMove=!0,this.handleMoveNormal(t),l="resetEnlargeMove",this.addTouchEndTask(l,{priority:1,callback:function(){return e.isEnlargeMove=!1}})):this.handleMoveEnlage(t);else this.handleMoveNormal(t);else{if(this.actionExecutor.isEnlargement&&(a<0||h>c)||!this.actionExecutor.isEnlargement)return void(!this.actionExecutor.isEnlargement||r||this.normalMoved?this.actionExecutor.isEnlargement?(r||this.normalMoved)&&(this.normalMoved?this.handleMoveNormal(t):"right"==o?i?this.handleMoveNormal(t):this.handleMoveEnlage(t):"left"==o&&n?this.handleMoveNormal(t):this.handleMoveEnlage(t)):this.handleMoveNormal(t):this.handleMoveEnlage(t));if(this.getMovePoints(t),this.movePoints.lengtho?p:0,i=Math.round(l)<0||Math.round(u)>s?g:0,e.eventsHanlder.handleMoveEnlage(n,i,0),this.addTouchEndTask("handleTendEnlarte",{priority:10,callback:this.handleTEndEnlarge.bind(this)}),this.startX=d,this.startY=f}},t.prototype.autoMove=function(t,e,i,n){var r=n.maxTop,o=n.minTop,s=n.maxLeft,a=n.minLeft,h=this.imgContainer.getBoundingClientRect(),c=h.width,l=h.height,u=this.actionExecutor,d=u.viewRect,f=u.eventsHanlder,p=d,g=p.top,m=p.bottom,v=p.left,x=p.right;t=t/180*Math.PI;var w=e+300*Math.cos(t),y=i+300*Math.sin(t);w>s?w=s:wr?y=r:y=0&&x<=c||(M=w-e),g>=0&&m<=l||(b=y-i),f.moveCurPlaneTo(M,b,0)},t}();e.Move=i},841:function(t,e){"use strict";var i=this&&this.__awaiter||function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},n=this&&this.__generator||function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((r=(r=s.trys).length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Zoom=void 0;var i=function(){function t(){}return t.prototype.handleZoom=function(t){if(!(this.isNormalMove&&this.normalMoved||this.isAnimating||this.actionExecutor.isLoadingError())){this.isZooming||(this.curStartPoint1={x:this.curPoint1.x,y:this.curPoint1.y},this.curStartPoint2={x:this.curPoint2.x,y:this.curPoint2.y}),this.isZooming=!0,this.isAnimating=!0;var e=this.actionExecutor,i=Math.pow(this.curPoint1.x-this.curPoint2.x,2)+Math.pow(this.curPoint1.y-this.curPoint2.y,2),n=Math.pow(t.touches[0].clientX-t.touches[1].clientX,2)+Math.pow(t.touches[0].clientY-t.touches[1].clientY,2),r=(this.curStartPoint1.x+this.curStartPoint2.x)/2,o=(this.curStartPoint1.y+this.curStartPoint2.y)/2,s=e.viewWidth/(2*e.dpr),a=e.viewHeight/(2*e.dpr);this.curPoint1.x=t.touches[0].clientX,this.curPoint1.y=t.touches[0].clientY,this.curPoint2.x=t.touches[1].clientX,this.curPoint2.y=t.touches[1].clientY;var h=0,c=0,l=1,u=1;if(i>n)c=(o-a)*this.zoomScale,h=(r-s)*this.zoomScale,l=1-this.zoomScale,u=1-this.zoomScale;else{if(!(i{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.easeInOut=e.easeOut=e.easeIn=e.ease=e.linear=e.cubicBezier=void 0;var i=function(){function t(t,e,i,n){this.cachedY=new Map,this.precision=1e-5,this.p1={x:t,y:e},this.p2={x:i,y:n}}return t.prototype.getX=function(t){var e=this.p1.x,i=this.p2.x;return 3*e*t*Math.pow(1-t,2)+3*i*Math.pow(t,2)*(1-t)+Math.pow(t,3)},t.prototype.getY=function(t){var e=this.p1.y,i=this.p2.y;return 3*e*t*Math.pow(1-t,2)+3*i*Math.pow(t,2)*(1-t)+Math.pow(t,3)},t.prototype.solveCurveX=function(t){for(var e,i,n,r=t,o=this.p1.x,s=this.p2.x,a=3*o-3*s+1,h=3*s-6*o,c=3*o,l=0;l<8;l++){if(i=this.getX(r)-t,Math.abs(i)d;){if(i=this.getX(r)-t,Math.abs(i)0?u=r:d=r,r=(u+d)/2}return r},t.prototype.solve=function(t){return this.cachedY.get(t)||this.cachedY.set(t,this.getY(this.solveCurveX(t))),this.cachedY.get(t)},t}();e.cubicBezier=i,e.linear=new i(0,0,1,1),e.ease=new i(.25,.1,.25,1),e.easeIn=new i(.42,0,1,1),e.easeOut=new i(0,0,.58,1),e.easeInOut=new i(.42,0,.58,1)},755:function(t,e,i){"use strict";var n=this&&this.__decorate||function(t,e,i,n){var r,o=arguments.length,s=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(s=(o<3?r(s):o>3?r(e,i,s):r(e,i))||s);return o>3&&s&&Object.defineProperty(e,i,s),s},r=this&&this.__awaiter||function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((r=(r=s.trys).length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]f?(w=f-m,x=!0):mu?(y=u-g,v=!0):g=0&&l<=n&&(x=!1,w=0),a<=r&&(v=!1,y=0),x||v?(this.isAnimating=!0,[4,e.eventsHanlder.handleTEndEnlarge(t,w,y,0)]):[3,2];case 1:return o.sent(),this.isAnimating=!1,[3,4];case 2:return this.moveEndTime=Date.now(),M={x:this.startX,y:this.startY},b={x:this.touchStartX,y:this.touchStartY},E=M.x-b.x,T=M.y-b.y,P=180*Math.atan2(T,E)/Math.PI,this.moveEndTime-this.moveStartTime<90&&Math.abs(E)+Math.abs(T)>5?(I={maxTop:u,minTop:d,maxLeft:f,minLeft:n-s},this.isAnimating=!0,[4,this.autoMove(P,c,h,I)]):[3,4];case 3:o.sent(),this.isAnimating=!1,o.label=4;case 4:return this.moveStartTime=0,[2]}}))}))},t.prototype.handleTEndEnNormal=function(t){return r(this,void 0,void 0,(function(){var e,i,n;return o(this,(function(r){switch(r.label){case 0:return this.isAnimating?[2]:(e=t.changedTouches[0].clientX,i=this.actionExecutor.eventsHanlder,0==(n=e-this.touchStartX)?[2]:(this.isAnimating=!0,[4,i.handleTEndEnNormal(t,n)]));case 1:return r.sent(),this.isAnimating=!1,[2]}}))}))},t.prototype.genFrame=function(){var t=this,e=this.options.imgs;!e||e.length,this.imgsNumber=e.length,this.curIndex=0;var i='\n                
\n \n \n \n \n
\n
\n
\n '+("pc"==this.envClient?'
\n \n
\n
\n \n
':"")+'\n
\n \n
\n
\n \n
\n
\n ',n=/iphone/gi.test(window.navigator.userAgent)&&window.devicePixelRatio&&3===window.devicePixelRatio&&375===window.screen.width&&812===window.screen.height,r=/iphone/gi.test(window.navigator.userAgent)&&window.devicePixelRatio&&3===window.devicePixelRatio&&414===window.screen.width&&896===window.screen.height,o=/iphone/gi.test(window.navigator.userAgent)&&window.devicePixelRatio&&2===window.devicePixelRatio&&414===window.screen.width&&896===window.screen.height,s=n||r||o,a="\n ."+this.prefix+"imagePreviewer{\n position: fixed;\n top:0;\n left: 100%;\n width: 100%;\n height: 100%;\n background: "+("pc"==t.envClient?"rgba(0,0,0,0.8)":"rgba(0,0,0,1)")+";\n color:#fff;\n transform: translate3d(0,0,0);\n transition: left 0.5s;\n overflow:hidden;\n user-select: none;\n }\n \n ."+this.prefix+"imagePreviewer."+this.defToggleClass+"{\n left: 0%;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"close{\n position: absolute;\n top: 20px;\n right: 20px;\n z-index: 10;\n box-sizing: border-box;\n width: 22px;\n height: 22px;\n cursor:pointer;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"close svg{\n width: 100%;\n height: 100%; \n }\n ."+this.prefix+"imagePreviewer svg{\n overflow:visible;\n }\n ."+this.prefix+"imagePreviewer svg path{\n stroke: #948888;\n stroke-width: 30px;\n }\n \n ."+this.prefix+"imagePreviewer "+this.prefix+".close."+this.prefix+"scroll{\n height: 0;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"imgContainer{\n position: relative;\n height: 100%;\n font-size: 0;\n white-space: nowrap;\n }\n \n ."+this.prefix+"imagePreviewer ."+this.prefix+"bottom{\n position: absolute;\n bottom: "+(s?20:0)+"px;\n left: 20px;\n right: 20px;\n z-index: 10;\n padding: 0 10px;\n text-align: center;\n border-top: 1px solid rgba(255, 255, 255, .2);\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"bottom ."+this.prefix+"item{\n display:inline-block;\n width: 42px;\n height: 42px;\n cursor:pointer;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"bottom ."+this.prefix+"item svg{\n box-sizing: border-box;\n width: 100%;\n height: 100%;\n padding:10px;\n }\n ";if(this.ref=document.createElement("div"),this.ref.className=this.prefix+"imagePreviewer",this.ref.innerHTML=i,!document.querySelector("#"+this.prefix+"style")){var h=document.createElement("style");h.id=this.prefix+"style",h.innerHTML=a,document.querySelector("head").appendChild(h)}this.ref.querySelector("."+this.prefix+"imgContainer").append(this.actionExecutor.ref),document.body.appendChild(this.ref)},t.prototype.handleReausetAnimate=function(){window.requestAnimationFrame||(window.requestAnimationFrame=window.webkitRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60),0})},t.prototype.close=function(t){t.stopImmediatePropagation(),clearTimeout(this.performerClick),this[this.envClient+"BeforeClose"](),this.toggleClass(this.ref,this.defToggleClass)},t.prototype.pcBeforeClose=function(){document.body.style.overflow=document.body.dataset.imgPreOverflow},t.prototype.mobileBeforeClose=function(){},t.prototype.show=function(t){this.actionExecutor.curIndex=t,this.actionExecutor.draw(t),this.toggleClass(this.ref,this.defToggleClass)},t.prototype.mobileReadyShow=function(){},t.prototype.pcReadyShow=function(){var t=window.getComputedStyle(document.body);document.body.dataset.imgPreOverflow=t.overflow,document.body.style.overflow="hidden"},t.prototype.toggleClass=function(t,e){var i=t.className.split(" "),n=i.indexOf(e);-1!==n?i.splice(n,1):i.push(e),t.className=i.join(" ")},t.prototype.getMovePoints=function(t){var e=this;this.movePoints.length>this.maxMovePointCounts||(this.movePoints.push({x:t.touches[0].clientX,y:t.touches[0].clientY}),this.addTouchEndTask("resetMovePoints",{priority:1,callback:function(){return e.movePoints=[]}}))},t.prototype.decideMoveDirection=function(){var t=this,e=this.movePoints.length,i=this.movePoints[e-1],n=this.movePoints[0],r=i.x-n.x,o=i.y-n.y,s=180*Math.atan2(o,r)/Math.PI;Math.abs(90-Math.abs(s))<30?this.fingerDirection="vertical":this.fingerDirection="horizontal",this.addTouchEndTask("resetFingerDirection",{priority:1,callback:function(){t.fingerDirection=""}})},t.prototype.destroy=function(){this.ref.parentNode.removeChild(this.ref),window.removeEventListener("resize",this.handleResize),window.removeEventListener("orientationchange",this.handleResize)},t.prototype.testEnv=function(){return/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)?"mobile":"pc"},n([a.default],t)}();e.ImagePreview=l,s=l,[h.Move,h.Zoom,h.Rotate].forEach((function(t){Object.getOwnPropertyNames(t.prototype).forEach((function(e){s.prototype[e]=t.prototype[e]}))}))},324:function(t,e){"use strict";var i,n=this&&this.__extends||(i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),r=this&&this.__awaiter||function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((r=(r=s.trys).length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]0?(h=-(i-s)*u,a=-(e-r)*u,c=1+u,l=1+u):(h=(i-s)*u,a=(e-r)*u,c=1-u,l=1-u),n.eventsHanlder.handleZoom(c,l,a,h),this.isZooming=!1,this.isAnimating=!1,this.actionExecutor.isEnlargement?this.ref.style.cursor="grab":this.ref.style.cursor="initial",[2]}))}))},e.prototype.handlePCDoubleClick=function(t){return r(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.isAnimating?[2]:(this.isAnimating=!0,[4,this.actionExecutor.eventsHanlder.handleDoubleClick({clientX:t.clientX,clientY:t.clientY})]);case 1:return e.sent(),this.isAnimating=!1,this.actionExecutor.isEnlargement?this.ref.style.cursor="grab":this.ref.style.cursor="initial",[2]}}))}))},e.prototype.handleMouseDown=function(t){var e=this,i=t.target.dataset.type;this[i]?this[i](t):(this.mouseDown=!0,this.actionExecutor.isEnlargement?(this.startX=t.clientX,this.startY=t.clientY,this.ref.style.cursor="grabbing"):this.ref.style.cursor="initial",Date.now()-this.lastClick0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]4*s||u*t=this.throldDeg?(s=t.curIndex,-1!=(a=t.curIndex+1*o)&&a!=t.imgUrls.length?[3,2]:(t.curIndex=s,[4,t.rotate(-n)])):[3,6];case 1:return r.sent(),[3,5];case 2:return[4,t.rotate(o*Math.PI/2-n)];case 3:return r.sent(),t.curIndex=a,t.modelMatrix=t.baseModel=t.initialModel,t.gl.uniformMatrix4fv(t.gl.getUniformLocation(t.shaderProgram,"uModelViewMatrix"),!1,t.modelMatrix),[4,t.draw(a)];case 4:r.sent(),r.label=5;case 5:return[3,8];case 6:return[4,t.rotate(-n)];case 7:r.sent(),r.label=8;case 8:return t.modelMatrix=t.baseModel=t.initialModel,[2,"handled"]}}))}))},t.prototype.handleTEndEnlarge=function(t,e,i,o){return n(this,void 0,void 0,(function(){var t;return r(this,(function(n){switch(n.label){case 0:return t=this.viewInstance,e*=t.dpr,i*=-t.dpr,t.dpr,this.curBehaviorCanBreak=!0,[4,t.moveCurPlane(e,i,0)];case 1:return n.sent(),this.curBehaviorCanBreak=!1,0!==e&&(t.isBoudriedSide=!0),[2]}}))}))},t.prototype.moveCurPlaneTo=function(t,e,i){return n(this,void 0,void 0,(function(){var i;return r(this,(function(n){switch(n.label){case 0:return i=this.viewInstance,t*=i.dpr,e*=-i.dpr,i.dpr,this.curBehaviorCanBreak=!0,[4,i.moveCurPlane(t,e,0)];case 1:return n.sent(),this.curBehaviorCanBreak=!1,[2]}}))}))},t}();e.events=s},401:function(t,e,i){"use strict";var n=this&&this.__awaiter||function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},r=this&&this.__generator||function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((r=(r=s.trys).length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]n&&(e=n-1,r=n),this.imgUrls.splice(e+1,0,t),e+1>this.imgs.length?this.imgs[r]=null:this.imgs.splice(e+1,0,null),t instanceof Image)if(void 0===t._id&&(t._id=this.imgId++),t.complete)this.imgUrls[e+1]=this.validateImg(t);else{var o=function(){var e=i.imgUrls.indexOf(t);t.loadError=!0,~[-2,-1,0].indexOf(e-i.curIndex)&&i.draw(i.curIndex)};t.addEventListener("load",(function(){var e=i.imgUrls.indexOf(t);i.imgUrls[e]=i.validateImg(t),~[-2,-1,0].indexOf(e-i.curIndex)&&i.draw(i.curIndex)})),t.addEventListener("error",o),t.addEventListener("abort",o)}~[-2,-1,0].indexOf(e-this.curIndex)&&this.draw(this.curIndex)},t.prototype.delImg=function(t){var e=this.imgUrls.length;t<=-1?t=0:t>=e&&(t=e-1),this.imgUrls.splice(t,1),this.imgs[t]&&this.textures.delete(this.imgs[t]._id),this.imgs.splice(t,1),t-=this.curIndex,~[-1,0,1].indexOf(t)&&this.draw(this.curIndex)},t.prototype.initOtherTexture=function(){var t=this,e=this.gl,i=e.createTexture();this.texturesOther.set(0,i),e.bindTexture(e.TEXTURE_2D,i),i.cubicBgd=!0,e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,new Uint8Array([0,0,0,255]));var n=new Image;n.onload=function(){var i=e.createTexture();t.texturesOther.set(1,i),e.bindTexture(e.TEXTURE_2D,i),t.texImage(n),t.setTexParameteri(n.width,n.height)},n.src=u.errImgBase64},t.prototype.initData=function(){this.draw(this.curIndex)},t.prototype.slideNext=function(){return n(this,void 0,void 0,(function(){var t=this;return r(this,(function(e){return this.curIndex==this.imgUrls.length-1?[2,[!0]]:[2,this.slide(.5*Math.PI,(function(){return t.curIndex++}))]}))}))},t.prototype.slideBefore=function(){return n(this,void 0,void 0,(function(){var t=this;return r(this,(function(e){return 0==this.curIndex?[2,[!0]]:[2,this.slide(-.5*Math.PI,(function(){return t.curIndex--}))]}))}))},t.prototype.slide=function(t,e){return n(this,void 0,void 0,(function(){return r(this,(function(i){switch(i.label){case 0:return this.baseModel=this.modelMatrix,[4,this.rotate(t)];case 1:return i.sent(),e(),this.modelMatrix=this.baseModel=this.initialModel,this.gl.uniformMatrix4fv(this.gl.getUniformLocation(this.shaderProgram,"uModelViewMatrix"),!1,this.modelMatrix),[4,this.draw(this.curIndex)];case 2:return i.sent(),this.modelMatrix=this.baseModel=this.initialModel,[2,[!1]]}}))}))},t.prototype.rotate=function(t){var e,i=this;return this.animate({allTime:this.defaultAnimateTime,timingFun:c.linear,ends:[t],playGame:(e=i.rotatePosition.bind(i),function(t){i.clear(),e(t)})})},t.prototype.rotateZ=function(t){var e=this;this.curPlane=this.positions.slice(this.curPointAt,this.curPointAt+16);var i=this.imgShape,n=this.imgShapeInitinal;this.imgShape=h.matrix.multiplyPoint(i,h.matrix.rotateZMatrix(t)),this.imgShapeInitinal=h.matrix.multiplyPoint(n,h.matrix.rotateZMatrix(t));var r=this.curCenterCoordinate,o=-r[0],s=-r[1];return this.animate({allTime:this.defaultAnimateTime,timingFun:c.linear,ends:[t,o,s],playGame:function(){for(var t=[],i=0;il?l:this.viewWidth):(i=l,n=u),p=-(t-r)*(d=i/a-1),g=(e-o)*(f=n/h-1),this.curIsLongImg()&&(p=0);return[d,f,p,g]},t.prototype.decideImgViewSize=function(t,e){var i=0,n=0;return(n=e/t*(i=this.viewWidth>=t?t:this.viewWidth))>this.viewHeight&&(i=(n=this.viewHeight)*t/e),[i,n]},t.prototype.draw=function(t){this.positions=[];for(var e=this.imgUrls.length,i=0,n=0,r=t-1;r<=t+1;r++)if(-1!==r&&r<=e-1){var o=void 0;this.imgs[r]?o=this.imgs[r]:"string"==typeof this.imgUrls[r]?o=this.loadImage(this.imgUrls[r],r):void 0===(o=this.imgUrls[r])._id&&(this.imgUrls[r]=this.validateImg(o),o=this.imgUrls[r]),this.imgs[r]=o;var s=o.naturalWidth,a=o.naturalHeight;o.loadError&&(s=a=200);var h=this.decideImgViewSize(s*this.dpr,a*this.dpr),c=h[0],l=h[1];r==this.curIndex&&(this.imgShape=[s*this.dpr,a*this.dpr,0,1],this.imgShapeInitinal=[c,l,0,1]),this.genPostion(c,l,r),i=Math.max(c,i),n=Math.max(l,n)}this.generateCube(i,n),this.bindPostion(),this.drawPosition()},t.prototype.createPerspectiveMatrix=function(){var t=this.fieldOfViewInRadians,e=this.viewWidth/this.viewHeight,i=this.zNear,n=this.zFar,r=1/Math.tan(t/2),o=1/(i-n);return[r/e,0,0,0,0,r,0,0,0,0,(i+n)*o,-1,0,0,i*n*o*2,0]},Object.defineProperty(t.prototype,"curPointAt",{get:function(){var t=64;return 0==this.curIndex&&(t=48),t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"IsBoundaryLeft",{get:function(){var t=this.viewRect;return Math.round(t.left)>=0&&this.isBoudriedSide},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isBoundaryRight",{get:function(){var t=this.viewRect;return Math.round(t.right*this.dpr)<=Math.round(this.viewWidth/1)&&this.isBoudriedSide},enumerable:!1,configurable:!0}),t.prototype.curIsLongImg=function(){var t=this.imgShape,e=t[0],i=t[1];return 2*Math.abs(e)<=Math.abs(i)},Object.defineProperty(t.prototype,"curCenterCoordinate",{get:function(){var t=this.curPointAt;return[(this.positions[t]+this.positions[t+8])/2,(this.positions[t+1]+this.positions[t+9])/2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"viewRect",{get:function(){for(var t=-this.viewWidth/2,e=this.viewHeight/2,i=this.curPointAt,n=1/0,r=-1/0,o=1/0,s=-1/0,a=i;athis.viewWidth||e.height*this.dpr-1>this.viewHeight},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isEnlargementForScale",{get:function(){var t=this.imgShapeInitinal,e=t[0],i=t[1],n=this.viewRect;return Math.round(n.width*this.dpr)>Math.round(Math.abs(e))||Math.round(n.height*this.dpr)>Math.round(Math.abs(i))},enumerable:!1,configurable:!0}),t.prototype.isLoadingError=function(t){return 0==arguments.length&&(t=this.curIndex),this.imgs[t].loadError},t.prototype.loadImage=function(t,e){var i=this,n=new Image;return n._id=this.imgId++,this.imgs[e]=n,n.onload=function(){i.handleImgLoaded(n,e)},n.onerror=function(){n.loadError=!0,i.handleImgLoaded(n,e)},n.onabort=function(){n.loadError=!0,i.handleImgLoaded(n,e)},n.crossOrigin="anonymous",n.src=t,n},t.prototype.handleImgLoaded=function(t,e){e=this.imgs.indexOf(t),t.loadError||(t=this.validateImg(t),this.imgs[e]=t),~[-1,0,1].indexOf(e-this.curIndex)&&(this.updatePosition(t,e-this.curIndex),this.bindPostion(),this.drawPosition())},t.prototype.validateImg=function(t){var e=this.gl.MAX_TEXTURE_SIZE,i=t.naturalWidth,n=t.naturalHeight;if(Math.max(n,i)>=e){var r=this.dpr,o=e/r,s=n/i*o;s>=e&&(o=i/n*(s=e/r));var a=d.tailor(t,o,s);return a._id=this.imgId++,a.naturalHeight=s,a.naturalWidth=o,a.complete=!0,a}return t},t.prototype.clear=function(){var t=this.gl;t.clearColor(0,0,0,1),t.clearDepth(1),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT)},t.prototype.bindShader=function(t,e,i){var n=this.loadShader(t,t.VERTEX_SHADER,i),r=this.loadShader(t,t.FRAGMENT_SHADER,e),o=t.createProgram();return t.attachShader(o,n),t.attachShader(o,r),t.linkProgram(o),t.getProgramParameter(o,t.LINK_STATUS)?o:(console.error("Unable to initialize the shader program: "+t.getProgramInfoLog(o)),null)},t.prototype.loadShader=function(t,e,i){var n=t.createShader(e);return t.shaderSource(n,i),t.compileShader(n),t.getShaderParameter(n,t.COMPILE_STATUS)?n:(console.error("An error occurred compiling the shaders: "+t.getShaderInfoLog(n)),t.deleteShader(n),null)},t.prototype.createPlane=function(t){return t.x,t.y,t.width,t.height,{}},t.prototype.intialView=function(){var t=document.createElement("canvas");t.style.cssText="\n position: absolute;\n top: 0;\n left:0;\n z-index: 9;\n width:"+window.innerWidth+"px;\n height:"+window.innerHeight+"px;\n user-select:none;\n font-size:0;\n ",t.width=window.innerWidth*this.dpr,t.height=window.innerHeight*this.dpr,this.ref=t;var e=t.getContext("webgl",{antialias:!0});return e||console.error("webgl is not supported. please use before version."),this.viewWidth=t.width,this.viewHeight=t.height,e},t.prototype.animate=function(t){var e,i=this,n=t.allTime,r=t.timingFun,o=t.ends,s=t.playGame,a=t.callback,h=Date.now(),c=h,l=new Promise((function(t){return e=t})),u=o.length,d=function(){if(i.curAimateBreaked)return e([!1,3]),void(i.curAimateBreaked=!1);var t=c-h;t>n&&(t=n);var l=t/n;l>1&&(l=1);var f=r.solve(l);f>=1&&(f=1);var p=new Array(u);o.forEach((function(t,e){p[e]=t*f})),s.apply(void 0,p),l<1?requestAnimationFrame(d):(a&&a(),e([!1,1])),c=Date.now()};return d(),l},t}();e.webGl=g},110:function(t,e){"use strict";var i=this&&this.__spreadArray||function(t,e){for(var i=0,n=e.length,r=t.length;i{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.errImgBase64=void 0,e.errImgBase64="data:image/svg+xml;base64,PHN2ZyB0PSIxNjI1ODExNDgwNTgyIiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEzNDIgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjYwNjkiIHdpZHRoPSIyMDAiIGhlaWdodD0iMjAwIj48cGF0aCBkPSJNMTIxNi4zNTcgMTM5LjAzYy0xMC4xNTctMTEuNDI3LTI0Ljc1OS0xNy43NzUtMzkuOTk1LTE4LjQxTDc0My40IDEwMy40OGwtMzIuMzc3IDczLjAwNiA0NS4wNzQgMTM1Ljg1Ni04MS4yNiAxNTQuMjY3IDMzLjAxMiAxMjQuNDI5IDgyLjUzIDEwNi42NTMgMTE5LjM1LTEwOS44MjdjMTEuNDI3LTEwLjc5MyAyOS44MzctMTAuMTU4IDM5Ljk5NCAxLjkwNGwxNTIuOTk3IDE2NS42OTRjMTAuNzkzIDExLjQyNyAxMC4xNTggMjkuODM3LTEuMjcgNDAuNjMtNS43MTMgNS4wNzgtMTIuNjk2IDguMjUzLTIwLjMxNCA3LjYxOGwtNDE5LjYzLTE2LjUwNi0yMC45NSA2MC4zMSAyMi44NTQgNTMuOTYyIDQ4Mi40OCAxOC40MWMzMS43NDIgMS4yNyA1OC40MDUtMjMuNDkgNTkuMDQtNTUuMjMxbDI2LjY2My02ODQuMzZjMC42MzUtMTUuMjM2LTQuNDQ0LTMwLjQ3Mi0xNS4yMzYtNDEuMjY1ek05MDYuNTU0IDQ1My4yNzdjLTQ3LjYxMy0xLjkwNC04NC40MzQtNDEuOS04Mi41My04OC44NzggMS45MDUtNDcuNjEzIDQxLjktODQuNDM0IDg4Ljg3OS04Mi41MyA0Ni45NzggMS45MDUgODQuNDM0IDQxLjkgODIuNTMgODguODc5LTEuOTA1IDQ2Ljk3OC00MS45IDg0LjQzNC04OC44NzkgODIuNTN6TTU5NS40ODIgODQ4LjE1bDE0LjYwMS02My40ODQtMzQwLjkxIDIzLjQ4OWMtMTUuODcxIDEuMjctMjkuMjAzLTEwLjE1OC0zMC40NzItMjYuMDI5YTI4LjEyIDI4LjEyIDAgMCAxIDYuOTgzLTIwLjk1TDQ5OC4zNSA0NzEuMDUzYzUuMDc5LTYuMzQ5IDEyLjY5Ny05LjUyMyAyMC45NS05LjUyMyA3LjYxOCAwIDE1LjIzNiAzLjE3NCAyMC45NSA4Ljg4OGw4NC40MzMgODguMjQzLTM2LjE4Ni05My45NTcgNjQuNzU0LTE2Mi41Mi01OS4wNC0xMzAuMTQyIDI0LjEyNC03NC45MTEtNDY0LjcwNCAzMi4zNzdjLTMxLjc0MiAxLjkwNC01NS4yMzIgMjkuMjAyLTUzLjMyNyA2MC45NDVsNDYuOTc4IDY4NC4zNmMwLjYzNSAxNS4yMzUgNy42MTggMjkuMjAyIDE5LjY4IDM4LjcyNSAxMS40MjggMTAuMTU3IDI2LjAyOSAxNS4yMzYgNDEuMjY1IDEzLjk2Nmw0MTUuMTg3LTI4LjU2OC0yNy45MzMtNTAuNzg3eiIgcC1pZD0iNjA3MCIgZmlsbD0iI2JmYmZiZiIvPjwvc3ZnPg=="},868:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.tailor=void 0,e.tailor=function(t,e,i){var n=t.naturalWidth,r=t.naturalHeight,o=document.createElement("canvas"),s=o.getContext("2d"),a=window.devicePixelRatio||1;return o.width=e*a,o.height=i*a,Date.now(),s.drawImage(t,0,0,n,r,0,0,e*a,i*a),o}},711:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.fps=e.canvasForTextures=void 0,e.canvasForTextures=function(t){var e=document.createElement("canvas");e.width=128,e.height=128,e.style.cssText="\n position: fixed;\n top: 0;\n left:0;\n z-index:100;\n width:128px;\n height:128px;\n user-select:none;\n font-size:0;\n ",document.body.append(e);var i=e.getContext("2d"),n=0;t.forEach((function(t){})),t.forEach((function(t){n+=t.naturalWidth}));var r=0,o=0,s=0;i.rect(0,0,e.width,e.height),i.fill(),t.forEach((function(t){r=t.naturalWidth/n,(o=t.naturalHeight/t.naturalWidth*r)>128?(function(t){o=1;var e=t.naturalWidth/t.naturalHeight*o;n-=t.naturalWidth,n+=e/r*t.naturalWidth}(t),o*=128,r=t.naturalHeight/t.naturalWidth*o):(r*=128,o=t.naturalHeight/t.naturalWidth*r),console.log(r,o),i.drawImage(t,0,0,t.naturalWidth,t.naturalHeight,s,0,r,o),s+=r}))},e.fps=function(){var t,e=0,i=document.createElement("pre");return i.style.cssText="\n position: fixed;\n top: 0;\n right: 50%;\n transform: translateX(50%);\n z-index:100;\n padding: 10px;\n font-size:12px;\n background: rgba(255,255,255,0.5);\n color:#000;\n ",document.body.append(i),function n(){t||(t=Date.now()),e++,Date.now()-t>=1e3&&(i.innerHTML=e.toString(),e=0,t=Date.now()),requestAnimationFrame(n)}}},233:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.sourceFrag=void 0,e.sourceFrag="precision mediump float;\n\nvarying vec2 vTextureCoord;\nuniform sampler2D uSampler0;\nuniform vec2 iResolution;\nvoid main() {\n\n // vec2 uv = vec2(gl_FragCoord.xy / iResolution.xy);\n vec4 color0 = texture2D(uSampler0, vTextureCoord) ;\n gl_FragColor = color0;\n}"},266:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.sourceVer=void 0,e.sourceVer="attribute vec4 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\n\nvarying mediump vec2 vTextureCoord;\n\nvoid main(void) {\n gl_Position = uProjectionMatrix * uModelViewMatrix * aVertexPosition;\n vTextureCoord = aTextureCoord;\n}"}},e={};function i(n){var r=e[n];if(void 0!==r)return r.exports;var o=e[n]={exports:{}};return t[n].call(o.exports,o,o.exports,i),o.exports}(()=>{"use strict";var t=i(755);i(711).fps()(),/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent);var e=new t.ImagePreview({imgs:["/testImage/BBC82C020430AED149F8D18A0849D241.png","https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fc-ssl.duitang.com%2Fuploads%2Fitem%2F201909%2F30%2F20190930192812_ZdJUw.jpeg&refer=http%3A%2F%2Fc-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1629013294&t=0fefdbd28f9926ff195325bd9d2bd4a9","https://iknow-pic.cdn.bcebos.com/9213b07eca806538184ec36695dda144ad34821a","https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fi0.hdslb.com%2Fbfs%2Farchive%2F1e93e74fb4b87734fb11bc487f9d7e2e9ce666f2.jpg&refer=http%3A%2F%2Fi0.hdslb.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1629028767&t=83072eef6345c4169751cef753b79bd7","/testImage/main_body3.png","https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fp.ssl.qhimg.com%2Ft017bbc635928363c05.jpg&refer=http%3A%2F%2Fp.ssl.qhimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1629274751&t=89d2696d8027df24bb767e6acb5330ac","/testImage/errorload.jpg","/testImage/BBC82C020430AED149F8D18A0849D241.png","/testImage/more20190627.png","/testImage/cubetexture.png","/testImage/IMG_0512.JPG","/testImage/main_body3.png","/testImage/main_body3.png","/testImage/main_body3.png","https://gimg2.baidu.com/image_search/src=http%3A%2F%2Ff.mgame.netease.com%2Fforum%2F201509%2F21%2F171337o26avxzpb6wpowza.gif&refer=http%3A%2F%2Ff.mgame.netease.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1628907951&t=85efd61fe8604d1fb018b1555e23d316"]});new t.ImagePreview({selector:".imageWraper img"}),e.show(0),setTimeout((function(){var t=new Image;t.crossOrigin="anonymous",t.src="/testImage/BBC82C020430AED149F8D18A0849D241.png"}),500);var n=document.querySelector("#stat");window.onerror=function(t,e,i,r,o){n.innerHTML="\n "+t+"\n "+e+"\n "+i+"\n "+r+"\n "+o+"\n "}})()})(); \ No newline at end of file diff --git a/example/js/image-preview-iife.js b/example/js/image-preview-iife.js index be740dd..4b3cf6d 100644 --- a/example/js/image-preview-iife.js +++ b/example/js/image-preview-iife.js @@ -765,6 +765,7 @@ var imagePreviewModule = (function (exports) { var cubicBezier = (function () { function cubicBezier(x1, y1, x2, y2) { + this.cachedY = new Map(); this.precision = 1e-5; this.p1 = { x: x1, @@ -824,7 +825,10 @@ var imagePreviewModule = (function (exports) { return t2; }; cubicBezier.prototype.solve = function (x) { - return this.getY(this.solveCurveX(x)); + if (!this.cachedY.get(x)) { + this.cachedY.set(x, this.getY(this.solveCurveX(x))); + } + return this.cachedY.get(x); }; return cubicBezier; }()); @@ -1342,7 +1346,8 @@ var imagePreviewModule = (function (exports) { }; webGl.prototype.genPostion = function (width, height, index) { var _a; - var z = -(this.viewHeight) / (2 * Math.tan(this.fieldOfViewInRadians / 2)) - forDev; + var zNearHeight = (2 * Math.tan(this.fieldOfViewInRadians / 2)); + var z = -(this.viewHeight) / (zNearHeight) - forDev; var viewWidth = this.viewWidth; var sideZAxis = z - (viewWidth - width) / 2; var positionsMap = [ diff --git a/package-lock.json b/package-lock.json index 989c6c3..20abbe2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "image-preview", - "version": "2.0.0", + "version": "2.2.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index bb4a0a7..5ca7c20 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,13 @@ { "name": "image-preview", - "version": "2.1.0", + "version": "2.1.1", "description": "image-preview", "scripts": { "start": "webpack serve --open Chrome.exe --mode=development", "build": "node scripts/beforeBuild.js && npm run genModule", "compileTs": "tsc --project ./src", "buildTest": "webpack --mode=production", - "genModule": ".\\scripts\\genModule.cmd", + "genModule": "./scripts/genModule.sh", "release": "standard-version" }, "repository": { diff --git a/release/image-preview/image-preview-amd-min.js b/release/image-preview/image-preview-amd-min.js index dbd8d95..a6fc55f 100644 --- a/release/image-preview/image-preview-amd-min.js +++ b/release/image-preview/image-preview-amd-min.js @@ -1 +1 @@ -define(["exports"],(function(t){"use strict";var e,i=(e=function(t,i){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(t,i)},function(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}),n=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},r=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]0?(h=-(i-s)*u,a=-(e-o)*u,l=1+u,c=1+u):(h=(i-s)*u,a=(e-o)*u,l=1-u,c=1-u),n.eventsHanlder.handleZoom(l,c,a,h),this.isZooming=!1,this.isAnimating=!1,this.actionExecutor.isEnlargement?this.ref.style.cursor="grab":this.ref.style.cursor="initial",[2]}))}))},e.prototype.handlePCDoubleClick=function(t){return n(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return this.isAnimating?[2]:(this.isAnimating=!0,[4,this.actionExecutor.eventsHanlder.handleDoubleClick({clientX:t.clientX,clientY:t.clientY})]);case 1:return e.sent(),this.isAnimating=!1,this.actionExecutor.isEnlargement?this.ref.style.cursor="grab":this.ref.style.cursor="initial",[2]}}))}))},e.prototype.handleMouseDown=function(t){var e=this,i=t.target.dataset.type;this[i]?this[i](t):(this.mouseDown=!0,this.actionExecutor.isEnlargement?(this.startX=t.clientX,this.startY=t.clientY,this.ref.style.cursor="grabbing"):this.ref.style.cursor="initial",Date.now()-this.lastClick0?"right":"left",s=this.actionExecutor.viewRect,a=s.left,h=s.right,l=this.actionExecutor.viewWidth/this.actionExecutor.dpr;if(this.fingerDirection)if(this.actionExecutor.isEnlargement)if(a>=0&&h<=l)if("right"!=o&&"left"!=o&&!this.isEnlargeMove||"horizontal"!=this.fingerDirection)this.handleMoveEnlage(t);else{this.isEnlargeMove=!0,this.handleMoveNormal(t);var c="resetEnlargeMove";this.addTouchEndTask(c,{priority:1,callback:function(){e.isEnlargeMove=!1}})}else if(i&&"right"==o||n&&"left"==o||this.isEnlargeMove){this.isEnlargeMove=!0,this.handleMoveNormal(t);c="resetEnlargeMove";this.addTouchEndTask(c,{priority:1,callback:function(){return e.isEnlargeMove=!1}})}else this.handleMoveEnlage(t);else this.handleMoveNormal(t);else{if(this.actionExecutor.isEnlargement&&(a<0||h>l)||!this.actionExecutor.isEnlargement)return void(!this.actionExecutor.isEnlargement||r||this.normalMoved?this.actionExecutor.isEnlargement?(r||this.normalMoved)&&(this.normalMoved?this.handleMoveNormal(t):"right"==o?i?this.handleMoveNormal(t):this.handleMoveEnlage(t):"left"==o&&n?this.handleMoveNormal(t):this.handleMoveEnlage(t)):this.handleMoveNormal(t):this.handleMoveEnlage(t));if(this.getMovePoints(t),this.movePoints.lengthn?p:0,s=Math.round(c)<0||Math.round(u)>r?g:0,e.eventsHanlder.handleMoveEnlage(a,s,0);this.addTouchEndTask("handleTendEnlarte",{priority:10,callback:this.handleTEndEnlarge.bind(this)}),this.startX=d,this.startY=f}},t.prototype.autoMove=function(t,e,i,n){var r=n.maxTop,o=n.minTop,s=n.maxLeft,a=n.minLeft,h=this.imgContainer.getBoundingClientRect(),l=h.width,c=h.height,u=this.actionExecutor,d=u.viewRect,f=u.eventsHanlder,p=d,g=p.top,v=p.bottom,m=p.left,w=p.right;t=t/180*Math.PI;var x=e+300*Math.cos(t),y=i+300*Math.sin(t);x>s?x=s:xr?y=r:y=0&&w<=l||(M=x-e),g>=0&&v<=c||(b=y-i),f.moveCurPlaneTo(M,b,0)},t}(),a=function(){function t(){}return t.prototype.handleZoom=function(t){if(!(this.isNormalMove&&this.normalMoved||this.isAnimating||this.actionExecutor.isLoadingError())){this.isZooming||(this.curStartPoint1={x:this.curPoint1.x,y:this.curPoint1.y},this.curStartPoint2={x:this.curPoint2.x,y:this.curPoint2.y}),this.isZooming=!0,this.isAnimating=!0;var e=this.actionExecutor,i=Math.pow(this.curPoint1.x-this.curPoint2.x,2)+Math.pow(this.curPoint1.y-this.curPoint2.y,2),n=Math.pow(t.touches[0].clientX-t.touches[1].clientX,2)+Math.pow(t.touches[0].clientY-t.touches[1].clientY,2),r=(this.curStartPoint1.x+this.curStartPoint2.x)/2,o=(this.curStartPoint1.y+this.curStartPoint2.y)/2,s=e.viewWidth/(2*e.dpr),a=e.viewHeight/(2*e.dpr);this.curPoint1.x=t.touches[0].clientX,this.curPoint1.y=t.touches[0].clientY,this.curPoint2.x=t.touches[1].clientX,this.curPoint2.y=t.touches[1].clientY;var h=0,l=0,c=1,u=1;if(i>n)l=(o-a)*this.zoomScale,h=(r-s)*this.zoomScale,c=1-this.zoomScale,u=1-this.zoomScale;else{if(!(i0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]d;){if(i=this.getX(r)-t,Math.abs(i)0?u=r:d=r,r=(u+d)/2}return r},t.prototype.solve=function(t){return this.getY(this.solveCurveX(t))},t}(),p=new f(0,0,1,1);new f(.25,.1,.25,1),new f(.42,0,1,1),new f(0,0,.58,1),new f(.42,0,.58,1);var g=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},v=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]4*s||(l*t=this.throldDeg?(o=t.curIndex,-1!=(s=t.curIndex+1*r)&&s!=t.imgUrls.length?[3,2]:(t.curIndex=o,[4,t.rotate(-n)])):[3,6];case 1:return a.sent(),[3,5];case 2:return[4,t.rotate(r*Math.PI/2-n)];case 3:return a.sent(),t.curIndex=s,t.modelMatrix=t.baseModel=t.initialModel,t.gl.uniformMatrix4fv(t.gl.getUniformLocation(t.shaderProgram,"uModelViewMatrix"),!1,t.modelMatrix),[4,t.draw(s)];case 4:a.sent(),a.label=5;case 5:return[3,8];case 6:return[4,t.rotate(-n)];case 7:a.sent(),a.label=8;case 8:return t.modelMatrix=t.baseModel=t.initialModel,[2,"handled"]}}))}))},t.prototype.handleTEndEnlarge=function(t,e,i,n){return g(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return t=this.viewInstance,e*=t.dpr,i*=-t.dpr,t.dpr,this.curBehaviorCanBreak=!0,[4,t.moveCurPlane(e,i,0)];case 1:return n.sent(),this.curBehaviorCanBreak=!1,0!==e&&(t.isBoudriedSide=!0),[2]}}))}))},t.prototype.moveCurPlaneTo=function(t,e,i){return g(this,void 0,void 0,(function(){var i;return v(this,(function(n){switch(n.label){case 0:return i=this.viewInstance,t*=i.dpr,e*=-i.dpr,i.dpr,this.curBehaviorCanBreak=!0,[4,i.moveCurPlane(t,e,0)];case 1:return n.sent(),this.curBehaviorCanBreak=!1,[2]}}))}))},t}();var w=function(t,e,i){var n=t.naturalWidth,r=t.naturalHeight,o=document.createElement("canvas"),s=o.getContext("2d"),a=window.devicePixelRatio||1;return o.width=e*a,o.height=i*a,s.drawImage(t,0,0,n,r,0,0,e*a,i*a),o},x=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},y=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]n&&(e=n-1,r=n),this.imgUrls.splice(e+1,0,t),e+1>this.imgs.length?this.imgs[r]=null:this.imgs.splice(e+1,0,null),t instanceof Image)if(void 0===t._id&&(t._id=this.imgId++),t.complete)this.imgUrls[e+1]=this.validateImg(t);else{var o=function(){var e=i.imgUrls.indexOf(t);t.loadError=!0,~[-2,-1,0].indexOf(e-i.curIndex)&&i.draw(i.curIndex)};t.addEventListener("load",(function(){var e=i.imgUrls.indexOf(t);i.imgUrls[e]=i.validateImg(t),~[-2,-1,0].indexOf(e-i.curIndex)&&i.draw(i.curIndex)})),t.addEventListener("error",o),t.addEventListener("abort",o)}~[-2,-1,0].indexOf(e-this.curIndex)&&this.draw(this.curIndex)},t.prototype.delImg=function(t){var e=this.imgUrls.length;t<=-1?t=0:t>=e&&(t=e-1),this.imgUrls.splice(t,1),this.imgs[t]&&this.textures.delete(this.imgs[t]._id),this.imgs.splice(t,1),t-=this.curIndex,~[-1,0,1].indexOf(t)&&this.draw(this.curIndex)},t.prototype.initOtherTexture=function(){var t=this,e=this.gl,i=e.createTexture();this.texturesOther.set(0,i),e.bindTexture(e.TEXTURE_2D,i),i.cubicBgd=!0;e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,new Uint8Array([0,0,0,255]));var n=new Image;n.onload=function(){var i=e.createTexture();t.texturesOther.set(1,i),e.bindTexture(e.TEXTURE_2D,i),t.texImage(n),t.setTexParameteri(n.width,n.height)},n.src="data:image/svg+xml;base64,PHN2ZyB0PSIxNjI1ODExNDgwNTgyIiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEzNDIgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjYwNjkiIHdpZHRoPSIyMDAiIGhlaWdodD0iMjAwIj48cGF0aCBkPSJNMTIxNi4zNTcgMTM5LjAzYy0xMC4xNTctMTEuNDI3LTI0Ljc1OS0xNy43NzUtMzkuOTk1LTE4LjQxTDc0My40IDEwMy40OGwtMzIuMzc3IDczLjAwNiA0NS4wNzQgMTM1Ljg1Ni04MS4yNiAxNTQuMjY3IDMzLjAxMiAxMjQuNDI5IDgyLjUzIDEwNi42NTMgMTE5LjM1LTEwOS44MjdjMTEuNDI3LTEwLjc5MyAyOS44MzctMTAuMTU4IDM5Ljk5NCAxLjkwNGwxNTIuOTk3IDE2NS42OTRjMTAuNzkzIDExLjQyNyAxMC4xNTggMjkuODM3LTEuMjcgNDAuNjMtNS43MTMgNS4wNzgtMTIuNjk2IDguMjUzLTIwLjMxNCA3LjYxOGwtNDE5LjYzLTE2LjUwNi0yMC45NSA2MC4zMSAyMi44NTQgNTMuOTYyIDQ4Mi40OCAxOC40MWMzMS43NDIgMS4yNyA1OC40MDUtMjMuNDkgNTkuMDQtNTUuMjMxbDI2LjY2My02ODQuMzZjMC42MzUtMTUuMjM2LTQuNDQ0LTMwLjQ3Mi0xNS4yMzYtNDEuMjY1ek05MDYuNTU0IDQ1My4yNzdjLTQ3LjYxMy0xLjkwNC04NC40MzQtNDEuOS04Mi41My04OC44NzggMS45MDUtNDcuNjEzIDQxLjktODQuNDM0IDg4Ljg3OS04Mi41MyA0Ni45NzggMS45MDUgODQuNDM0IDQxLjkgODIuNTMgODguODc5LTEuOTA1IDQ2Ljk3OC00MS45IDg0LjQzNC04OC44NzkgODIuNTN6TTU5NS40ODIgODQ4LjE1bDE0LjYwMS02My40ODQtMzQwLjkxIDIzLjQ4OWMtMTUuODcxIDEuMjctMjkuMjAzLTEwLjE1OC0zMC40NzItMjYuMDI5YTI4LjEyIDI4LjEyIDAgMCAxIDYuOTgzLTIwLjk1TDQ5OC4zNSA0NzEuMDUzYzUuMDc5LTYuMzQ5IDEyLjY5Ny05LjUyMyAyMC45NS05LjUyMyA3LjYxOCAwIDE1LjIzNiAzLjE3NCAyMC45NSA4Ljg4OGw4NC40MzMgODguMjQzLTM2LjE4Ni05My45NTcgNjQuNzU0LTE2Mi41Mi01OS4wNC0xMzAuMTQyIDI0LjEyNC03NC45MTEtNDY0LjcwNCAzMi4zNzdjLTMxLjc0MiAxLjkwNC01NS4yMzIgMjkuMjAyLTUzLjMyNyA2MC45NDVsNDYuOTc4IDY4NC4zNmMwLjYzNSAxNS4yMzUgNy42MTggMjkuMjAyIDE5LjY4IDM4LjcyNSAxMS40MjggMTAuMTU3IDI2LjAyOSAxNS4yMzYgNDEuMjY1IDEzLjk2Nmw0MTUuMTg3LTI4LjU2OC0yNy45MzMtNTAuNzg3eiIgcC1pZD0iNjA3MCIgZmlsbD0iI2JmYmZiZiIvPjwvc3ZnPg=="},t.prototype.initData=function(){this.draw(this.curIndex)},t.prototype.slideNext=function(){return x(this,void 0,void 0,(function(){var t=this;return y(this,(function(e){return this.curIndex==this.imgUrls.length-1?[2,[!0]]:[2,this.slide(.5*Math.PI,(function(){return t.curIndex++}))]}))}))},t.prototype.slideBefore=function(){return x(this,void 0,void 0,(function(){var t=this;return y(this,(function(e){return 0==this.curIndex?[2,[!0]]:[2,this.slide(-.5*Math.PI,(function(){return t.curIndex--}))]}))}))},t.prototype.slide=function(t,e){return x(this,void 0,void 0,(function(){return y(this,(function(i){switch(i.label){case 0:return this.baseModel=this.modelMatrix,[4,this.rotate(t)];case 1:return i.sent(),e(),this.modelMatrix=this.baseModel=this.initialModel,this.gl.uniformMatrix4fv(this.gl.getUniformLocation(this.shaderProgram,"uModelViewMatrix"),!1,this.modelMatrix),[4,this.draw(this.curIndex)];case 2:return i.sent(),this.modelMatrix=this.baseModel=this.initialModel,[2,[!1]]}}))}))},t.prototype.rotate=function(t){var e,i=this;return this.animate({allTime:this.defaultAnimateTime,timingFun:p,ends:[t],playGame:(e=i.rotatePosition.bind(i),function(t){i.clear(),e(t)})})},t.prototype.rotateZ=function(t){var e=this;this.curPlane=this.positions.slice(this.curPointAt,this.curPointAt+16);var i=this.imgShape,n=this.imgShapeInitinal;this.imgShape=d.multiplyPoint(i,d.rotateZMatrix(t)),this.imgShapeInitinal=d.multiplyPoint(n,d.rotateZMatrix(t));var r=this.curCenterCoordinate,o=-r[0],s=-r[1];return this.animate({allTime:this.defaultAnimateTime,timingFun:p,ends:[t,o,s],playGame:function(){for(var t=[],i=0;ic?c:this.viewWidth):(i=c,n=u),p=-(t-r)*(d=i/a-1),g=(e-o)*(f=n/h-1),this.curIsLongImg()&&(p=0);return[d,f,p,g]},t.prototype.decideImgViewSize=function(t,e){var i=0,n=0;return(n=e/t*(i=this.viewWidth>=t?t:this.viewWidth))>this.viewHeight&&(i=(n=this.viewHeight)*t/e),[i,n]},t.prototype.draw=function(t){this.positions=[];for(var e=this.imgUrls.length,i=0,n=0,r=t-1;r<=t+1;r++)if(-1!==r&&r<=e-1){var o=void 0;this.imgs[r]?o=this.imgs[r]:"string"==typeof this.imgUrls[r]?o=this.loadImage(this.imgUrls[r],r):void 0===(o=this.imgUrls[r])._id&&(this.imgUrls[r]=this.validateImg(o),o=this.imgUrls[r]),this.imgs[r]=o;var s=o.naturalWidth,a=o.naturalHeight;o.loadError&&(s=a=200);var h=this.decideImgViewSize(s*this.dpr,a*this.dpr),l=h[0],c=h[1];r==this.curIndex&&(this.imgShape=[s*this.dpr,a*this.dpr,0,1],this.imgShapeInitinal=[l,c,0,1]),this.genPostion(l,c,r),i=Math.max(l,i),n=Math.max(c,n)}this.generateCube(i,n),this.bindPostion(),this.drawPosition()},t.prototype.createPerspectiveMatrix=function(){var t=this.fieldOfViewInRadians,e=this.viewWidth/this.viewHeight,i=this.zNear,n=this.zFar,r=1/Math.tan(t/2),o=1/(i-n);return[r/e,0,0,0,0,r,0,0,0,0,(i+n)*o,-1,0,0,i*n*o*2,0]},Object.defineProperty(t.prototype,"curPointAt",{get:function(){var t=64;return 0==this.curIndex&&(t=48),t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"IsBoundaryLeft",{get:function(){var t=this.viewRect;return Math.round(t.left)>=0&&this.isBoudriedSide},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isBoundaryRight",{get:function(){var t=this.viewRect;return Math.round(t.right*this.dpr)<=Math.round(this.viewWidth/1)&&this.isBoudriedSide},enumerable:!1,configurable:!0}),t.prototype.curIsLongImg=function(){var t=this.imgShape,e=t[0],i=t[1];return 2*Math.abs(e)<=Math.abs(i)},Object.defineProperty(t.prototype,"curCenterCoordinate",{get:function(){var t=this.curPointAt;return[(this.positions[t]+this.positions[t+8])/2,(this.positions[t+1]+this.positions[t+9])/2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"viewRect",{get:function(){for(var t=-this.viewWidth/2,e=this.viewHeight/2,i=this.curPointAt,n=1/0,r=-1/0,o=1/0,s=-1/0,a=i;athis.viewWidth||e.height*this.dpr-1>this.viewHeight},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isEnlargementForScale",{get:function(){var t=this.imgShapeInitinal,e=t[0],i=t[1],n=this.viewRect;return Math.round(n.width*this.dpr)>Math.round(Math.abs(e))||Math.round(n.height*this.dpr)>Math.round(Math.abs(i))},enumerable:!1,configurable:!0}),t.prototype.isLoadingError=function(t){return 0==arguments.length&&(t=this.curIndex),this.imgs[t].loadError},t.prototype.loadImage=function(t,e){var i=this,n=new Image;return n._id=this.imgId++,this.imgs[e]=n,n.onload=function(){i.handleImgLoaded(n,e)},n.onerror=function(){n.loadError=!0,i.handleImgLoaded(n,e)},n.onabort=function(){n.loadError=!0,i.handleImgLoaded(n,e)},n.crossOrigin="anonymous",n.src=t,n},t.prototype.handleImgLoaded=function(t,e){e=this.imgs.indexOf(t),t.loadError||(t=this.validateImg(t),this.imgs[e]=t),~[-1,0,1].indexOf(e-this.curIndex)&&(this.updatePosition(t,e-this.curIndex),this.bindPostion(),this.drawPosition())},t.prototype.validateImg=function(t){var e=this.gl.MAX_TEXTURE_SIZE,i=t.naturalWidth,n=t.naturalHeight;if(Math.max(n,i)>=e){var r=this.dpr,o=e/r,s=n/i*o;s>=e&&(o=i/n*(s=e/r));var a=w(t,o,s);return a._id=this.imgId++,a.naturalHeight=s,a.naturalWidth=o,a.complete=!0,a}return t},t.prototype.clear=function(){var t=this.gl;t.clearColor(0,0,0,1),t.clearDepth(1),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT)},t.prototype.bindShader=function(t,e,i){var n=this.loadShader(t,t.VERTEX_SHADER,i),r=this.loadShader(t,t.FRAGMENT_SHADER,e),o=t.createProgram();return t.attachShader(o,n),t.attachShader(o,r),t.linkProgram(o),t.getProgramParameter(o,t.LINK_STATUS)?o:(console.error("Unable to initialize the shader program: "+t.getProgramInfoLog(o)),null)},t.prototype.loadShader=function(t,e,i){var n=t.createShader(e);return t.shaderSource(n,i),t.compileShader(n),t.getShaderParameter(n,t.COMPILE_STATUS)?n:(console.error("An error occurred compiling the shaders: "+t.getShaderInfoLog(n)),t.deleteShader(n),null)},t.prototype.createPlane=function(t){return t.x,t.y,t.width,t.height,{}},t.prototype.intialView=function(){var t=document.createElement("canvas");t.style.cssText="\n position: absolute;\n top: 0;\n left:0;\n z-index: 9;\n width:"+window.innerWidth+"px;\n height:"+window.innerHeight+"px;\n user-select:none;\n font-size:0;\n ",t.width=window.innerWidth*this.dpr,t.height=window.innerHeight*this.dpr,this.ref=t;var e=t.getContext("webgl",{antialias:!0});return e||console.error("webgl is not supported. please use before version."),this.viewWidth=t.width,this.viewHeight=t.height,e},t.prototype.animate=function(t){var e,i=this,n=t.allTime,r=t.timingFun,o=t.ends,s=t.playGame,a=t.callback,h=Date.now(),l=h,c=new Promise((function(t){return e=t})),u=o.length,d=function(){if(i.curAimateBreaked)return e([!1,3]),void(i.curAimateBreaked=!1);var t=l-h;t>n&&(t=n);var c=t/n;c>1&&(c=1);var f=r.solve(c);f>=1&&(f=1);var p=new Array(u);o.forEach((function(t,e){p[e]=t*f})),s.apply(void 0,p),c<1?requestAnimationFrame(d):(a&&a(),e([!1,1])),l=Date.now()};return d(),c},t}(),I=function(t,e,i,n){var r,o=arguments.length,s=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(s=(o<3?r(s):o>3?r(e,i,s):r(e,i))||s);return o>3&&s&&Object.defineProperty(e,i,s),s},A=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},S=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]d?(w=d-g,m=!0):gc?(x=c-p,v=!0):p=0&&l<=n&&(m=!1,w=0),s<=r&&(v=!1,x=0),m||v?(this.isAnimating=!0,[4,e.eventsHanlder.handleTEndEnlarge(t,w,x,0)]):[3,2];case 1:return I.sent(),this.isAnimating=!1,[3,4];case 2:return this.moveEndTime=Date.now(),y={x:this.startX,y:this.startY},M={x:this.touchStartX,y:this.touchStartY},b=y.x-M.x,E=y.y-M.y,T=180*Math.atan2(E,b)/Math.PI,this.moveEndTime-this.moveStartTime<90&&Math.abs(b)+Math.abs(E)>5?(P={maxTop:c,minTop:u,maxLeft:d,minLeft:n-o},this.isAnimating=!0,[4,this.autoMove(T,h,a,P)]):[3,4];case 3:I.sent(),this.isAnimating=!1,I.label=4;case 4:return this.moveStartTime=0,[2]}}))}))},t.prototype.handleTEndEnNormal=function(t){return A(this,void 0,void 0,(function(){var e,i,n;return S(this,(function(r){switch(r.label){case 0:return this.isAnimating?[2]:(e=t.changedTouches[0].clientX,i=this.actionExecutor.eventsHanlder,0===(n=e-this.touchStartX)?[2]:(this.isAnimating=!0,[4,i.handleTEndEnNormal(t,n)]));case 1:return r.sent(),this.isAnimating=!1,[2]}}))}))},t.prototype.genFrame=function(){var t=this,e=this.options.imgs;!e||e.length,this.imgsNumber=e.length,this.curIndex=0;var i='\n
\n \n \n \n \n
\n
\n
\n '+("pc"==this.envClient?'
\n \n
\n
\n \n
':"")+'\n
\n \n
\n
\n \n
\n
\n ',n=/iphone/gi.test(window.navigator.userAgent)&&window.devicePixelRatio&&3===window.devicePixelRatio&&375===window.screen.width&&812===window.screen.height,r=/iphone/gi.test(window.navigator.userAgent)&&window.devicePixelRatio&&3===window.devicePixelRatio&&414===window.screen.width&&896===window.screen.height,o=/iphone/gi.test(window.navigator.userAgent)&&window.devicePixelRatio&&2===window.devicePixelRatio&&414===window.screen.width&&896===window.screen.height,s=n||r||o,a="\n ."+this.prefix+"imagePreviewer{\n position: fixed;\n top:0;\n left: 100%;\n width: 100%;\n height: 100%;\n background: "+function(e){switch(e){case"conBackground":return"pc"==t.envClient?"rgba(0,0,0,0.8)":"rgba(0,0,0,1)";case"imgWidth":return t.envClient,"100%";case"itemHeight":return"pc"==t.envClient?"100%":"auto";case"itemScroll":return"pc"==t.envClient?"auto ":"hidden";case"item-text-align":return"pc"==t.envClient?"center ":"initial";default:return""}}("conBackground")+";\n color:#fff;\n transform: translate3d(0,0,0);\n transition: left 0.5s;\n overflow:hidden;\n user-select: none;\n }\n \n ."+this.prefix+"imagePreviewer."+this.defToggleClass+"{\n left: 0%;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"close{\n position: absolute;\n top: 20px;\n right: 20px;\n z-index: 10;\n box-sizing: border-box;\n width: 22px;\n height: 22px;\n cursor:pointer;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"close svg{\n width: 100%;\n height: 100%; \n }\n ."+this.prefix+"imagePreviewer svg{\n overflow:visible;\n }\n ."+this.prefix+"imagePreviewer svg path{\n stroke: #948888;\n stroke-width: 30px;\n }\n \n ."+this.prefix+"imagePreviewer "+this.prefix+".close."+this.prefix+"scroll{\n height: 0;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"imgContainer{\n position: relative;\n height: 100%;\n font-size: 0;\n white-space: nowrap;\n }\n \n ."+this.prefix+"imagePreviewer ."+this.prefix+"bottom{\n position: absolute;\n bottom: "+(s?20:0)+"px;\n left: 20px;\n right: 20px;\n z-index: 10;\n padding: 0 10px;\n text-align: center;\n border-top: 1px solid rgba(255, 255, 255, .2);\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"bottom ."+this.prefix+"item{\n display:inline-block;\n width: 42px;\n height: 42px;\n cursor:pointer;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"bottom ."+this.prefix+"item svg{\n box-sizing: border-box;\n width: 100%;\n height: 100%;\n padding:10px;\n }\n ";if(this.ref=document.createElement("div"),this.ref.className=this.prefix+"imagePreviewer",this.ref.innerHTML=i,!document.querySelector("#"+this.prefix+"style")){var h=document.createElement("style");h.id=this.prefix+"style",h.innerHTML=a,document.querySelector("head").appendChild(h)}this.ref.querySelector("."+this.prefix+"imgContainer").append(this.actionExecutor.ref),document.body.appendChild(this.ref)},t.prototype.handleReausetAnimate=function(){window.requestAnimationFrame||(window.requestAnimationFrame=window.webkitRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60),0})},t.prototype.close=function(t){t.stopImmediatePropagation(),clearTimeout(this.performerClick),this[this.envClient+"BeforeClose"](),this.toggleClass(this.ref,this.defToggleClass)},t.prototype.pcBeforeClose=function(){document.body.style.overflow=document.body.dataset.imgPreOverflow},t.prototype.mobileBeforeClose=function(){},t.prototype.show=function(t){this.actionExecutor.curIndex=t,this.actionExecutor.draw(t),this.toggleClass(this.ref,this.defToggleClass)},t.prototype.mobileReadyShow=function(){},t.prototype.pcReadyShow=function(){var t=window.getComputedStyle(document.body);document.body.dataset.imgPreOverflow=t.overflow,document.body.style.overflow="hidden"},t.prototype.toggleClass=function(t,e){var i=t.className.split(" "),n=i.indexOf(e);-1!==n?i.splice(n,1):i.push(e),t.className=i.join(" ")},t.prototype.getMovePoints=function(t){var e=this;if(!(this.movePoints.length>this.maxMovePointCounts)){this.movePoints.push({x:t.touches[0].clientX,y:t.touches[0].clientY});this.addTouchEndTask("resetMovePoints",{priority:1,callback:function(){return e.movePoints=[]}})}},t.prototype.decideMoveDirection=function(){var t=this,e=this.movePoints.length,i=this.movePoints[e-1],n=this.movePoints[0],r=i.x-n.x,o=i.y-n.y,s=180*Math.atan2(o,r)/Math.PI;Math.abs(90-Math.abs(s))<30?this.fingerDirection="vertical":this.fingerDirection="horizontal";this.addTouchEndTask("resetFingerDirection",{priority:1,callback:function(){t.fingerDirection=""}})},t.prototype.destroy=function(){this.ref.parentNode.removeChild(this.ref),window.removeEventListener("resize",this.handleResize),window.removeEventListener("orientationchange",this.handleResize)},t.prototype.testEnv=function(){return/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)?"mobile":"pc"},t=I([o],t)}();T=D,[s,a,c].forEach((function(t){Object.getOwnPropertyNames(t.prototype).forEach((function(e){T.prototype[e]=t.prototype[e]}))})),t.ImagePreview=D,Object.defineProperty(t,"__esModule",{value:!0})})); +define(["exports"],(function(t){"use strict";var e,i=(e=function(t,i){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(t,i)},function(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}),n=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},r=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]0?(h=-(i-s)*u,a=-(e-o)*u,l=1+u,c=1+u):(h=(i-s)*u,a=(e-o)*u,l=1-u,c=1-u),n.eventsHanlder.handleZoom(l,c,a,h),this.isZooming=!1,this.isAnimating=!1,this.actionExecutor.isEnlargement?this.ref.style.cursor="grab":this.ref.style.cursor="initial",[2]}))}))},e.prototype.handlePCDoubleClick=function(t){return n(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return this.isAnimating?[2]:(this.isAnimating=!0,[4,this.actionExecutor.eventsHanlder.handleDoubleClick({clientX:t.clientX,clientY:t.clientY})]);case 1:return e.sent(),this.isAnimating=!1,this.actionExecutor.isEnlargement?this.ref.style.cursor="grab":this.ref.style.cursor="initial",[2]}}))}))},e.prototype.handleMouseDown=function(t){var e=this,i=t.target.dataset.type;this[i]?this[i](t):(this.mouseDown=!0,this.actionExecutor.isEnlargement?(this.startX=t.clientX,this.startY=t.clientY,this.ref.style.cursor="grabbing"):this.ref.style.cursor="initial",Date.now()-this.lastClick0?"right":"left",s=this.actionExecutor.viewRect,a=s.left,h=s.right,l=this.actionExecutor.viewWidth/this.actionExecutor.dpr;if(this.fingerDirection)if(this.actionExecutor.isEnlargement)if(a>=0&&h<=l)if("right"!=o&&"left"!=o&&!this.isEnlargeMove||"horizontal"!=this.fingerDirection)this.handleMoveEnlage(t);else{this.isEnlargeMove=!0,this.handleMoveNormal(t);var c="resetEnlargeMove";this.addTouchEndTask(c,{priority:1,callback:function(){e.isEnlargeMove=!1}})}else if(i&&"right"==o||n&&"left"==o||this.isEnlargeMove){this.isEnlargeMove=!0,this.handleMoveNormal(t);c="resetEnlargeMove";this.addTouchEndTask(c,{priority:1,callback:function(){return e.isEnlargeMove=!1}})}else this.handleMoveEnlage(t);else this.handleMoveNormal(t);else{if(this.actionExecutor.isEnlargement&&(a<0||h>l)||!this.actionExecutor.isEnlargement)return void(!this.actionExecutor.isEnlargement||r||this.normalMoved?this.actionExecutor.isEnlargement?(r||this.normalMoved)&&(this.normalMoved?this.handleMoveNormal(t):"right"==o?i?this.handleMoveNormal(t):this.handleMoveEnlage(t):"left"==o&&n?this.handleMoveNormal(t):this.handleMoveEnlage(t)):this.handleMoveNormal(t):this.handleMoveEnlage(t));if(this.getMovePoints(t),this.movePoints.lengthn?p:0,s=Math.round(c)<0||Math.round(u)>r?g:0,e.eventsHanlder.handleMoveEnlage(a,s,0);this.addTouchEndTask("handleTendEnlarte",{priority:10,callback:this.handleTEndEnlarge.bind(this)}),this.startX=d,this.startY=f}},t.prototype.autoMove=function(t,e,i,n){var r=n.maxTop,o=n.minTop,s=n.maxLeft,a=n.minLeft,h=this.imgContainer.getBoundingClientRect(),l=h.width,c=h.height,u=this.actionExecutor,d=u.viewRect,f=u.eventsHanlder,p=d,g=p.top,v=p.bottom,m=p.left,w=p.right;t=t/180*Math.PI;var x=e+300*Math.cos(t),y=i+300*Math.sin(t);x>s?x=s:xr?y=r:y=0&&w<=l||(M=x-e),g>=0&&v<=c||(b=y-i),f.moveCurPlaneTo(M,b,0)},t}(),a=function(){function t(){}return t.prototype.handleZoom=function(t){if(!(this.isNormalMove&&this.normalMoved||this.isAnimating||this.actionExecutor.isLoadingError())){this.isZooming||(this.curStartPoint1={x:this.curPoint1.x,y:this.curPoint1.y},this.curStartPoint2={x:this.curPoint2.x,y:this.curPoint2.y}),this.isZooming=!0,this.isAnimating=!0;var e=this.actionExecutor,i=Math.pow(this.curPoint1.x-this.curPoint2.x,2)+Math.pow(this.curPoint1.y-this.curPoint2.y,2),n=Math.pow(t.touches[0].clientX-t.touches[1].clientX,2)+Math.pow(t.touches[0].clientY-t.touches[1].clientY,2),r=(this.curStartPoint1.x+this.curStartPoint2.x)/2,o=(this.curStartPoint1.y+this.curStartPoint2.y)/2,s=e.viewWidth/(2*e.dpr),a=e.viewHeight/(2*e.dpr);this.curPoint1.x=t.touches[0].clientX,this.curPoint1.y=t.touches[0].clientY,this.curPoint2.x=t.touches[1].clientX,this.curPoint2.y=t.touches[1].clientY;var h=0,l=0,c=1,u=1;if(i>n)l=(o-a)*this.zoomScale,h=(r-s)*this.zoomScale,c=1-this.zoomScale,u=1-this.zoomScale;else{if(!(i0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]d;){if(i=this.getX(r)-t,Math.abs(i)0?u=r:d=r,r=(u+d)/2}return r},t.prototype.solve=function(t){return this.cachedY.get(t)||this.cachedY.set(t,this.getY(this.solveCurveX(t))),this.cachedY.get(t)},t}(),p=new f(0,0,1,1);new f(.25,.1,.25,1),new f(.42,0,1,1),new f(0,0,.58,1),new f(.42,0,.58,1);var g=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},v=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]4*s||(l*t=this.throldDeg?(o=t.curIndex,-1!=(s=t.curIndex+1*r)&&s!=t.imgUrls.length?[3,2]:(t.curIndex=o,[4,t.rotate(-n)])):[3,6];case 1:return a.sent(),[3,5];case 2:return[4,t.rotate(r*Math.PI/2-n)];case 3:return a.sent(),t.curIndex=s,t.modelMatrix=t.baseModel=t.initialModel,t.gl.uniformMatrix4fv(t.gl.getUniformLocation(t.shaderProgram,"uModelViewMatrix"),!1,t.modelMatrix),[4,t.draw(s)];case 4:a.sent(),a.label=5;case 5:return[3,8];case 6:return[4,t.rotate(-n)];case 7:a.sent(),a.label=8;case 8:return t.modelMatrix=t.baseModel=t.initialModel,[2,"handled"]}}))}))},t.prototype.handleTEndEnlarge=function(t,e,i,n){return g(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return t=this.viewInstance,e*=t.dpr,i*=-t.dpr,t.dpr,this.curBehaviorCanBreak=!0,[4,t.moveCurPlane(e,i,0)];case 1:return n.sent(),this.curBehaviorCanBreak=!1,0!==e&&(t.isBoudriedSide=!0),[2]}}))}))},t.prototype.moveCurPlaneTo=function(t,e,i){return g(this,void 0,void 0,(function(){var i;return v(this,(function(n){switch(n.label){case 0:return i=this.viewInstance,t*=i.dpr,e*=-i.dpr,i.dpr,this.curBehaviorCanBreak=!0,[4,i.moveCurPlane(t,e,0)];case 1:return n.sent(),this.curBehaviorCanBreak=!1,[2]}}))}))},t}();var w=function(t,e,i){var n=t.naturalWidth,r=t.naturalHeight,o=document.createElement("canvas"),s=o.getContext("2d"),a=window.devicePixelRatio||1;return o.width=e*a,o.height=i*a,s.drawImage(t,0,0,n,r,0,0,e*a,i*a),o},x=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},y=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]n&&(e=n-1,r=n),this.imgUrls.splice(e+1,0,t),e+1>this.imgs.length?this.imgs[r]=null:this.imgs.splice(e+1,0,null),t instanceof Image)if(void 0===t._id&&(t._id=this.imgId++),t.complete)this.imgUrls[e+1]=this.validateImg(t);else{var o=function(){var e=i.imgUrls.indexOf(t);t.loadError=!0,~[-2,-1,0].indexOf(e-i.curIndex)&&i.draw(i.curIndex)};t.addEventListener("load",(function(){var e=i.imgUrls.indexOf(t);i.imgUrls[e]=i.validateImg(t),~[-2,-1,0].indexOf(e-i.curIndex)&&i.draw(i.curIndex)})),t.addEventListener("error",o),t.addEventListener("abort",o)}~[-2,-1,0].indexOf(e-this.curIndex)&&this.draw(this.curIndex)},t.prototype.delImg=function(t){var e=this.imgUrls.length;t<=-1?t=0:t>=e&&(t=e-1),this.imgUrls.splice(t,1),this.imgs[t]&&this.textures.delete(this.imgs[t]._id),this.imgs.splice(t,1),t-=this.curIndex,~[-1,0,1].indexOf(t)&&this.draw(this.curIndex)},t.prototype.initOtherTexture=function(){var t=this,e=this.gl,i=e.createTexture();this.texturesOther.set(0,i),e.bindTexture(e.TEXTURE_2D,i),i.cubicBgd=!0;e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,new Uint8Array([0,0,0,255]));var n=new Image;n.onload=function(){var i=e.createTexture();t.texturesOther.set(1,i),e.bindTexture(e.TEXTURE_2D,i),t.texImage(n),t.setTexParameteri(n.width,n.height)},n.src="data:image/svg+xml;base64,PHN2ZyB0PSIxNjI1ODExNDgwNTgyIiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEzNDIgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjYwNjkiIHdpZHRoPSIyMDAiIGhlaWdodD0iMjAwIj48cGF0aCBkPSJNMTIxNi4zNTcgMTM5LjAzYy0xMC4xNTctMTEuNDI3LTI0Ljc1OS0xNy43NzUtMzkuOTk1LTE4LjQxTDc0My40IDEwMy40OGwtMzIuMzc3IDczLjAwNiA0NS4wNzQgMTM1Ljg1Ni04MS4yNiAxNTQuMjY3IDMzLjAxMiAxMjQuNDI5IDgyLjUzIDEwNi42NTMgMTE5LjM1LTEwOS44MjdjMTEuNDI3LTEwLjc5MyAyOS44MzctMTAuMTU4IDM5Ljk5NCAxLjkwNGwxNTIuOTk3IDE2NS42OTRjMTAuNzkzIDExLjQyNyAxMC4xNTggMjkuODM3LTEuMjcgNDAuNjMtNS43MTMgNS4wNzgtMTIuNjk2IDguMjUzLTIwLjMxNCA3LjYxOGwtNDE5LjYzLTE2LjUwNi0yMC45NSA2MC4zMSAyMi44NTQgNTMuOTYyIDQ4Mi40OCAxOC40MWMzMS43NDIgMS4yNyA1OC40MDUtMjMuNDkgNTkuMDQtNTUuMjMxbDI2LjY2My02ODQuMzZjMC42MzUtMTUuMjM2LTQuNDQ0LTMwLjQ3Mi0xNS4yMzYtNDEuMjY1ek05MDYuNTU0IDQ1My4yNzdjLTQ3LjYxMy0xLjkwNC04NC40MzQtNDEuOS04Mi41My04OC44NzggMS45MDUtNDcuNjEzIDQxLjktODQuNDM0IDg4Ljg3OS04Mi41MyA0Ni45NzggMS45MDUgODQuNDM0IDQxLjkgODIuNTMgODguODc5LTEuOTA1IDQ2Ljk3OC00MS45IDg0LjQzNC04OC44NzkgODIuNTN6TTU5NS40ODIgODQ4LjE1bDE0LjYwMS02My40ODQtMzQwLjkxIDIzLjQ4OWMtMTUuODcxIDEuMjctMjkuMjAzLTEwLjE1OC0zMC40NzItMjYuMDI5YTI4LjEyIDI4LjEyIDAgMCAxIDYuOTgzLTIwLjk1TDQ5OC4zNSA0NzEuMDUzYzUuMDc5LTYuMzQ5IDEyLjY5Ny05LjUyMyAyMC45NS05LjUyMyA3LjYxOCAwIDE1LjIzNiAzLjE3NCAyMC45NSA4Ljg4OGw4NC40MzMgODguMjQzLTM2LjE4Ni05My45NTcgNjQuNzU0LTE2Mi41Mi01OS4wNC0xMzAuMTQyIDI0LjEyNC03NC45MTEtNDY0LjcwNCAzMi4zNzdjLTMxLjc0MiAxLjkwNC01NS4yMzIgMjkuMjAyLTUzLjMyNyA2MC45NDVsNDYuOTc4IDY4NC4zNmMwLjYzNSAxNS4yMzUgNy42MTggMjkuMjAyIDE5LjY4IDM4LjcyNSAxMS40MjggMTAuMTU3IDI2LjAyOSAxNS4yMzYgNDEuMjY1IDEzLjk2Nmw0MTUuMTg3LTI4LjU2OC0yNy45MzMtNTAuNzg3eiIgcC1pZD0iNjA3MCIgZmlsbD0iI2JmYmZiZiIvPjwvc3ZnPg=="},t.prototype.initData=function(){this.draw(this.curIndex)},t.prototype.slideNext=function(){return x(this,void 0,void 0,(function(){var t=this;return y(this,(function(e){return this.curIndex==this.imgUrls.length-1?[2,[!0]]:[2,this.slide(.5*Math.PI,(function(){return t.curIndex++}))]}))}))},t.prototype.slideBefore=function(){return x(this,void 0,void 0,(function(){var t=this;return y(this,(function(e){return 0==this.curIndex?[2,[!0]]:[2,this.slide(-.5*Math.PI,(function(){return t.curIndex--}))]}))}))},t.prototype.slide=function(t,e){return x(this,void 0,void 0,(function(){return y(this,(function(i){switch(i.label){case 0:return this.baseModel=this.modelMatrix,[4,this.rotate(t)];case 1:return i.sent(),e(),this.modelMatrix=this.baseModel=this.initialModel,this.gl.uniformMatrix4fv(this.gl.getUniformLocation(this.shaderProgram,"uModelViewMatrix"),!1,this.modelMatrix),[4,this.draw(this.curIndex)];case 2:return i.sent(),this.modelMatrix=this.baseModel=this.initialModel,[2,[!1]]}}))}))},t.prototype.rotate=function(t){var e,i=this;return this.animate({allTime:this.defaultAnimateTime,timingFun:p,ends:[t],playGame:(e=i.rotatePosition.bind(i),function(t){i.clear(),e(t)})})},t.prototype.rotateZ=function(t){var e=this;this.curPlane=this.positions.slice(this.curPointAt,this.curPointAt+16);var i=this.imgShape,n=this.imgShapeInitinal;this.imgShape=d.multiplyPoint(i,d.rotateZMatrix(t)),this.imgShapeInitinal=d.multiplyPoint(n,d.rotateZMatrix(t));var r=this.curCenterCoordinate,o=-r[0],s=-r[1];return this.animate({allTime:this.defaultAnimateTime,timingFun:p,ends:[t,o,s],playGame:function(){for(var t=[],i=0;ic?c:this.viewWidth):(i=c,n=u),p=-(t-r)*(d=i/a-1),g=(e-o)*(f=n/h-1),this.curIsLongImg()&&(p=0);return[d,f,p,g]},t.prototype.decideImgViewSize=function(t,e){var i=0,n=0;return(n=e/t*(i=this.viewWidth>=t?t:this.viewWidth))>this.viewHeight&&(i=(n=this.viewHeight)*t/e),[i,n]},t.prototype.draw=function(t){this.positions=[];for(var e=this.imgUrls.length,i=0,n=0,r=t-1;r<=t+1;r++)if(-1!==r&&r<=e-1){var o=void 0;this.imgs[r]?o=this.imgs[r]:"string"==typeof this.imgUrls[r]?o=this.loadImage(this.imgUrls[r],r):void 0===(o=this.imgUrls[r])._id&&(this.imgUrls[r]=this.validateImg(o),o=this.imgUrls[r]),this.imgs[r]=o;var s=o.naturalWidth,a=o.naturalHeight;o.loadError&&(s=a=200);var h=this.decideImgViewSize(s*this.dpr,a*this.dpr),l=h[0],c=h[1];r==this.curIndex&&(this.imgShape=[s*this.dpr,a*this.dpr,0,1],this.imgShapeInitinal=[l,c,0,1]),this.genPostion(l,c,r),i=Math.max(l,i),n=Math.max(c,n)}this.generateCube(i,n),this.bindPostion(),this.drawPosition()},t.prototype.createPerspectiveMatrix=function(){var t=this.fieldOfViewInRadians,e=this.viewWidth/this.viewHeight,i=this.zNear,n=this.zFar,r=1/Math.tan(t/2),o=1/(i-n);return[r/e,0,0,0,0,r,0,0,0,0,(i+n)*o,-1,0,0,i*n*o*2,0]},Object.defineProperty(t.prototype,"curPointAt",{get:function(){var t=64;return 0==this.curIndex&&(t=48),t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"IsBoundaryLeft",{get:function(){var t=this.viewRect;return Math.round(t.left)>=0&&this.isBoudriedSide},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isBoundaryRight",{get:function(){var t=this.viewRect;return Math.round(t.right*this.dpr)<=Math.round(this.viewWidth/1)&&this.isBoudriedSide},enumerable:!1,configurable:!0}),t.prototype.curIsLongImg=function(){var t=this.imgShape,e=t[0],i=t[1];return 2*Math.abs(e)<=Math.abs(i)},Object.defineProperty(t.prototype,"curCenterCoordinate",{get:function(){var t=this.curPointAt;return[(this.positions[t]+this.positions[t+8])/2,(this.positions[t+1]+this.positions[t+9])/2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"viewRect",{get:function(){for(var t=-this.viewWidth/2,e=this.viewHeight/2,i=this.curPointAt,n=1/0,r=-1/0,o=1/0,s=-1/0,a=i;athis.viewWidth||e.height*this.dpr-1>this.viewHeight},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isEnlargementForScale",{get:function(){var t=this.imgShapeInitinal,e=t[0],i=t[1],n=this.viewRect;return Math.round(n.width*this.dpr)>Math.round(Math.abs(e))||Math.round(n.height*this.dpr)>Math.round(Math.abs(i))},enumerable:!1,configurable:!0}),t.prototype.isLoadingError=function(t){return 0==arguments.length&&(t=this.curIndex),this.imgs[t].loadError},t.prototype.loadImage=function(t,e){var i=this,n=new Image;return n._id=this.imgId++,this.imgs[e]=n,n.onload=function(){i.handleImgLoaded(n,e)},n.onerror=function(){n.loadError=!0,i.handleImgLoaded(n,e)},n.onabort=function(){n.loadError=!0,i.handleImgLoaded(n,e)},n.crossOrigin="anonymous",n.src=t,n},t.prototype.handleImgLoaded=function(t,e){e=this.imgs.indexOf(t),t.loadError||(t=this.validateImg(t),this.imgs[e]=t),~[-1,0,1].indexOf(e-this.curIndex)&&(this.updatePosition(t,e-this.curIndex),this.bindPostion(),this.drawPosition())},t.prototype.validateImg=function(t){var e=this.gl.MAX_TEXTURE_SIZE,i=t.naturalWidth,n=t.naturalHeight;if(Math.max(n,i)>=e){var r=this.dpr,o=e/r,s=n/i*o;s>=e&&(o=i/n*(s=e/r));var a=w(t,o,s);return a._id=this.imgId++,a.naturalHeight=s,a.naturalWidth=o,a.complete=!0,a}return t},t.prototype.clear=function(){var t=this.gl;t.clearColor(0,0,0,1),t.clearDepth(1),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT)},t.prototype.bindShader=function(t,e,i){var n=this.loadShader(t,t.VERTEX_SHADER,i),r=this.loadShader(t,t.FRAGMENT_SHADER,e),o=t.createProgram();return t.attachShader(o,n),t.attachShader(o,r),t.linkProgram(o),t.getProgramParameter(o,t.LINK_STATUS)?o:(console.error("Unable to initialize the shader program: "+t.getProgramInfoLog(o)),null)},t.prototype.loadShader=function(t,e,i){var n=t.createShader(e);return t.shaderSource(n,i),t.compileShader(n),t.getShaderParameter(n,t.COMPILE_STATUS)?n:(console.error("An error occurred compiling the shaders: "+t.getShaderInfoLog(n)),t.deleteShader(n),null)},t.prototype.createPlane=function(t){return t.x,t.y,t.width,t.height,{}},t.prototype.intialView=function(){var t=document.createElement("canvas");t.style.cssText="\n position: absolute;\n top: 0;\n left:0;\n z-index: 9;\n width:"+window.innerWidth+"px;\n height:"+window.innerHeight+"px;\n user-select:none;\n font-size:0;\n ",t.width=window.innerWidth*this.dpr,t.height=window.innerHeight*this.dpr,this.ref=t;var e=t.getContext("webgl",{antialias:!0});return e||console.error("webgl is not supported. please use before version."),this.viewWidth=t.width,this.viewHeight=t.height,e},t.prototype.animate=function(t){var e,i=this,n=t.allTime,r=t.timingFun,o=t.ends,s=t.playGame,a=t.callback,h=Date.now(),l=h,c=new Promise((function(t){return e=t})),u=o.length,d=function(){if(i.curAimateBreaked)return e([!1,3]),void(i.curAimateBreaked=!1);var t=l-h;t>n&&(t=n);var c=t/n;c>1&&(c=1);var f=r.solve(c);f>=1&&(f=1);var p=new Array(u);o.forEach((function(t,e){p[e]=t*f})),s.apply(void 0,p),c<1?requestAnimationFrame(d):(a&&a(),e([!1,1])),l=Date.now()};return d(),c},t}(),I=function(t,e,i,n){var r,o=arguments.length,s=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(s=(o<3?r(s):o>3?r(e,i,s):r(e,i))||s);return o>3&&s&&Object.defineProperty(e,i,s),s},A=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},S=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]d?(w=d-g,m=!0):gc?(x=c-p,v=!0):p=0&&l<=n&&(m=!1,w=0),s<=r&&(v=!1,x=0),m||v?(this.isAnimating=!0,[4,e.eventsHanlder.handleTEndEnlarge(t,w,x,0)]):[3,2];case 1:return I.sent(),this.isAnimating=!1,[3,4];case 2:return this.moveEndTime=Date.now(),y={x:this.startX,y:this.startY},M={x:this.touchStartX,y:this.touchStartY},b=y.x-M.x,E=y.y-M.y,T=180*Math.atan2(E,b)/Math.PI,this.moveEndTime-this.moveStartTime<90&&Math.abs(b)+Math.abs(E)>5?(P={maxTop:c,minTop:u,maxLeft:d,minLeft:n-o},this.isAnimating=!0,[4,this.autoMove(T,h,a,P)]):[3,4];case 3:I.sent(),this.isAnimating=!1,I.label=4;case 4:return this.moveStartTime=0,[2]}}))}))},t.prototype.handleTEndEnNormal=function(t){return A(this,void 0,void 0,(function(){var e,i,n;return S(this,(function(r){switch(r.label){case 0:return this.isAnimating?[2]:(e=t.changedTouches[0].clientX,i=this.actionExecutor.eventsHanlder,0===(n=e-this.touchStartX)?[2]:(this.isAnimating=!0,[4,i.handleTEndEnNormal(t,n)]));case 1:return r.sent(),this.isAnimating=!1,[2]}}))}))},t.prototype.genFrame=function(){var t=this,e=this.options.imgs;!e||e.length,this.imgsNumber=e.length,this.curIndex=0;var i='\n
\n \n \n \n \n
\n
\n
\n '+("pc"==this.envClient?'
\n \n
\n
\n \n
':"")+'\n
\n \n
\n
\n \n
\n
\n ',n=/iphone/gi.test(window.navigator.userAgent)&&window.devicePixelRatio&&3===window.devicePixelRatio&&375===window.screen.width&&812===window.screen.height,r=/iphone/gi.test(window.navigator.userAgent)&&window.devicePixelRatio&&3===window.devicePixelRatio&&414===window.screen.width&&896===window.screen.height,o=/iphone/gi.test(window.navigator.userAgent)&&window.devicePixelRatio&&2===window.devicePixelRatio&&414===window.screen.width&&896===window.screen.height,s=n||r||o,a="\n ."+this.prefix+"imagePreviewer{\n position: fixed;\n top:0;\n left: 100%;\n width: 100%;\n height: 100%;\n background: "+function(e){switch(e){case"conBackground":return"pc"==t.envClient?"rgba(0,0,0,0.8)":"rgba(0,0,0,1)";case"imgWidth":return t.envClient,"100%";case"itemHeight":return"pc"==t.envClient?"100%":"auto";case"itemScroll":return"pc"==t.envClient?"auto ":"hidden";case"item-text-align":return"pc"==t.envClient?"center ":"initial";default:return""}}("conBackground")+";\n color:#fff;\n transform: translate3d(0,0,0);\n transition: left 0.5s;\n overflow:hidden;\n user-select: none;\n }\n \n ."+this.prefix+"imagePreviewer."+this.defToggleClass+"{\n left: 0%;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"close{\n position: absolute;\n top: 20px;\n right: 20px;\n z-index: 10;\n box-sizing: border-box;\n width: 22px;\n height: 22px;\n cursor:pointer;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"close svg{\n width: 100%;\n height: 100%; \n }\n ."+this.prefix+"imagePreviewer svg{\n overflow:visible;\n }\n ."+this.prefix+"imagePreviewer svg path{\n stroke: #948888;\n stroke-width: 30px;\n }\n \n ."+this.prefix+"imagePreviewer "+this.prefix+".close."+this.prefix+"scroll{\n height: 0;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"imgContainer{\n position: relative;\n height: 100%;\n font-size: 0;\n white-space: nowrap;\n }\n \n ."+this.prefix+"imagePreviewer ."+this.prefix+"bottom{\n position: absolute;\n bottom: "+(s?20:0)+"px;\n left: 20px;\n right: 20px;\n z-index: 10;\n padding: 0 10px;\n text-align: center;\n border-top: 1px solid rgba(255, 255, 255, .2);\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"bottom ."+this.prefix+"item{\n display:inline-block;\n width: 42px;\n height: 42px;\n cursor:pointer;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"bottom ."+this.prefix+"item svg{\n box-sizing: border-box;\n width: 100%;\n height: 100%;\n padding:10px;\n }\n ";if(this.ref=document.createElement("div"),this.ref.className=this.prefix+"imagePreviewer",this.ref.innerHTML=i,!document.querySelector("#"+this.prefix+"style")){var h=document.createElement("style");h.id=this.prefix+"style",h.innerHTML=a,document.querySelector("head").appendChild(h)}this.ref.querySelector("."+this.prefix+"imgContainer").append(this.actionExecutor.ref),document.body.appendChild(this.ref)},t.prototype.handleReausetAnimate=function(){window.requestAnimationFrame||(window.requestAnimationFrame=window.webkitRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60),0})},t.prototype.close=function(t){t.stopImmediatePropagation(),clearTimeout(this.performerClick),this[this.envClient+"BeforeClose"](),this.toggleClass(this.ref,this.defToggleClass)},t.prototype.pcBeforeClose=function(){document.body.style.overflow=document.body.dataset.imgPreOverflow},t.prototype.mobileBeforeClose=function(){},t.prototype.show=function(t){this.actionExecutor.curIndex=t,this.actionExecutor.draw(t),this.toggleClass(this.ref,this.defToggleClass)},t.prototype.mobileReadyShow=function(){},t.prototype.pcReadyShow=function(){var t=window.getComputedStyle(document.body);document.body.dataset.imgPreOverflow=t.overflow,document.body.style.overflow="hidden"},t.prototype.toggleClass=function(t,e){var i=t.className.split(" "),n=i.indexOf(e);-1!==n?i.splice(n,1):i.push(e),t.className=i.join(" ")},t.prototype.getMovePoints=function(t){var e=this;if(!(this.movePoints.length>this.maxMovePointCounts)){this.movePoints.push({x:t.touches[0].clientX,y:t.touches[0].clientY});this.addTouchEndTask("resetMovePoints",{priority:1,callback:function(){return e.movePoints=[]}})}},t.prototype.decideMoveDirection=function(){var t=this,e=this.movePoints.length,i=this.movePoints[e-1],n=this.movePoints[0],r=i.x-n.x,o=i.y-n.y,s=180*Math.atan2(o,r)/Math.PI;Math.abs(90-Math.abs(s))<30?this.fingerDirection="vertical":this.fingerDirection="horizontal";this.addTouchEndTask("resetFingerDirection",{priority:1,callback:function(){t.fingerDirection=""}})},t.prototype.destroy=function(){this.ref.parentNode.removeChild(this.ref),window.removeEventListener("resize",this.handleResize),window.removeEventListener("orientationchange",this.handleResize)},t.prototype.testEnv=function(){return/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)?"mobile":"pc"},t=I([o],t)}();T=D,[s,a,c].forEach((function(t){Object.getOwnPropertyNames(t.prototype).forEach((function(e){T.prototype[e]=t.prototype[e]}))})),t.ImagePreview=D,Object.defineProperty(t,"__esModule",{value:!0})})); diff --git a/release/image-preview/image-preview-amd.js b/release/image-preview/image-preview-amd.js index 8db732b..6242a45 100644 --- a/release/image-preview/image-preview-amd.js +++ b/release/image-preview/image-preview-amd.js @@ -764,6 +764,7 @@ define(['exports'], function (exports) { 'use strict'; var cubicBezier = (function () { function cubicBezier(x1, y1, x2, y2) { + this.cachedY = new Map(); this.precision = 1e-5; this.p1 = { x: x1, @@ -823,7 +824,10 @@ define(['exports'], function (exports) { 'use strict'; return t2; }; cubicBezier.prototype.solve = function (x) { - return this.getY(this.solveCurveX(x)); + if (!this.cachedY.get(x)) { + this.cachedY.set(x, this.getY(this.solveCurveX(x))); + } + return this.cachedY.get(x); }; return cubicBezier; }()); @@ -1341,7 +1345,8 @@ define(['exports'], function (exports) { 'use strict'; }; webGl.prototype.genPostion = function (width, height, index) { var _a; - var z = -(this.viewHeight) / (2 * Math.tan(this.fieldOfViewInRadians / 2)) - forDev; + var zNearHeight = (2 * Math.tan(this.fieldOfViewInRadians / 2)); + var z = -(this.viewHeight) / (zNearHeight) - forDev; var viewWidth = this.viewWidth; var sideZAxis = z - (viewWidth - width) / 2; var positionsMap = [ diff --git a/release/image-preview/image-preview-cjs-min.js b/release/image-preview/image-preview-cjs-min.js index ea615dc..b8e07e1 100644 --- a/release/image-preview/image-preview-cjs-min.js +++ b/release/image-preview/image-preview-cjs-min.js @@ -1 +1 @@ -"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=(t=function(e,i){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(e,i)},function(e,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}),i=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},n=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]0?(h=-(i-s)*u,a=-(e-o)*u,l=1+u,c=1+u):(h=(i-s)*u,a=(e-o)*u,l=1-u,c=1-u),r.eventsHanlder.handleZoom(l,c,a,h),this.isZooming=!1,this.isAnimating=!1,this.actionExecutor.isEnlargement?this.ref.style.cursor="grab":this.ref.style.cursor="initial",[2]}))}))},r.prototype.handlePCDoubleClick=function(t){return i(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return this.isAnimating?[2]:(this.isAnimating=!0,[4,this.actionExecutor.eventsHanlder.handleDoubleClick({clientX:t.clientX,clientY:t.clientY})]);case 1:return e.sent(),this.isAnimating=!1,this.actionExecutor.isEnlargement?this.ref.style.cursor="grab":this.ref.style.cursor="initial",[2]}}))}))},r.prototype.handleMouseDown=function(t){var e=this,i=t.target.dataset.type;this[i]?this[i](t):(this.mouseDown=!0,this.actionExecutor.isEnlargement?(this.startX=t.clientX,this.startY=t.clientY,this.ref.style.cursor="grabbing"):this.ref.style.cursor="initial",Date.now()-this.lastClick0?"right":"left",s=this.actionExecutor.viewRect,a=s.left,h=s.right,l=this.actionExecutor.viewWidth/this.actionExecutor.dpr;if(this.fingerDirection)if(this.actionExecutor.isEnlargement)if(a>=0&&h<=l)if("right"!=o&&"left"!=o&&!this.isEnlargeMove||"horizontal"!=this.fingerDirection)this.handleMoveEnlage(t);else{this.isEnlargeMove=!0,this.handleMoveNormal(t);var c="resetEnlargeMove";this.addTouchEndTask(c,{priority:1,callback:function(){e.isEnlargeMove=!1}})}else if(i&&"right"==o||n&&"left"==o||this.isEnlargeMove){this.isEnlargeMove=!0,this.handleMoveNormal(t);c="resetEnlargeMove";this.addTouchEndTask(c,{priority:1,callback:function(){return e.isEnlargeMove=!1}})}else this.handleMoveEnlage(t);else this.handleMoveNormal(t);else{if(this.actionExecutor.isEnlargement&&(a<0||h>l)||!this.actionExecutor.isEnlargement)return void(!this.actionExecutor.isEnlargement||r||this.normalMoved?this.actionExecutor.isEnlargement?(r||this.normalMoved)&&(this.normalMoved?this.handleMoveNormal(t):"right"==o?i?this.handleMoveNormal(t):this.handleMoveEnlage(t):"left"==o&&n?this.handleMoveNormal(t):this.handleMoveEnlage(t)):this.handleMoveNormal(t):this.handleMoveEnlage(t));if(this.getMovePoints(t),this.movePoints.lengthn?p:0,s=Math.round(c)<0||Math.round(u)>r?g:0,e.eventsHanlder.handleMoveEnlage(a,s,0);this.addTouchEndTask("handleTendEnlarte",{priority:10,callback:this.handleTEndEnlarge.bind(this)}),this.startX=d,this.startY=f}},t.prototype.autoMove=function(t,e,i,n){var r=n.maxTop,o=n.minTop,s=n.maxLeft,a=n.minLeft,h=this.imgContainer.getBoundingClientRect(),l=h.width,c=h.height,u=this.actionExecutor,d=u.viewRect,f=u.eventsHanlder,p=d,g=p.top,v=p.bottom,m=p.left,w=p.right;t=t/180*Math.PI;var x=e+300*Math.cos(t),y=i+300*Math.sin(t);x>s?x=s:xr?y=r:y=0&&w<=l||(M=x-e),g>=0&&v<=c||(b=y-i),f.moveCurPlaneTo(M,b,0)},t}(),s=function(){function t(){}return t.prototype.handleZoom=function(t){if(!(this.isNormalMove&&this.normalMoved||this.isAnimating||this.actionExecutor.isLoadingError())){this.isZooming||(this.curStartPoint1={x:this.curPoint1.x,y:this.curPoint1.y},this.curStartPoint2={x:this.curPoint2.x,y:this.curPoint2.y}),this.isZooming=!0,this.isAnimating=!0;var e=this.actionExecutor,i=Math.pow(this.curPoint1.x-this.curPoint2.x,2)+Math.pow(this.curPoint1.y-this.curPoint2.y,2),n=Math.pow(t.touches[0].clientX-t.touches[1].clientX,2)+Math.pow(t.touches[0].clientY-t.touches[1].clientY,2),r=(this.curStartPoint1.x+this.curStartPoint2.x)/2,o=(this.curStartPoint1.y+this.curStartPoint2.y)/2,s=e.viewWidth/(2*e.dpr),a=e.viewHeight/(2*e.dpr);this.curPoint1.x=t.touches[0].clientX,this.curPoint1.y=t.touches[0].clientY,this.curPoint2.x=t.touches[1].clientX,this.curPoint2.y=t.touches[1].clientY;var h=0,l=0,c=1,u=1;if(i>n)l=(o-a)*this.zoomScale,h=(r-s)*this.zoomScale,c=1-this.zoomScale,u=1-this.zoomScale;else{if(!(i0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]d;){if(i=this.getX(r)-t,Math.abs(i)0?u=r:d=r,r=(u+d)/2}return r},t.prototype.solve=function(t){return this.getY(this.solveCurveX(t))},t}(),f=new d(0,0,1,1);new d(.25,.1,.25,1),new d(.42,0,1,1),new d(0,0,.58,1),new d(.42,0,.58,1);var p=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},g=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]4*s||(l*t=this.throldDeg?(o=t.curIndex,-1!=(s=t.curIndex+1*r)&&s!=t.imgUrls.length?[3,2]:(t.curIndex=o,[4,t.rotate(-n)])):[3,6];case 1:return a.sent(),[3,5];case 2:return[4,t.rotate(r*Math.PI/2-n)];case 3:return a.sent(),t.curIndex=s,t.modelMatrix=t.baseModel=t.initialModel,t.gl.uniformMatrix4fv(t.gl.getUniformLocation(t.shaderProgram,"uModelViewMatrix"),!1,t.modelMatrix),[4,t.draw(s)];case 4:a.sent(),a.label=5;case 5:return[3,8];case 6:return[4,t.rotate(-n)];case 7:a.sent(),a.label=8;case 8:return t.modelMatrix=t.baseModel=t.initialModel,[2,"handled"]}}))}))},t.prototype.handleTEndEnlarge=function(t,e,i,n){return p(this,void 0,void 0,(function(){var t;return g(this,(function(n){switch(n.label){case 0:return t=this.viewInstance,e*=t.dpr,i*=-t.dpr,t.dpr,this.curBehaviorCanBreak=!0,[4,t.moveCurPlane(e,i,0)];case 1:return n.sent(),this.curBehaviorCanBreak=!1,0!==e&&(t.isBoudriedSide=!0),[2]}}))}))},t.prototype.moveCurPlaneTo=function(t,e,i){return p(this,void 0,void 0,(function(){var i;return g(this,(function(n){switch(n.label){case 0:return i=this.viewInstance,t*=i.dpr,e*=-i.dpr,i.dpr,this.curBehaviorCanBreak=!0,[4,i.moveCurPlane(t,e,0)];case 1:return n.sent(),this.curBehaviorCanBreak=!1,[2]}}))}))},t}();var m=function(t,e,i){var n=t.naturalWidth,r=t.naturalHeight,o=document.createElement("canvas"),s=o.getContext("2d"),a=window.devicePixelRatio||1;return o.width=e*a,o.height=i*a,s.drawImage(t,0,0,n,r,0,0,e*a,i*a),o},w=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},x=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]n&&(e=n-1,r=n),this.imgUrls.splice(e+1,0,t),e+1>this.imgs.length?this.imgs[r]=null:this.imgs.splice(e+1,0,null),t instanceof Image)if(void 0===t._id&&(t._id=this.imgId++),t.complete)this.imgUrls[e+1]=this.validateImg(t);else{var o=function(){var e=i.imgUrls.indexOf(t);t.loadError=!0,~[-2,-1,0].indexOf(e-i.curIndex)&&i.draw(i.curIndex)};t.addEventListener("load",(function(){var e=i.imgUrls.indexOf(t);i.imgUrls[e]=i.validateImg(t),~[-2,-1,0].indexOf(e-i.curIndex)&&i.draw(i.curIndex)})),t.addEventListener("error",o),t.addEventListener("abort",o)}~[-2,-1,0].indexOf(e-this.curIndex)&&this.draw(this.curIndex)},t.prototype.delImg=function(t){var e=this.imgUrls.length;t<=-1?t=0:t>=e&&(t=e-1),this.imgUrls.splice(t,1),this.imgs[t]&&this.textures.delete(this.imgs[t]._id),this.imgs.splice(t,1),t-=this.curIndex,~[-1,0,1].indexOf(t)&&this.draw(this.curIndex)},t.prototype.initOtherTexture=function(){var t=this,e=this.gl,i=e.createTexture();this.texturesOther.set(0,i),e.bindTexture(e.TEXTURE_2D,i),i.cubicBgd=!0;e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,new Uint8Array([0,0,0,255]));var n=new Image;n.onload=function(){var i=e.createTexture();t.texturesOther.set(1,i),e.bindTexture(e.TEXTURE_2D,i),t.texImage(n),t.setTexParameteri(n.width,n.height)},n.src="data:image/svg+xml;base64,PHN2ZyB0PSIxNjI1ODExNDgwNTgyIiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEzNDIgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjYwNjkiIHdpZHRoPSIyMDAiIGhlaWdodD0iMjAwIj48cGF0aCBkPSJNMTIxNi4zNTcgMTM5LjAzYy0xMC4xNTctMTEuNDI3LTI0Ljc1OS0xNy43NzUtMzkuOTk1LTE4LjQxTDc0My40IDEwMy40OGwtMzIuMzc3IDczLjAwNiA0NS4wNzQgMTM1Ljg1Ni04MS4yNiAxNTQuMjY3IDMzLjAxMiAxMjQuNDI5IDgyLjUzIDEwNi42NTMgMTE5LjM1LTEwOS44MjdjMTEuNDI3LTEwLjc5MyAyOS44MzctMTAuMTU4IDM5Ljk5NCAxLjkwNGwxNTIuOTk3IDE2NS42OTRjMTAuNzkzIDExLjQyNyAxMC4xNTggMjkuODM3LTEuMjcgNDAuNjMtNS43MTMgNS4wNzgtMTIuNjk2IDguMjUzLTIwLjMxNCA3LjYxOGwtNDE5LjYzLTE2LjUwNi0yMC45NSA2MC4zMSAyMi44NTQgNTMuOTYyIDQ4Mi40OCAxOC40MWMzMS43NDIgMS4yNyA1OC40MDUtMjMuNDkgNTkuMDQtNTUuMjMxbDI2LjY2My02ODQuMzZjMC42MzUtMTUuMjM2LTQuNDQ0LTMwLjQ3Mi0xNS4yMzYtNDEuMjY1ek05MDYuNTU0IDQ1My4yNzdjLTQ3LjYxMy0xLjkwNC04NC40MzQtNDEuOS04Mi41My04OC44NzggMS45MDUtNDcuNjEzIDQxLjktODQuNDM0IDg4Ljg3OS04Mi41MyA0Ni45NzggMS45MDUgODQuNDM0IDQxLjkgODIuNTMgODguODc5LTEuOTA1IDQ2Ljk3OC00MS45IDg0LjQzNC04OC44NzkgODIuNTN6TTU5NS40ODIgODQ4LjE1bDE0LjYwMS02My40ODQtMzQwLjkxIDIzLjQ4OWMtMTUuODcxIDEuMjctMjkuMjAzLTEwLjE1OC0zMC40NzItMjYuMDI5YTI4LjEyIDI4LjEyIDAgMCAxIDYuOTgzLTIwLjk1TDQ5OC4zNSA0NzEuMDUzYzUuMDc5LTYuMzQ5IDEyLjY5Ny05LjUyMyAyMC45NS05LjUyMyA3LjYxOCAwIDE1LjIzNiAzLjE3NCAyMC45NSA4Ljg4OGw4NC40MzMgODguMjQzLTM2LjE4Ni05My45NTcgNjQuNzU0LTE2Mi41Mi01OS4wNC0xMzAuMTQyIDI0LjEyNC03NC45MTEtNDY0LjcwNCAzMi4zNzdjLTMxLjc0MiAxLjkwNC01NS4yMzIgMjkuMjAyLTUzLjMyNyA2MC45NDVsNDYuOTc4IDY4NC4zNmMwLjYzNSAxNS4yMzUgNy42MTggMjkuMjAyIDE5LjY4IDM4LjcyNSAxMS40MjggMTAuMTU3IDI2LjAyOSAxNS4yMzYgNDEuMjY1IDEzLjk2Nmw0MTUuMTg3LTI4LjU2OC0yNy45MzMtNTAuNzg3eiIgcC1pZD0iNjA3MCIgZmlsbD0iI2JmYmZiZiIvPjwvc3ZnPg=="},t.prototype.initData=function(){this.draw(this.curIndex)},t.prototype.slideNext=function(){return w(this,void 0,void 0,(function(){var t=this;return x(this,(function(e){return this.curIndex==this.imgUrls.length-1?[2,[!0]]:[2,this.slide(.5*Math.PI,(function(){return t.curIndex++}))]}))}))},t.prototype.slideBefore=function(){return w(this,void 0,void 0,(function(){var t=this;return x(this,(function(e){return 0==this.curIndex?[2,[!0]]:[2,this.slide(-.5*Math.PI,(function(){return t.curIndex--}))]}))}))},t.prototype.slide=function(t,e){return w(this,void 0,void 0,(function(){return x(this,(function(i){switch(i.label){case 0:return this.baseModel=this.modelMatrix,[4,this.rotate(t)];case 1:return i.sent(),e(),this.modelMatrix=this.baseModel=this.initialModel,this.gl.uniformMatrix4fv(this.gl.getUniformLocation(this.shaderProgram,"uModelViewMatrix"),!1,this.modelMatrix),[4,this.draw(this.curIndex)];case 2:return i.sent(),this.modelMatrix=this.baseModel=this.initialModel,[2,[!1]]}}))}))},t.prototype.rotate=function(t){var e,i=this;return this.animate({allTime:this.defaultAnimateTime,timingFun:f,ends:[t],playGame:(e=i.rotatePosition.bind(i),function(t){i.clear(),e(t)})})},t.prototype.rotateZ=function(t){var e=this;this.curPlane=this.positions.slice(this.curPointAt,this.curPointAt+16);var i=this.imgShape,n=this.imgShapeInitinal;this.imgShape=u.multiplyPoint(i,u.rotateZMatrix(t)),this.imgShapeInitinal=u.multiplyPoint(n,u.rotateZMatrix(t));var r=this.curCenterCoordinate,o=-r[0],s=-r[1];return this.animate({allTime:this.defaultAnimateTime,timingFun:f,ends:[t,o,s],playGame:function(){for(var t=[],i=0;ic?c:this.viewWidth):(i=c,n=u),p=-(t-r)*(d=i/a-1),g=(e-o)*(f=n/h-1),this.curIsLongImg()&&(p=0);return[d,f,p,g]},t.prototype.decideImgViewSize=function(t,e){var i=0,n=0;return(n=e/t*(i=this.viewWidth>=t?t:this.viewWidth))>this.viewHeight&&(i=(n=this.viewHeight)*t/e),[i,n]},t.prototype.draw=function(t){this.positions=[];for(var e=this.imgUrls.length,i=0,n=0,r=t-1;r<=t+1;r++)if(-1!==r&&r<=e-1){var o=void 0;this.imgs[r]?o=this.imgs[r]:"string"==typeof this.imgUrls[r]?o=this.loadImage(this.imgUrls[r],r):void 0===(o=this.imgUrls[r])._id&&(this.imgUrls[r]=this.validateImg(o),o=this.imgUrls[r]),this.imgs[r]=o;var s=o.naturalWidth,a=o.naturalHeight;o.loadError&&(s=a=200);var h=this.decideImgViewSize(s*this.dpr,a*this.dpr),l=h[0],c=h[1];r==this.curIndex&&(this.imgShape=[s*this.dpr,a*this.dpr,0,1],this.imgShapeInitinal=[l,c,0,1]),this.genPostion(l,c,r),i=Math.max(l,i),n=Math.max(c,n)}this.generateCube(i,n),this.bindPostion(),this.drawPosition()},t.prototype.createPerspectiveMatrix=function(){var t=this.fieldOfViewInRadians,e=this.viewWidth/this.viewHeight,i=this.zNear,n=this.zFar,r=1/Math.tan(t/2),o=1/(i-n);return[r/e,0,0,0,0,r,0,0,0,0,(i+n)*o,-1,0,0,i*n*o*2,0]},Object.defineProperty(t.prototype,"curPointAt",{get:function(){var t=64;return 0==this.curIndex&&(t=48),t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"IsBoundaryLeft",{get:function(){var t=this.viewRect;return Math.round(t.left)>=0&&this.isBoudriedSide},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isBoundaryRight",{get:function(){var t=this.viewRect;return Math.round(t.right*this.dpr)<=Math.round(this.viewWidth/1)&&this.isBoudriedSide},enumerable:!1,configurable:!0}),t.prototype.curIsLongImg=function(){var t=this.imgShape,e=t[0],i=t[1];return 2*Math.abs(e)<=Math.abs(i)},Object.defineProperty(t.prototype,"curCenterCoordinate",{get:function(){var t=this.curPointAt;return[(this.positions[t]+this.positions[t+8])/2,(this.positions[t+1]+this.positions[t+9])/2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"viewRect",{get:function(){for(var t=-this.viewWidth/2,e=this.viewHeight/2,i=this.curPointAt,n=1/0,r=-1/0,o=1/0,s=-1/0,a=i;athis.viewWidth||e.height*this.dpr-1>this.viewHeight},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isEnlargementForScale",{get:function(){var t=this.imgShapeInitinal,e=t[0],i=t[1],n=this.viewRect;return Math.round(n.width*this.dpr)>Math.round(Math.abs(e))||Math.round(n.height*this.dpr)>Math.round(Math.abs(i))},enumerable:!1,configurable:!0}),t.prototype.isLoadingError=function(t){return 0==arguments.length&&(t=this.curIndex),this.imgs[t].loadError},t.prototype.loadImage=function(t,e){var i=this,n=new Image;return n._id=this.imgId++,this.imgs[e]=n,n.onload=function(){i.handleImgLoaded(n,e)},n.onerror=function(){n.loadError=!0,i.handleImgLoaded(n,e)},n.onabort=function(){n.loadError=!0,i.handleImgLoaded(n,e)},n.crossOrigin="anonymous",n.src=t,n},t.prototype.handleImgLoaded=function(t,e){e=this.imgs.indexOf(t),t.loadError||(t=this.validateImg(t),this.imgs[e]=t),~[-1,0,1].indexOf(e-this.curIndex)&&(this.updatePosition(t,e-this.curIndex),this.bindPostion(),this.drawPosition())},t.prototype.validateImg=function(t){var e=this.gl.MAX_TEXTURE_SIZE,i=t.naturalWidth,n=t.naturalHeight;if(Math.max(n,i)>=e){var r=this.dpr,o=e/r,s=n/i*o;s>=e&&(o=i/n*(s=e/r));var a=m(t,o,s);return a._id=this.imgId++,a.naturalHeight=s,a.naturalWidth=o,a.complete=!0,a}return t},t.prototype.clear=function(){var t=this.gl;t.clearColor(0,0,0,1),t.clearDepth(1),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT)},t.prototype.bindShader=function(t,e,i){var n=this.loadShader(t,t.VERTEX_SHADER,i),r=this.loadShader(t,t.FRAGMENT_SHADER,e),o=t.createProgram();return t.attachShader(o,n),t.attachShader(o,r),t.linkProgram(o),t.getProgramParameter(o,t.LINK_STATUS)?o:(console.error("Unable to initialize the shader program: "+t.getProgramInfoLog(o)),null)},t.prototype.loadShader=function(t,e,i){var n=t.createShader(e);return t.shaderSource(n,i),t.compileShader(n),t.getShaderParameter(n,t.COMPILE_STATUS)?n:(console.error("An error occurred compiling the shaders: "+t.getShaderInfoLog(n)),t.deleteShader(n),null)},t.prototype.createPlane=function(t){return t.x,t.y,t.width,t.height,{}},t.prototype.intialView=function(){var t=document.createElement("canvas");t.style.cssText="\n position: absolute;\n top: 0;\n left:0;\n z-index: 9;\n width:"+window.innerWidth+"px;\n height:"+window.innerHeight+"px;\n user-select:none;\n font-size:0;\n ",t.width=window.innerWidth*this.dpr,t.height=window.innerHeight*this.dpr,this.ref=t;var e=t.getContext("webgl",{antialias:!0});return e||console.error("webgl is not supported. please use before version."),this.viewWidth=t.width,this.viewHeight=t.height,e},t.prototype.animate=function(t){var e,i=this,n=t.allTime,r=t.timingFun,o=t.ends,s=t.playGame,a=t.callback,h=Date.now(),l=h,c=new Promise((function(t){return e=t})),u=o.length,d=function(){if(i.curAimateBreaked)return e([!1,3]),void(i.curAimateBreaked=!1);var t=l-h;t>n&&(t=n);var c=t/n;c>1&&(c=1);var f=r.solve(c);f>=1&&(f=1);var p=new Array(u);o.forEach((function(t,e){p[e]=t*f})),s.apply(void 0,p),c<1?requestAnimationFrame(d):(a&&a(),e([!1,1])),l=Date.now()};return d(),c},t}(),P=function(t,e,i,n){var r,o=arguments.length,s=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(s=(o<3?r(s):o>3?r(e,i,s):r(e,i))||s);return o>3&&s&&Object.defineProperty(e,i,s),s},I=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},A=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]d?(w=d-g,m=!0):gc?(x=c-p,v=!0):p=0&&l<=n&&(m=!1,w=0),s<=r&&(v=!1,x=0),m||v?(this.isAnimating=!0,[4,e.eventsHanlder.handleTEndEnlarge(t,w,x,0)]):[3,2];case 1:return I.sent(),this.isAnimating=!1,[3,4];case 2:return this.moveEndTime=Date.now(),y={x:this.startX,y:this.startY},M={x:this.touchStartX,y:this.touchStartY},b=y.x-M.x,E=y.y-M.y,T=180*Math.atan2(E,b)/Math.PI,this.moveEndTime-this.moveStartTime<90&&Math.abs(b)+Math.abs(E)>5?(P={maxTop:c,minTop:u,maxLeft:d,minLeft:n-o},this.isAnimating=!0,[4,this.autoMove(T,h,a,P)]):[3,4];case 3:I.sent(),this.isAnimating=!1,I.label=4;case 4:return this.moveStartTime=0,[2]}}))}))},t.prototype.handleTEndEnNormal=function(t){return I(this,void 0,void 0,(function(){var e,i,n;return A(this,(function(r){switch(r.label){case 0:return this.isAnimating?[2]:(e=t.changedTouches[0].clientX,i=this.actionExecutor.eventsHanlder,0===(n=e-this.touchStartX)?[2]:(this.isAnimating=!0,[4,i.handleTEndEnNormal(t,n)]));case 1:return r.sent(),this.isAnimating=!1,[2]}}))}))},t.prototype.genFrame=function(){var t=this,e=this.options.imgs;!e||e.length,this.imgsNumber=e.length,this.curIndex=0;var i='\n
\n \n \n \n \n
\n
\n
\n '+("pc"==this.envClient?'
\n \n
\n
\n \n
':"")+'\n
\n \n
\n
\n \n
\n
\n ',n=/iphone/gi.test(window.navigator.userAgent)&&window.devicePixelRatio&&3===window.devicePixelRatio&&375===window.screen.width&&812===window.screen.height,r=/iphone/gi.test(window.navigator.userAgent)&&window.devicePixelRatio&&3===window.devicePixelRatio&&414===window.screen.width&&896===window.screen.height,o=/iphone/gi.test(window.navigator.userAgent)&&window.devicePixelRatio&&2===window.devicePixelRatio&&414===window.screen.width&&896===window.screen.height,s=n||r||o,a="\n ."+this.prefix+"imagePreviewer{\n position: fixed;\n top:0;\n left: 100%;\n width: 100%;\n height: 100%;\n background: "+function(e){switch(e){case"conBackground":return"pc"==t.envClient?"rgba(0,0,0,0.8)":"rgba(0,0,0,1)";case"imgWidth":return t.envClient,"100%";case"itemHeight":return"pc"==t.envClient?"100%":"auto";case"itemScroll":return"pc"==t.envClient?"auto ":"hidden";case"item-text-align":return"pc"==t.envClient?"center ":"initial";default:return""}}("conBackground")+";\n color:#fff;\n transform: translate3d(0,0,0);\n transition: left 0.5s;\n overflow:hidden;\n user-select: none;\n }\n \n ."+this.prefix+"imagePreviewer."+this.defToggleClass+"{\n left: 0%;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"close{\n position: absolute;\n top: 20px;\n right: 20px;\n z-index: 10;\n box-sizing: border-box;\n width: 22px;\n height: 22px;\n cursor:pointer;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"close svg{\n width: 100%;\n height: 100%; \n }\n ."+this.prefix+"imagePreviewer svg{\n overflow:visible;\n }\n ."+this.prefix+"imagePreviewer svg path{\n stroke: #948888;\n stroke-width: 30px;\n }\n \n ."+this.prefix+"imagePreviewer "+this.prefix+".close."+this.prefix+"scroll{\n height: 0;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"imgContainer{\n position: relative;\n height: 100%;\n font-size: 0;\n white-space: nowrap;\n }\n \n ."+this.prefix+"imagePreviewer ."+this.prefix+"bottom{\n position: absolute;\n bottom: "+(s?20:0)+"px;\n left: 20px;\n right: 20px;\n z-index: 10;\n padding: 0 10px;\n text-align: center;\n border-top: 1px solid rgba(255, 255, 255, .2);\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"bottom ."+this.prefix+"item{\n display:inline-block;\n width: 42px;\n height: 42px;\n cursor:pointer;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"bottom ."+this.prefix+"item svg{\n box-sizing: border-box;\n width: 100%;\n height: 100%;\n padding:10px;\n }\n ";if(this.ref=document.createElement("div"),this.ref.className=this.prefix+"imagePreviewer",this.ref.innerHTML=i,!document.querySelector("#"+this.prefix+"style")){var h=document.createElement("style");h.id=this.prefix+"style",h.innerHTML=a,document.querySelector("head").appendChild(h)}this.ref.querySelector("."+this.prefix+"imgContainer").append(this.actionExecutor.ref),document.body.appendChild(this.ref)},t.prototype.handleReausetAnimate=function(){window.requestAnimationFrame||(window.requestAnimationFrame=window.webkitRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60),0})},t.prototype.close=function(t){t.stopImmediatePropagation(),clearTimeout(this.performerClick),this[this.envClient+"BeforeClose"](),this.toggleClass(this.ref,this.defToggleClass)},t.prototype.pcBeforeClose=function(){document.body.style.overflow=document.body.dataset.imgPreOverflow},t.prototype.mobileBeforeClose=function(){},t.prototype.show=function(t){this.actionExecutor.curIndex=t,this.actionExecutor.draw(t),this.toggleClass(this.ref,this.defToggleClass)},t.prototype.mobileReadyShow=function(){},t.prototype.pcReadyShow=function(){var t=window.getComputedStyle(document.body);document.body.dataset.imgPreOverflow=t.overflow,document.body.style.overflow="hidden"},t.prototype.toggleClass=function(t,e){var i=t.className.split(" "),n=i.indexOf(e);-1!==n?i.splice(n,1):i.push(e),t.className=i.join(" ")},t.prototype.getMovePoints=function(t){var e=this;if(!(this.movePoints.length>this.maxMovePointCounts)){this.movePoints.push({x:t.touches[0].clientX,y:t.touches[0].clientY});this.addTouchEndTask("resetMovePoints",{priority:1,callback:function(){return e.movePoints=[]}})}},t.prototype.decideMoveDirection=function(){var t=this,e=this.movePoints.length,i=this.movePoints[e-1],n=this.movePoints[0],r=i.x-n.x,o=i.y-n.y,s=180*Math.atan2(o,r)/Math.PI;Math.abs(90-Math.abs(s))<30?this.fingerDirection="vertical":this.fingerDirection="horizontal";this.addTouchEndTask("resetFingerDirection",{priority:1,callback:function(){t.fingerDirection=""}})},t.prototype.destroy=function(){this.ref.parentNode.removeChild(this.ref),window.removeEventListener("resize",this.handleResize),window.removeEventListener("orientationchange",this.handleResize)},t.prototype.testEnv=function(){return/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)?"mobile":"pc"},t=P([r],t)}();E=S,[o,s,l].forEach((function(t){Object.getOwnPropertyNames(t.prototype).forEach((function(e){E.prototype[e]=t.prototype[e]}))})),exports.ImagePreview=S; +"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=(t=function(e,i){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(e,i)},function(e,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}),i=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},n=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]0?(h=-(i-s)*u,a=-(e-o)*u,l=1+u,c=1+u):(h=(i-s)*u,a=(e-o)*u,l=1-u,c=1-u),r.eventsHanlder.handleZoom(l,c,a,h),this.isZooming=!1,this.isAnimating=!1,this.actionExecutor.isEnlargement?this.ref.style.cursor="grab":this.ref.style.cursor="initial",[2]}))}))},r.prototype.handlePCDoubleClick=function(t){return i(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return this.isAnimating?[2]:(this.isAnimating=!0,[4,this.actionExecutor.eventsHanlder.handleDoubleClick({clientX:t.clientX,clientY:t.clientY})]);case 1:return e.sent(),this.isAnimating=!1,this.actionExecutor.isEnlargement?this.ref.style.cursor="grab":this.ref.style.cursor="initial",[2]}}))}))},r.prototype.handleMouseDown=function(t){var e=this,i=t.target.dataset.type;this[i]?this[i](t):(this.mouseDown=!0,this.actionExecutor.isEnlargement?(this.startX=t.clientX,this.startY=t.clientY,this.ref.style.cursor="grabbing"):this.ref.style.cursor="initial",Date.now()-this.lastClick0?"right":"left",s=this.actionExecutor.viewRect,a=s.left,h=s.right,l=this.actionExecutor.viewWidth/this.actionExecutor.dpr;if(this.fingerDirection)if(this.actionExecutor.isEnlargement)if(a>=0&&h<=l)if("right"!=o&&"left"!=o&&!this.isEnlargeMove||"horizontal"!=this.fingerDirection)this.handleMoveEnlage(t);else{this.isEnlargeMove=!0,this.handleMoveNormal(t);var c="resetEnlargeMove";this.addTouchEndTask(c,{priority:1,callback:function(){e.isEnlargeMove=!1}})}else if(i&&"right"==o||n&&"left"==o||this.isEnlargeMove){this.isEnlargeMove=!0,this.handleMoveNormal(t);c="resetEnlargeMove";this.addTouchEndTask(c,{priority:1,callback:function(){return e.isEnlargeMove=!1}})}else this.handleMoveEnlage(t);else this.handleMoveNormal(t);else{if(this.actionExecutor.isEnlargement&&(a<0||h>l)||!this.actionExecutor.isEnlargement)return void(!this.actionExecutor.isEnlargement||r||this.normalMoved?this.actionExecutor.isEnlargement?(r||this.normalMoved)&&(this.normalMoved?this.handleMoveNormal(t):"right"==o?i?this.handleMoveNormal(t):this.handleMoveEnlage(t):"left"==o&&n?this.handleMoveNormal(t):this.handleMoveEnlage(t)):this.handleMoveNormal(t):this.handleMoveEnlage(t));if(this.getMovePoints(t),this.movePoints.lengthn?p:0,s=Math.round(c)<0||Math.round(u)>r?g:0,e.eventsHanlder.handleMoveEnlage(a,s,0);this.addTouchEndTask("handleTendEnlarte",{priority:10,callback:this.handleTEndEnlarge.bind(this)}),this.startX=d,this.startY=f}},t.prototype.autoMove=function(t,e,i,n){var r=n.maxTop,o=n.minTop,s=n.maxLeft,a=n.minLeft,h=this.imgContainer.getBoundingClientRect(),l=h.width,c=h.height,u=this.actionExecutor,d=u.viewRect,f=u.eventsHanlder,p=d,g=p.top,v=p.bottom,m=p.left,w=p.right;t=t/180*Math.PI;var x=e+300*Math.cos(t),y=i+300*Math.sin(t);x>s?x=s:xr?y=r:y=0&&w<=l||(M=x-e),g>=0&&v<=c||(b=y-i),f.moveCurPlaneTo(M,b,0)},t}(),s=function(){function t(){}return t.prototype.handleZoom=function(t){if(!(this.isNormalMove&&this.normalMoved||this.isAnimating||this.actionExecutor.isLoadingError())){this.isZooming||(this.curStartPoint1={x:this.curPoint1.x,y:this.curPoint1.y},this.curStartPoint2={x:this.curPoint2.x,y:this.curPoint2.y}),this.isZooming=!0,this.isAnimating=!0;var e=this.actionExecutor,i=Math.pow(this.curPoint1.x-this.curPoint2.x,2)+Math.pow(this.curPoint1.y-this.curPoint2.y,2),n=Math.pow(t.touches[0].clientX-t.touches[1].clientX,2)+Math.pow(t.touches[0].clientY-t.touches[1].clientY,2),r=(this.curStartPoint1.x+this.curStartPoint2.x)/2,o=(this.curStartPoint1.y+this.curStartPoint2.y)/2,s=e.viewWidth/(2*e.dpr),a=e.viewHeight/(2*e.dpr);this.curPoint1.x=t.touches[0].clientX,this.curPoint1.y=t.touches[0].clientY,this.curPoint2.x=t.touches[1].clientX,this.curPoint2.y=t.touches[1].clientY;var h=0,l=0,c=1,u=1;if(i>n)l=(o-a)*this.zoomScale,h=(r-s)*this.zoomScale,c=1-this.zoomScale,u=1-this.zoomScale;else{if(!(i0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]d;){if(i=this.getX(r)-t,Math.abs(i)0?u=r:d=r,r=(u+d)/2}return r},t.prototype.solve=function(t){return this.cachedY.get(t)||this.cachedY.set(t,this.getY(this.solveCurveX(t))),this.cachedY.get(t)},t}(),f=new d(0,0,1,1);new d(.25,.1,.25,1),new d(.42,0,1,1),new d(0,0,.58,1),new d(.42,0,.58,1);var p=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},g=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]4*s||(l*t=this.throldDeg?(o=t.curIndex,-1!=(s=t.curIndex+1*r)&&s!=t.imgUrls.length?[3,2]:(t.curIndex=o,[4,t.rotate(-n)])):[3,6];case 1:return a.sent(),[3,5];case 2:return[4,t.rotate(r*Math.PI/2-n)];case 3:return a.sent(),t.curIndex=s,t.modelMatrix=t.baseModel=t.initialModel,t.gl.uniformMatrix4fv(t.gl.getUniformLocation(t.shaderProgram,"uModelViewMatrix"),!1,t.modelMatrix),[4,t.draw(s)];case 4:a.sent(),a.label=5;case 5:return[3,8];case 6:return[4,t.rotate(-n)];case 7:a.sent(),a.label=8;case 8:return t.modelMatrix=t.baseModel=t.initialModel,[2,"handled"]}}))}))},t.prototype.handleTEndEnlarge=function(t,e,i,n){return p(this,void 0,void 0,(function(){var t;return g(this,(function(n){switch(n.label){case 0:return t=this.viewInstance,e*=t.dpr,i*=-t.dpr,t.dpr,this.curBehaviorCanBreak=!0,[4,t.moveCurPlane(e,i,0)];case 1:return n.sent(),this.curBehaviorCanBreak=!1,0!==e&&(t.isBoudriedSide=!0),[2]}}))}))},t.prototype.moveCurPlaneTo=function(t,e,i){return p(this,void 0,void 0,(function(){var i;return g(this,(function(n){switch(n.label){case 0:return i=this.viewInstance,t*=i.dpr,e*=-i.dpr,i.dpr,this.curBehaviorCanBreak=!0,[4,i.moveCurPlane(t,e,0)];case 1:return n.sent(),this.curBehaviorCanBreak=!1,[2]}}))}))},t}();var m=function(t,e,i){var n=t.naturalWidth,r=t.naturalHeight,o=document.createElement("canvas"),s=o.getContext("2d"),a=window.devicePixelRatio||1;return o.width=e*a,o.height=i*a,s.drawImage(t,0,0,n,r,0,0,e*a,i*a),o},w=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},x=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]n&&(e=n-1,r=n),this.imgUrls.splice(e+1,0,t),e+1>this.imgs.length?this.imgs[r]=null:this.imgs.splice(e+1,0,null),t instanceof Image)if(void 0===t._id&&(t._id=this.imgId++),t.complete)this.imgUrls[e+1]=this.validateImg(t);else{var o=function(){var e=i.imgUrls.indexOf(t);t.loadError=!0,~[-2,-1,0].indexOf(e-i.curIndex)&&i.draw(i.curIndex)};t.addEventListener("load",(function(){var e=i.imgUrls.indexOf(t);i.imgUrls[e]=i.validateImg(t),~[-2,-1,0].indexOf(e-i.curIndex)&&i.draw(i.curIndex)})),t.addEventListener("error",o),t.addEventListener("abort",o)}~[-2,-1,0].indexOf(e-this.curIndex)&&this.draw(this.curIndex)},t.prototype.delImg=function(t){var e=this.imgUrls.length;t<=-1?t=0:t>=e&&(t=e-1),this.imgUrls.splice(t,1),this.imgs[t]&&this.textures.delete(this.imgs[t]._id),this.imgs.splice(t,1),t-=this.curIndex,~[-1,0,1].indexOf(t)&&this.draw(this.curIndex)},t.prototype.initOtherTexture=function(){var t=this,e=this.gl,i=e.createTexture();this.texturesOther.set(0,i),e.bindTexture(e.TEXTURE_2D,i),i.cubicBgd=!0;e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,new Uint8Array([0,0,0,255]));var n=new Image;n.onload=function(){var i=e.createTexture();t.texturesOther.set(1,i),e.bindTexture(e.TEXTURE_2D,i),t.texImage(n),t.setTexParameteri(n.width,n.height)},n.src="data:image/svg+xml;base64,PHN2ZyB0PSIxNjI1ODExNDgwNTgyIiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEzNDIgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjYwNjkiIHdpZHRoPSIyMDAiIGhlaWdodD0iMjAwIj48cGF0aCBkPSJNMTIxNi4zNTcgMTM5LjAzYy0xMC4xNTctMTEuNDI3LTI0Ljc1OS0xNy43NzUtMzkuOTk1LTE4LjQxTDc0My40IDEwMy40OGwtMzIuMzc3IDczLjAwNiA0NS4wNzQgMTM1Ljg1Ni04MS4yNiAxNTQuMjY3IDMzLjAxMiAxMjQuNDI5IDgyLjUzIDEwNi42NTMgMTE5LjM1LTEwOS44MjdjMTEuNDI3LTEwLjc5MyAyOS44MzctMTAuMTU4IDM5Ljk5NCAxLjkwNGwxNTIuOTk3IDE2NS42OTRjMTAuNzkzIDExLjQyNyAxMC4xNTggMjkuODM3LTEuMjcgNDAuNjMtNS43MTMgNS4wNzgtMTIuNjk2IDguMjUzLTIwLjMxNCA3LjYxOGwtNDE5LjYzLTE2LjUwNi0yMC45NSA2MC4zMSAyMi44NTQgNTMuOTYyIDQ4Mi40OCAxOC40MWMzMS43NDIgMS4yNyA1OC40MDUtMjMuNDkgNTkuMDQtNTUuMjMxbDI2LjY2My02ODQuMzZjMC42MzUtMTUuMjM2LTQuNDQ0LTMwLjQ3Mi0xNS4yMzYtNDEuMjY1ek05MDYuNTU0IDQ1My4yNzdjLTQ3LjYxMy0xLjkwNC04NC40MzQtNDEuOS04Mi41My04OC44NzggMS45MDUtNDcuNjEzIDQxLjktODQuNDM0IDg4Ljg3OS04Mi41MyA0Ni45NzggMS45MDUgODQuNDM0IDQxLjkgODIuNTMgODguODc5LTEuOTA1IDQ2Ljk3OC00MS45IDg0LjQzNC04OC44NzkgODIuNTN6TTU5NS40ODIgODQ4LjE1bDE0LjYwMS02My40ODQtMzQwLjkxIDIzLjQ4OWMtMTUuODcxIDEuMjctMjkuMjAzLTEwLjE1OC0zMC40NzItMjYuMDI5YTI4LjEyIDI4LjEyIDAgMCAxIDYuOTgzLTIwLjk1TDQ5OC4zNSA0NzEuMDUzYzUuMDc5LTYuMzQ5IDEyLjY5Ny05LjUyMyAyMC45NS05LjUyMyA3LjYxOCAwIDE1LjIzNiAzLjE3NCAyMC45NSA4Ljg4OGw4NC40MzMgODguMjQzLTM2LjE4Ni05My45NTcgNjQuNzU0LTE2Mi41Mi01OS4wNC0xMzAuMTQyIDI0LjEyNC03NC45MTEtNDY0LjcwNCAzMi4zNzdjLTMxLjc0MiAxLjkwNC01NS4yMzIgMjkuMjAyLTUzLjMyNyA2MC45NDVsNDYuOTc4IDY4NC4zNmMwLjYzNSAxNS4yMzUgNy42MTggMjkuMjAyIDE5LjY4IDM4LjcyNSAxMS40MjggMTAuMTU3IDI2LjAyOSAxNS4yMzYgNDEuMjY1IDEzLjk2Nmw0MTUuMTg3LTI4LjU2OC0yNy45MzMtNTAuNzg3eiIgcC1pZD0iNjA3MCIgZmlsbD0iI2JmYmZiZiIvPjwvc3ZnPg=="},t.prototype.initData=function(){this.draw(this.curIndex)},t.prototype.slideNext=function(){return w(this,void 0,void 0,(function(){var t=this;return x(this,(function(e){return this.curIndex==this.imgUrls.length-1?[2,[!0]]:[2,this.slide(.5*Math.PI,(function(){return t.curIndex++}))]}))}))},t.prototype.slideBefore=function(){return w(this,void 0,void 0,(function(){var t=this;return x(this,(function(e){return 0==this.curIndex?[2,[!0]]:[2,this.slide(-.5*Math.PI,(function(){return t.curIndex--}))]}))}))},t.prototype.slide=function(t,e){return w(this,void 0,void 0,(function(){return x(this,(function(i){switch(i.label){case 0:return this.baseModel=this.modelMatrix,[4,this.rotate(t)];case 1:return i.sent(),e(),this.modelMatrix=this.baseModel=this.initialModel,this.gl.uniformMatrix4fv(this.gl.getUniformLocation(this.shaderProgram,"uModelViewMatrix"),!1,this.modelMatrix),[4,this.draw(this.curIndex)];case 2:return i.sent(),this.modelMatrix=this.baseModel=this.initialModel,[2,[!1]]}}))}))},t.prototype.rotate=function(t){var e,i=this;return this.animate({allTime:this.defaultAnimateTime,timingFun:f,ends:[t],playGame:(e=i.rotatePosition.bind(i),function(t){i.clear(),e(t)})})},t.prototype.rotateZ=function(t){var e=this;this.curPlane=this.positions.slice(this.curPointAt,this.curPointAt+16);var i=this.imgShape,n=this.imgShapeInitinal;this.imgShape=u.multiplyPoint(i,u.rotateZMatrix(t)),this.imgShapeInitinal=u.multiplyPoint(n,u.rotateZMatrix(t));var r=this.curCenterCoordinate,o=-r[0],s=-r[1];return this.animate({allTime:this.defaultAnimateTime,timingFun:f,ends:[t,o,s],playGame:function(){for(var t=[],i=0;ic?c:this.viewWidth):(i=c,n=u),p=-(t-r)*(d=i/a-1),g=(e-o)*(f=n/h-1),this.curIsLongImg()&&(p=0);return[d,f,p,g]},t.prototype.decideImgViewSize=function(t,e){var i=0,n=0;return(n=e/t*(i=this.viewWidth>=t?t:this.viewWidth))>this.viewHeight&&(i=(n=this.viewHeight)*t/e),[i,n]},t.prototype.draw=function(t){this.positions=[];for(var e=this.imgUrls.length,i=0,n=0,r=t-1;r<=t+1;r++)if(-1!==r&&r<=e-1){var o=void 0;this.imgs[r]?o=this.imgs[r]:"string"==typeof this.imgUrls[r]?o=this.loadImage(this.imgUrls[r],r):void 0===(o=this.imgUrls[r])._id&&(this.imgUrls[r]=this.validateImg(o),o=this.imgUrls[r]),this.imgs[r]=o;var s=o.naturalWidth,a=o.naturalHeight;o.loadError&&(s=a=200);var h=this.decideImgViewSize(s*this.dpr,a*this.dpr),l=h[0],c=h[1];r==this.curIndex&&(this.imgShape=[s*this.dpr,a*this.dpr,0,1],this.imgShapeInitinal=[l,c,0,1]),this.genPostion(l,c,r),i=Math.max(l,i),n=Math.max(c,n)}this.generateCube(i,n),this.bindPostion(),this.drawPosition()},t.prototype.createPerspectiveMatrix=function(){var t=this.fieldOfViewInRadians,e=this.viewWidth/this.viewHeight,i=this.zNear,n=this.zFar,r=1/Math.tan(t/2),o=1/(i-n);return[r/e,0,0,0,0,r,0,0,0,0,(i+n)*o,-1,0,0,i*n*o*2,0]},Object.defineProperty(t.prototype,"curPointAt",{get:function(){var t=64;return 0==this.curIndex&&(t=48),t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"IsBoundaryLeft",{get:function(){var t=this.viewRect;return Math.round(t.left)>=0&&this.isBoudriedSide},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isBoundaryRight",{get:function(){var t=this.viewRect;return Math.round(t.right*this.dpr)<=Math.round(this.viewWidth/1)&&this.isBoudriedSide},enumerable:!1,configurable:!0}),t.prototype.curIsLongImg=function(){var t=this.imgShape,e=t[0],i=t[1];return 2*Math.abs(e)<=Math.abs(i)},Object.defineProperty(t.prototype,"curCenterCoordinate",{get:function(){var t=this.curPointAt;return[(this.positions[t]+this.positions[t+8])/2,(this.positions[t+1]+this.positions[t+9])/2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"viewRect",{get:function(){for(var t=-this.viewWidth/2,e=this.viewHeight/2,i=this.curPointAt,n=1/0,r=-1/0,o=1/0,s=-1/0,a=i;athis.viewWidth||e.height*this.dpr-1>this.viewHeight},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isEnlargementForScale",{get:function(){var t=this.imgShapeInitinal,e=t[0],i=t[1],n=this.viewRect;return Math.round(n.width*this.dpr)>Math.round(Math.abs(e))||Math.round(n.height*this.dpr)>Math.round(Math.abs(i))},enumerable:!1,configurable:!0}),t.prototype.isLoadingError=function(t){return 0==arguments.length&&(t=this.curIndex),this.imgs[t].loadError},t.prototype.loadImage=function(t,e){var i=this,n=new Image;return n._id=this.imgId++,this.imgs[e]=n,n.onload=function(){i.handleImgLoaded(n,e)},n.onerror=function(){n.loadError=!0,i.handleImgLoaded(n,e)},n.onabort=function(){n.loadError=!0,i.handleImgLoaded(n,e)},n.crossOrigin="anonymous",n.src=t,n},t.prototype.handleImgLoaded=function(t,e){e=this.imgs.indexOf(t),t.loadError||(t=this.validateImg(t),this.imgs[e]=t),~[-1,0,1].indexOf(e-this.curIndex)&&(this.updatePosition(t,e-this.curIndex),this.bindPostion(),this.drawPosition())},t.prototype.validateImg=function(t){var e=this.gl.MAX_TEXTURE_SIZE,i=t.naturalWidth,n=t.naturalHeight;if(Math.max(n,i)>=e){var r=this.dpr,o=e/r,s=n/i*o;s>=e&&(o=i/n*(s=e/r));var a=m(t,o,s);return a._id=this.imgId++,a.naturalHeight=s,a.naturalWidth=o,a.complete=!0,a}return t},t.prototype.clear=function(){var t=this.gl;t.clearColor(0,0,0,1),t.clearDepth(1),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT)},t.prototype.bindShader=function(t,e,i){var n=this.loadShader(t,t.VERTEX_SHADER,i),r=this.loadShader(t,t.FRAGMENT_SHADER,e),o=t.createProgram();return t.attachShader(o,n),t.attachShader(o,r),t.linkProgram(o),t.getProgramParameter(o,t.LINK_STATUS)?o:(console.error("Unable to initialize the shader program: "+t.getProgramInfoLog(o)),null)},t.prototype.loadShader=function(t,e,i){var n=t.createShader(e);return t.shaderSource(n,i),t.compileShader(n),t.getShaderParameter(n,t.COMPILE_STATUS)?n:(console.error("An error occurred compiling the shaders: "+t.getShaderInfoLog(n)),t.deleteShader(n),null)},t.prototype.createPlane=function(t){return t.x,t.y,t.width,t.height,{}},t.prototype.intialView=function(){var t=document.createElement("canvas");t.style.cssText="\n position: absolute;\n top: 0;\n left:0;\n z-index: 9;\n width:"+window.innerWidth+"px;\n height:"+window.innerHeight+"px;\n user-select:none;\n font-size:0;\n ",t.width=window.innerWidth*this.dpr,t.height=window.innerHeight*this.dpr,this.ref=t;var e=t.getContext("webgl",{antialias:!0});return e||console.error("webgl is not supported. please use before version."),this.viewWidth=t.width,this.viewHeight=t.height,e},t.prototype.animate=function(t){var e,i=this,n=t.allTime,r=t.timingFun,o=t.ends,s=t.playGame,a=t.callback,h=Date.now(),l=h,c=new Promise((function(t){return e=t})),u=o.length,d=function(){if(i.curAimateBreaked)return e([!1,3]),void(i.curAimateBreaked=!1);var t=l-h;t>n&&(t=n);var c=t/n;c>1&&(c=1);var f=r.solve(c);f>=1&&(f=1);var p=new Array(u);o.forEach((function(t,e){p[e]=t*f})),s.apply(void 0,p),c<1?requestAnimationFrame(d):(a&&a(),e([!1,1])),l=Date.now()};return d(),c},t}(),P=function(t,e,i,n){var r,o=arguments.length,s=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(s=(o<3?r(s):o>3?r(e,i,s):r(e,i))||s);return o>3&&s&&Object.defineProperty(e,i,s),s},I=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},A=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]d?(w=d-g,m=!0):gc?(x=c-p,v=!0):p=0&&l<=n&&(m=!1,w=0),s<=r&&(v=!1,x=0),m||v?(this.isAnimating=!0,[4,e.eventsHanlder.handleTEndEnlarge(t,w,x,0)]):[3,2];case 1:return I.sent(),this.isAnimating=!1,[3,4];case 2:return this.moveEndTime=Date.now(),y={x:this.startX,y:this.startY},M={x:this.touchStartX,y:this.touchStartY},b=y.x-M.x,E=y.y-M.y,T=180*Math.atan2(E,b)/Math.PI,this.moveEndTime-this.moveStartTime<90&&Math.abs(b)+Math.abs(E)>5?(P={maxTop:c,minTop:u,maxLeft:d,minLeft:n-o},this.isAnimating=!0,[4,this.autoMove(T,h,a,P)]):[3,4];case 3:I.sent(),this.isAnimating=!1,I.label=4;case 4:return this.moveStartTime=0,[2]}}))}))},t.prototype.handleTEndEnNormal=function(t){return I(this,void 0,void 0,(function(){var e,i,n;return A(this,(function(r){switch(r.label){case 0:return this.isAnimating?[2]:(e=t.changedTouches[0].clientX,i=this.actionExecutor.eventsHanlder,0===(n=e-this.touchStartX)?[2]:(this.isAnimating=!0,[4,i.handleTEndEnNormal(t,n)]));case 1:return r.sent(),this.isAnimating=!1,[2]}}))}))},t.prototype.genFrame=function(){var t=this,e=this.options.imgs;!e||e.length,this.imgsNumber=e.length,this.curIndex=0;var i='\n
\n \n \n \n \n
\n
\n
\n '+("pc"==this.envClient?'
\n \n
\n
\n \n
':"")+'\n
\n \n
\n
\n \n
\n
\n ',n=/iphone/gi.test(window.navigator.userAgent)&&window.devicePixelRatio&&3===window.devicePixelRatio&&375===window.screen.width&&812===window.screen.height,r=/iphone/gi.test(window.navigator.userAgent)&&window.devicePixelRatio&&3===window.devicePixelRatio&&414===window.screen.width&&896===window.screen.height,o=/iphone/gi.test(window.navigator.userAgent)&&window.devicePixelRatio&&2===window.devicePixelRatio&&414===window.screen.width&&896===window.screen.height,s=n||r||o,a="\n ."+this.prefix+"imagePreviewer{\n position: fixed;\n top:0;\n left: 100%;\n width: 100%;\n height: 100%;\n background: "+function(e){switch(e){case"conBackground":return"pc"==t.envClient?"rgba(0,0,0,0.8)":"rgba(0,0,0,1)";case"imgWidth":return t.envClient,"100%";case"itemHeight":return"pc"==t.envClient?"100%":"auto";case"itemScroll":return"pc"==t.envClient?"auto ":"hidden";case"item-text-align":return"pc"==t.envClient?"center ":"initial";default:return""}}("conBackground")+";\n color:#fff;\n transform: translate3d(0,0,0);\n transition: left 0.5s;\n overflow:hidden;\n user-select: none;\n }\n \n ."+this.prefix+"imagePreviewer."+this.defToggleClass+"{\n left: 0%;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"close{\n position: absolute;\n top: 20px;\n right: 20px;\n z-index: 10;\n box-sizing: border-box;\n width: 22px;\n height: 22px;\n cursor:pointer;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"close svg{\n width: 100%;\n height: 100%; \n }\n ."+this.prefix+"imagePreviewer svg{\n overflow:visible;\n }\n ."+this.prefix+"imagePreviewer svg path{\n stroke: #948888;\n stroke-width: 30px;\n }\n \n ."+this.prefix+"imagePreviewer "+this.prefix+".close."+this.prefix+"scroll{\n height: 0;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"imgContainer{\n position: relative;\n height: 100%;\n font-size: 0;\n white-space: nowrap;\n }\n \n ."+this.prefix+"imagePreviewer ."+this.prefix+"bottom{\n position: absolute;\n bottom: "+(s?20:0)+"px;\n left: 20px;\n right: 20px;\n z-index: 10;\n padding: 0 10px;\n text-align: center;\n border-top: 1px solid rgba(255, 255, 255, .2);\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"bottom ."+this.prefix+"item{\n display:inline-block;\n width: 42px;\n height: 42px;\n cursor:pointer;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"bottom ."+this.prefix+"item svg{\n box-sizing: border-box;\n width: 100%;\n height: 100%;\n padding:10px;\n }\n ";if(this.ref=document.createElement("div"),this.ref.className=this.prefix+"imagePreviewer",this.ref.innerHTML=i,!document.querySelector("#"+this.prefix+"style")){var h=document.createElement("style");h.id=this.prefix+"style",h.innerHTML=a,document.querySelector("head").appendChild(h)}this.ref.querySelector("."+this.prefix+"imgContainer").append(this.actionExecutor.ref),document.body.appendChild(this.ref)},t.prototype.handleReausetAnimate=function(){window.requestAnimationFrame||(window.requestAnimationFrame=window.webkitRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60),0})},t.prototype.close=function(t){t.stopImmediatePropagation(),clearTimeout(this.performerClick),this[this.envClient+"BeforeClose"](),this.toggleClass(this.ref,this.defToggleClass)},t.prototype.pcBeforeClose=function(){document.body.style.overflow=document.body.dataset.imgPreOverflow},t.prototype.mobileBeforeClose=function(){},t.prototype.show=function(t){this.actionExecutor.curIndex=t,this.actionExecutor.draw(t),this.toggleClass(this.ref,this.defToggleClass)},t.prototype.mobileReadyShow=function(){},t.prototype.pcReadyShow=function(){var t=window.getComputedStyle(document.body);document.body.dataset.imgPreOverflow=t.overflow,document.body.style.overflow="hidden"},t.prototype.toggleClass=function(t,e){var i=t.className.split(" "),n=i.indexOf(e);-1!==n?i.splice(n,1):i.push(e),t.className=i.join(" ")},t.prototype.getMovePoints=function(t){var e=this;if(!(this.movePoints.length>this.maxMovePointCounts)){this.movePoints.push({x:t.touches[0].clientX,y:t.touches[0].clientY});this.addTouchEndTask("resetMovePoints",{priority:1,callback:function(){return e.movePoints=[]}})}},t.prototype.decideMoveDirection=function(){var t=this,e=this.movePoints.length,i=this.movePoints[e-1],n=this.movePoints[0],r=i.x-n.x,o=i.y-n.y,s=180*Math.atan2(o,r)/Math.PI;Math.abs(90-Math.abs(s))<30?this.fingerDirection="vertical":this.fingerDirection="horizontal";this.addTouchEndTask("resetFingerDirection",{priority:1,callback:function(){t.fingerDirection=""}})},t.prototype.destroy=function(){this.ref.parentNode.removeChild(this.ref),window.removeEventListener("resize",this.handleResize),window.removeEventListener("orientationchange",this.handleResize)},t.prototype.testEnv=function(){return/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)?"mobile":"pc"},t=P([r],t)}();E=S,[o,s,l].forEach((function(t){Object.getOwnPropertyNames(t.prototype).forEach((function(e){E.prototype[e]=t.prototype[e]}))})),exports.ImagePreview=S; diff --git a/release/image-preview/image-preview-cjs.js b/release/image-preview/image-preview-cjs.js index ec5dfea..0a8fc83 100644 --- a/release/image-preview/image-preview-cjs.js +++ b/release/image-preview/image-preview-cjs.js @@ -766,6 +766,7 @@ var matrix = { var cubicBezier = (function () { function cubicBezier(x1, y1, x2, y2) { + this.cachedY = new Map(); this.precision = 1e-5; this.p1 = { x: x1, @@ -825,7 +826,10 @@ var cubicBezier = (function () { return t2; }; cubicBezier.prototype.solve = function (x) { - return this.getY(this.solveCurveX(x)); + if (!this.cachedY.get(x)) { + this.cachedY.set(x, this.getY(this.solveCurveX(x))); + } + return this.cachedY.get(x); }; return cubicBezier; }()); @@ -1343,7 +1347,8 @@ var webGl = (function () { }; webGl.prototype.genPostion = function (width, height, index) { var _a; - var z = -(this.viewHeight) / (2 * Math.tan(this.fieldOfViewInRadians / 2)) - forDev; + var zNearHeight = (2 * Math.tan(this.fieldOfViewInRadians / 2)); + var z = -(this.viewHeight) / (zNearHeight) - forDev; var viewWidth = this.viewWidth; var sideZAxis = z - (viewWidth - width) / 2; var positionsMap = [ diff --git a/release/image-preview/image-preview-esm-min.js b/release/image-preview/image-preview-esm-min.js index 8783043..458a8d0 100644 --- a/release/image-preview/image-preview-esm-min.js +++ b/release/image-preview/image-preview-esm-min.js @@ -1 +1 @@ -var t,e=(t=function(e,i){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(e,i)},function(e,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}),i=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},n=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]0?(h=-(i-s)*u,a=-(e-o)*u,l=1+u,c=1+u):(h=(i-s)*u,a=(e-o)*u,l=1-u,c=1-u),r.eventsHanlder.handleZoom(l,c,a,h),this.isZooming=!1,this.isAnimating=!1,this.actionExecutor.isEnlargement?this.ref.style.cursor="grab":this.ref.style.cursor="initial",[2]}))}))},r.prototype.handlePCDoubleClick=function(t){return i(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return this.isAnimating?[2]:(this.isAnimating=!0,[4,this.actionExecutor.eventsHanlder.handleDoubleClick({clientX:t.clientX,clientY:t.clientY})]);case 1:return e.sent(),this.isAnimating=!1,this.actionExecutor.isEnlargement?this.ref.style.cursor="grab":this.ref.style.cursor="initial",[2]}}))}))},r.prototype.handleMouseDown=function(t){var e=this,i=t.target.dataset.type;this[i]?this[i](t):(this.mouseDown=!0,this.actionExecutor.isEnlargement?(this.startX=t.clientX,this.startY=t.clientY,this.ref.style.cursor="grabbing"):this.ref.style.cursor="initial",Date.now()-this.lastClick0?"right":"left",s=this.actionExecutor.viewRect,a=s.left,h=s.right,l=this.actionExecutor.viewWidth/this.actionExecutor.dpr;if(this.fingerDirection)if(this.actionExecutor.isEnlargement)if(a>=0&&h<=l)if("right"!=o&&"left"!=o&&!this.isEnlargeMove||"horizontal"!=this.fingerDirection)this.handleMoveEnlage(t);else{this.isEnlargeMove=!0,this.handleMoveNormal(t);var c="resetEnlargeMove";this.addTouchEndTask(c,{priority:1,callback:function(){e.isEnlargeMove=!1}})}else if(i&&"right"==o||n&&"left"==o||this.isEnlargeMove){this.isEnlargeMove=!0,this.handleMoveNormal(t);c="resetEnlargeMove";this.addTouchEndTask(c,{priority:1,callback:function(){return e.isEnlargeMove=!1}})}else this.handleMoveEnlage(t);else this.handleMoveNormal(t);else{if(this.actionExecutor.isEnlargement&&(a<0||h>l)||!this.actionExecutor.isEnlargement)return void(!this.actionExecutor.isEnlargement||r||this.normalMoved?this.actionExecutor.isEnlargement?(r||this.normalMoved)&&(this.normalMoved?this.handleMoveNormal(t):"right"==o?i?this.handleMoveNormal(t):this.handleMoveEnlage(t):"left"==o&&n?this.handleMoveNormal(t):this.handleMoveEnlage(t)):this.handleMoveNormal(t):this.handleMoveEnlage(t));if(this.getMovePoints(t),this.movePoints.lengthn?p:0,s=Math.round(c)<0||Math.round(u)>r?g:0,e.eventsHanlder.handleMoveEnlage(a,s,0);this.addTouchEndTask("handleTendEnlarte",{priority:10,callback:this.handleTEndEnlarge.bind(this)}),this.startX=d,this.startY=f}},t.prototype.autoMove=function(t,e,i,n){var r=n.maxTop,o=n.minTop,s=n.maxLeft,a=n.minLeft,h=this.imgContainer.getBoundingClientRect(),l=h.width,c=h.height,u=this.actionExecutor,d=u.viewRect,f=u.eventsHanlder,p=d,g=p.top,v=p.bottom,m=p.left,w=p.right;t=t/180*Math.PI;var x=e+300*Math.cos(t),y=i+300*Math.sin(t);x>s?x=s:xr?y=r:y=0&&w<=l||(M=x-e),g>=0&&v<=c||(b=y-i),f.moveCurPlaneTo(M,b,0)},t}(),s=function(){function t(){}return t.prototype.handleZoom=function(t){if(!(this.isNormalMove&&this.normalMoved||this.isAnimating||this.actionExecutor.isLoadingError())){this.isZooming||(this.curStartPoint1={x:this.curPoint1.x,y:this.curPoint1.y},this.curStartPoint2={x:this.curPoint2.x,y:this.curPoint2.y}),this.isZooming=!0,this.isAnimating=!0;var e=this.actionExecutor,i=Math.pow(this.curPoint1.x-this.curPoint2.x,2)+Math.pow(this.curPoint1.y-this.curPoint2.y,2),n=Math.pow(t.touches[0].clientX-t.touches[1].clientX,2)+Math.pow(t.touches[0].clientY-t.touches[1].clientY,2),r=(this.curStartPoint1.x+this.curStartPoint2.x)/2,o=(this.curStartPoint1.y+this.curStartPoint2.y)/2,s=e.viewWidth/(2*e.dpr),a=e.viewHeight/(2*e.dpr);this.curPoint1.x=t.touches[0].clientX,this.curPoint1.y=t.touches[0].clientY,this.curPoint2.x=t.touches[1].clientX,this.curPoint2.y=t.touches[1].clientY;var h=0,l=0,c=1,u=1;if(i>n)l=(o-a)*this.zoomScale,h=(r-s)*this.zoomScale,c=1-this.zoomScale,u=1-this.zoomScale;else{if(!(i0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]d;){if(i=this.getX(r)-t,Math.abs(i)0?u=r:d=r,r=(u+d)/2}return r},t.prototype.solve=function(t){return this.getY(this.solveCurveX(t))},t}(),f=new d(0,0,1,1);new d(.25,.1,.25,1),new d(.42,0,1,1),new d(0,0,.58,1),new d(.42,0,.58,1);var p=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},g=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]4*s||(l*t=this.throldDeg?(o=t.curIndex,-1!=(s=t.curIndex+1*r)&&s!=t.imgUrls.length?[3,2]:(t.curIndex=o,[4,t.rotate(-n)])):[3,6];case 1:return a.sent(),[3,5];case 2:return[4,t.rotate(r*Math.PI/2-n)];case 3:return a.sent(),t.curIndex=s,t.modelMatrix=t.baseModel=t.initialModel,t.gl.uniformMatrix4fv(t.gl.getUniformLocation(t.shaderProgram,"uModelViewMatrix"),!1,t.modelMatrix),[4,t.draw(s)];case 4:a.sent(),a.label=5;case 5:return[3,8];case 6:return[4,t.rotate(-n)];case 7:a.sent(),a.label=8;case 8:return t.modelMatrix=t.baseModel=t.initialModel,[2,"handled"]}}))}))},t.prototype.handleTEndEnlarge=function(t,e,i,n){return p(this,void 0,void 0,(function(){var t;return g(this,(function(n){switch(n.label){case 0:return t=this.viewInstance,e*=t.dpr,i*=-t.dpr,t.dpr,this.curBehaviorCanBreak=!0,[4,t.moveCurPlane(e,i,0)];case 1:return n.sent(),this.curBehaviorCanBreak=!1,0!==e&&(t.isBoudriedSide=!0),[2]}}))}))},t.prototype.moveCurPlaneTo=function(t,e,i){return p(this,void 0,void 0,(function(){var i;return g(this,(function(n){switch(n.label){case 0:return i=this.viewInstance,t*=i.dpr,e*=-i.dpr,i.dpr,this.curBehaviorCanBreak=!0,[4,i.moveCurPlane(t,e,0)];case 1:return n.sent(),this.curBehaviorCanBreak=!1,[2]}}))}))},t}();var m=function(t,e,i){var n=t.naturalWidth,r=t.naturalHeight,o=document.createElement("canvas"),s=o.getContext("2d"),a=window.devicePixelRatio||1;return o.width=e*a,o.height=i*a,s.drawImage(t,0,0,n,r,0,0,e*a,i*a),o},w=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},x=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]n&&(e=n-1,r=n),this.imgUrls.splice(e+1,0,t),e+1>this.imgs.length?this.imgs[r]=null:this.imgs.splice(e+1,0,null),t instanceof Image)if(void 0===t._id&&(t._id=this.imgId++),t.complete)this.imgUrls[e+1]=this.validateImg(t);else{var o=function(){var e=i.imgUrls.indexOf(t);t.loadError=!0,~[-2,-1,0].indexOf(e-i.curIndex)&&i.draw(i.curIndex)};t.addEventListener("load",(function(){var e=i.imgUrls.indexOf(t);i.imgUrls[e]=i.validateImg(t),~[-2,-1,0].indexOf(e-i.curIndex)&&i.draw(i.curIndex)})),t.addEventListener("error",o),t.addEventListener("abort",o)}~[-2,-1,0].indexOf(e-this.curIndex)&&this.draw(this.curIndex)},t.prototype.delImg=function(t){var e=this.imgUrls.length;t<=-1?t=0:t>=e&&(t=e-1),this.imgUrls.splice(t,1),this.imgs[t]&&this.textures.delete(this.imgs[t]._id),this.imgs.splice(t,1),t-=this.curIndex,~[-1,0,1].indexOf(t)&&this.draw(this.curIndex)},t.prototype.initOtherTexture=function(){var t=this,e=this.gl,i=e.createTexture();this.texturesOther.set(0,i),e.bindTexture(e.TEXTURE_2D,i),i.cubicBgd=!0;e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,new Uint8Array([0,0,0,255]));var n=new Image;n.onload=function(){var i=e.createTexture();t.texturesOther.set(1,i),e.bindTexture(e.TEXTURE_2D,i),t.texImage(n),t.setTexParameteri(n.width,n.height)},n.src="data:image/svg+xml;base64,PHN2ZyB0PSIxNjI1ODExNDgwNTgyIiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEzNDIgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjYwNjkiIHdpZHRoPSIyMDAiIGhlaWdodD0iMjAwIj48cGF0aCBkPSJNMTIxNi4zNTcgMTM5LjAzYy0xMC4xNTctMTEuNDI3LTI0Ljc1OS0xNy43NzUtMzkuOTk1LTE4LjQxTDc0My40IDEwMy40OGwtMzIuMzc3IDczLjAwNiA0NS4wNzQgMTM1Ljg1Ni04MS4yNiAxNTQuMjY3IDMzLjAxMiAxMjQuNDI5IDgyLjUzIDEwNi42NTMgMTE5LjM1LTEwOS44MjdjMTEuNDI3LTEwLjc5MyAyOS44MzctMTAuMTU4IDM5Ljk5NCAxLjkwNGwxNTIuOTk3IDE2NS42OTRjMTAuNzkzIDExLjQyNyAxMC4xNTggMjkuODM3LTEuMjcgNDAuNjMtNS43MTMgNS4wNzgtMTIuNjk2IDguMjUzLTIwLjMxNCA3LjYxOGwtNDE5LjYzLTE2LjUwNi0yMC45NSA2MC4zMSAyMi44NTQgNTMuOTYyIDQ4Mi40OCAxOC40MWMzMS43NDIgMS4yNyA1OC40MDUtMjMuNDkgNTkuMDQtNTUuMjMxbDI2LjY2My02ODQuMzZjMC42MzUtMTUuMjM2LTQuNDQ0LTMwLjQ3Mi0xNS4yMzYtNDEuMjY1ek05MDYuNTU0IDQ1My4yNzdjLTQ3LjYxMy0xLjkwNC04NC40MzQtNDEuOS04Mi41My04OC44NzggMS45MDUtNDcuNjEzIDQxLjktODQuNDM0IDg4Ljg3OS04Mi41MyA0Ni45NzggMS45MDUgODQuNDM0IDQxLjkgODIuNTMgODguODc5LTEuOTA1IDQ2Ljk3OC00MS45IDg0LjQzNC04OC44NzkgODIuNTN6TTU5NS40ODIgODQ4LjE1bDE0LjYwMS02My40ODQtMzQwLjkxIDIzLjQ4OWMtMTUuODcxIDEuMjctMjkuMjAzLTEwLjE1OC0zMC40NzItMjYuMDI5YTI4LjEyIDI4LjEyIDAgMCAxIDYuOTgzLTIwLjk1TDQ5OC4zNSA0NzEuMDUzYzUuMDc5LTYuMzQ5IDEyLjY5Ny05LjUyMyAyMC45NS05LjUyMyA3LjYxOCAwIDE1LjIzNiAzLjE3NCAyMC45NSA4Ljg4OGw4NC40MzMgODguMjQzLTM2LjE4Ni05My45NTcgNjQuNzU0LTE2Mi41Mi01OS4wNC0xMzAuMTQyIDI0LjEyNC03NC45MTEtNDY0LjcwNCAzMi4zNzdjLTMxLjc0MiAxLjkwNC01NS4yMzIgMjkuMjAyLTUzLjMyNyA2MC45NDVsNDYuOTc4IDY4NC4zNmMwLjYzNSAxNS4yMzUgNy42MTggMjkuMjAyIDE5LjY4IDM4LjcyNSAxMS40MjggMTAuMTU3IDI2LjAyOSAxNS4yMzYgNDEuMjY1IDEzLjk2Nmw0MTUuMTg3LTI4LjU2OC0yNy45MzMtNTAuNzg3eiIgcC1pZD0iNjA3MCIgZmlsbD0iI2JmYmZiZiIvPjwvc3ZnPg=="},t.prototype.initData=function(){this.draw(this.curIndex)},t.prototype.slideNext=function(){return w(this,void 0,void 0,(function(){var t=this;return x(this,(function(e){return this.curIndex==this.imgUrls.length-1?[2,[!0]]:[2,this.slide(.5*Math.PI,(function(){return t.curIndex++}))]}))}))},t.prototype.slideBefore=function(){return w(this,void 0,void 0,(function(){var t=this;return x(this,(function(e){return 0==this.curIndex?[2,[!0]]:[2,this.slide(-.5*Math.PI,(function(){return t.curIndex--}))]}))}))},t.prototype.slide=function(t,e){return w(this,void 0,void 0,(function(){return x(this,(function(i){switch(i.label){case 0:return this.baseModel=this.modelMatrix,[4,this.rotate(t)];case 1:return i.sent(),e(),this.modelMatrix=this.baseModel=this.initialModel,this.gl.uniformMatrix4fv(this.gl.getUniformLocation(this.shaderProgram,"uModelViewMatrix"),!1,this.modelMatrix),[4,this.draw(this.curIndex)];case 2:return i.sent(),this.modelMatrix=this.baseModel=this.initialModel,[2,[!1]]}}))}))},t.prototype.rotate=function(t){var e,i=this;return this.animate({allTime:this.defaultAnimateTime,timingFun:f,ends:[t],playGame:(e=i.rotatePosition.bind(i),function(t){i.clear(),e(t)})})},t.prototype.rotateZ=function(t){var e=this;this.curPlane=this.positions.slice(this.curPointAt,this.curPointAt+16);var i=this.imgShape,n=this.imgShapeInitinal;this.imgShape=u.multiplyPoint(i,u.rotateZMatrix(t)),this.imgShapeInitinal=u.multiplyPoint(n,u.rotateZMatrix(t));var r=this.curCenterCoordinate,o=-r[0],s=-r[1];return this.animate({allTime:this.defaultAnimateTime,timingFun:f,ends:[t,o,s],playGame:function(){for(var t=[],i=0;ic?c:this.viewWidth):(i=c,n=u),p=-(t-r)*(d=i/a-1),g=(e-o)*(f=n/h-1),this.curIsLongImg()&&(p=0);return[d,f,p,g]},t.prototype.decideImgViewSize=function(t,e){var i=0,n=0;return(n=e/t*(i=this.viewWidth>=t?t:this.viewWidth))>this.viewHeight&&(i=(n=this.viewHeight)*t/e),[i,n]},t.prototype.draw=function(t){this.positions=[];for(var e=this.imgUrls.length,i=0,n=0,r=t-1;r<=t+1;r++)if(-1!==r&&r<=e-1){var o=void 0;this.imgs[r]?o=this.imgs[r]:"string"==typeof this.imgUrls[r]?o=this.loadImage(this.imgUrls[r],r):void 0===(o=this.imgUrls[r])._id&&(this.imgUrls[r]=this.validateImg(o),o=this.imgUrls[r]),this.imgs[r]=o;var s=o.naturalWidth,a=o.naturalHeight;o.loadError&&(s=a=200);var h=this.decideImgViewSize(s*this.dpr,a*this.dpr),l=h[0],c=h[1];r==this.curIndex&&(this.imgShape=[s*this.dpr,a*this.dpr,0,1],this.imgShapeInitinal=[l,c,0,1]),this.genPostion(l,c,r),i=Math.max(l,i),n=Math.max(c,n)}this.generateCube(i,n),this.bindPostion(),this.drawPosition()},t.prototype.createPerspectiveMatrix=function(){var t=this.fieldOfViewInRadians,e=this.viewWidth/this.viewHeight,i=this.zNear,n=this.zFar,r=1/Math.tan(t/2),o=1/(i-n);return[r/e,0,0,0,0,r,0,0,0,0,(i+n)*o,-1,0,0,i*n*o*2,0]},Object.defineProperty(t.prototype,"curPointAt",{get:function(){var t=64;return 0==this.curIndex&&(t=48),t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"IsBoundaryLeft",{get:function(){var t=this.viewRect;return Math.round(t.left)>=0&&this.isBoudriedSide},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isBoundaryRight",{get:function(){var t=this.viewRect;return Math.round(t.right*this.dpr)<=Math.round(this.viewWidth/1)&&this.isBoudriedSide},enumerable:!1,configurable:!0}),t.prototype.curIsLongImg=function(){var t=this.imgShape,e=t[0],i=t[1];return 2*Math.abs(e)<=Math.abs(i)},Object.defineProperty(t.prototype,"curCenterCoordinate",{get:function(){var t=this.curPointAt;return[(this.positions[t]+this.positions[t+8])/2,(this.positions[t+1]+this.positions[t+9])/2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"viewRect",{get:function(){for(var t=-this.viewWidth/2,e=this.viewHeight/2,i=this.curPointAt,n=1/0,r=-1/0,o=1/0,s=-1/0,a=i;athis.viewWidth||e.height*this.dpr-1>this.viewHeight},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isEnlargementForScale",{get:function(){var t=this.imgShapeInitinal,e=t[0],i=t[1],n=this.viewRect;return Math.round(n.width*this.dpr)>Math.round(Math.abs(e))||Math.round(n.height*this.dpr)>Math.round(Math.abs(i))},enumerable:!1,configurable:!0}),t.prototype.isLoadingError=function(t){return 0==arguments.length&&(t=this.curIndex),this.imgs[t].loadError},t.prototype.loadImage=function(t,e){var i=this,n=new Image;return n._id=this.imgId++,this.imgs[e]=n,n.onload=function(){i.handleImgLoaded(n,e)},n.onerror=function(){n.loadError=!0,i.handleImgLoaded(n,e)},n.onabort=function(){n.loadError=!0,i.handleImgLoaded(n,e)},n.crossOrigin="anonymous",n.src=t,n},t.prototype.handleImgLoaded=function(t,e){e=this.imgs.indexOf(t),t.loadError||(t=this.validateImg(t),this.imgs[e]=t),~[-1,0,1].indexOf(e-this.curIndex)&&(this.updatePosition(t,e-this.curIndex),this.bindPostion(),this.drawPosition())},t.prototype.validateImg=function(t){var e=this.gl.MAX_TEXTURE_SIZE,i=t.naturalWidth,n=t.naturalHeight;if(Math.max(n,i)>=e){var r=this.dpr,o=e/r,s=n/i*o;s>=e&&(o=i/n*(s=e/r));var a=m(t,o,s);return a._id=this.imgId++,a.naturalHeight=s,a.naturalWidth=o,a.complete=!0,a}return t},t.prototype.clear=function(){var t=this.gl;t.clearColor(0,0,0,1),t.clearDepth(1),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT)},t.prototype.bindShader=function(t,e,i){var n=this.loadShader(t,t.VERTEX_SHADER,i),r=this.loadShader(t,t.FRAGMENT_SHADER,e),o=t.createProgram();return t.attachShader(o,n),t.attachShader(o,r),t.linkProgram(o),t.getProgramParameter(o,t.LINK_STATUS)?o:(console.error("Unable to initialize the shader program: "+t.getProgramInfoLog(o)),null)},t.prototype.loadShader=function(t,e,i){var n=t.createShader(e);return t.shaderSource(n,i),t.compileShader(n),t.getShaderParameter(n,t.COMPILE_STATUS)?n:(console.error("An error occurred compiling the shaders: "+t.getShaderInfoLog(n)),t.deleteShader(n),null)},t.prototype.createPlane=function(t){return t.x,t.y,t.width,t.height,{}},t.prototype.intialView=function(){var t=document.createElement("canvas");t.style.cssText="\n position: absolute;\n top: 0;\n left:0;\n z-index: 9;\n width:"+window.innerWidth+"px;\n height:"+window.innerHeight+"px;\n user-select:none;\n font-size:0;\n ",t.width=window.innerWidth*this.dpr,t.height=window.innerHeight*this.dpr,this.ref=t;var e=t.getContext("webgl",{antialias:!0});return e||console.error("webgl is not supported. please use before version."),this.viewWidth=t.width,this.viewHeight=t.height,e},t.prototype.animate=function(t){var e,i=this,n=t.allTime,r=t.timingFun,o=t.ends,s=t.playGame,a=t.callback,h=Date.now(),l=h,c=new Promise((function(t){return e=t})),u=o.length,d=function(){if(i.curAimateBreaked)return e([!1,3]),void(i.curAimateBreaked=!1);var t=l-h;t>n&&(t=n);var c=t/n;c>1&&(c=1);var f=r.solve(c);f>=1&&(f=1);var p=new Array(u);o.forEach((function(t,e){p[e]=t*f})),s.apply(void 0,p),c<1?requestAnimationFrame(d):(a&&a(),e([!1,1])),l=Date.now()};return d(),c},t}(),P=function(t,e,i,n){var r,o=arguments.length,s=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(s=(o<3?r(s):o>3?r(e,i,s):r(e,i))||s);return o>3&&s&&Object.defineProperty(e,i,s),s},I=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},A=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]d?(w=d-g,m=!0):gc?(x=c-p,v=!0):p=0&&l<=n&&(m=!1,w=0),s<=r&&(v=!1,x=0),m||v?(this.isAnimating=!0,[4,e.eventsHanlder.handleTEndEnlarge(t,w,x,0)]):[3,2];case 1:return I.sent(),this.isAnimating=!1,[3,4];case 2:return this.moveEndTime=Date.now(),y={x:this.startX,y:this.startY},M={x:this.touchStartX,y:this.touchStartY},b=y.x-M.x,E=y.y-M.y,T=180*Math.atan2(E,b)/Math.PI,this.moveEndTime-this.moveStartTime<90&&Math.abs(b)+Math.abs(E)>5?(P={maxTop:c,minTop:u,maxLeft:d,minLeft:n-o},this.isAnimating=!0,[4,this.autoMove(T,h,a,P)]):[3,4];case 3:I.sent(),this.isAnimating=!1,I.label=4;case 4:return this.moveStartTime=0,[2]}}))}))},t.prototype.handleTEndEnNormal=function(t){return I(this,void 0,void 0,(function(){var e,i,n;return A(this,(function(r){switch(r.label){case 0:return this.isAnimating?[2]:(e=t.changedTouches[0].clientX,i=this.actionExecutor.eventsHanlder,0===(n=e-this.touchStartX)?[2]:(this.isAnimating=!0,[4,i.handleTEndEnNormal(t,n)]));case 1:return r.sent(),this.isAnimating=!1,[2]}}))}))},t.prototype.genFrame=function(){var t=this,e=this.options.imgs;!e||e.length,this.imgsNumber=e.length,this.curIndex=0;var i='\n
\n \n \n \n \n
\n
\n
\n '+("pc"==this.envClient?'
\n \n
\n
\n \n
':"")+'\n
\n \n
\n
\n \n
\n
\n ',n=/iphone/gi.test(window.navigator.userAgent)&&window.devicePixelRatio&&3===window.devicePixelRatio&&375===window.screen.width&&812===window.screen.height,r=/iphone/gi.test(window.navigator.userAgent)&&window.devicePixelRatio&&3===window.devicePixelRatio&&414===window.screen.width&&896===window.screen.height,o=/iphone/gi.test(window.navigator.userAgent)&&window.devicePixelRatio&&2===window.devicePixelRatio&&414===window.screen.width&&896===window.screen.height,s=n||r||o,a="\n ."+this.prefix+"imagePreviewer{\n position: fixed;\n top:0;\n left: 100%;\n width: 100%;\n height: 100%;\n background: "+function(e){switch(e){case"conBackground":return"pc"==t.envClient?"rgba(0,0,0,0.8)":"rgba(0,0,0,1)";case"imgWidth":return t.envClient,"100%";case"itemHeight":return"pc"==t.envClient?"100%":"auto";case"itemScroll":return"pc"==t.envClient?"auto ":"hidden";case"item-text-align":return"pc"==t.envClient?"center ":"initial";default:return""}}("conBackground")+";\n color:#fff;\n transform: translate3d(0,0,0);\n transition: left 0.5s;\n overflow:hidden;\n user-select: none;\n }\n \n ."+this.prefix+"imagePreviewer."+this.defToggleClass+"{\n left: 0%;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"close{\n position: absolute;\n top: 20px;\n right: 20px;\n z-index: 10;\n box-sizing: border-box;\n width: 22px;\n height: 22px;\n cursor:pointer;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"close svg{\n width: 100%;\n height: 100%; \n }\n ."+this.prefix+"imagePreviewer svg{\n overflow:visible;\n }\n ."+this.prefix+"imagePreviewer svg path{\n stroke: #948888;\n stroke-width: 30px;\n }\n \n ."+this.prefix+"imagePreviewer "+this.prefix+".close."+this.prefix+"scroll{\n height: 0;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"imgContainer{\n position: relative;\n height: 100%;\n font-size: 0;\n white-space: nowrap;\n }\n \n ."+this.prefix+"imagePreviewer ."+this.prefix+"bottom{\n position: absolute;\n bottom: "+(s?20:0)+"px;\n left: 20px;\n right: 20px;\n z-index: 10;\n padding: 0 10px;\n text-align: center;\n border-top: 1px solid rgba(255, 255, 255, .2);\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"bottom ."+this.prefix+"item{\n display:inline-block;\n width: 42px;\n height: 42px;\n cursor:pointer;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"bottom ."+this.prefix+"item svg{\n box-sizing: border-box;\n width: 100%;\n height: 100%;\n padding:10px;\n }\n ";if(this.ref=document.createElement("div"),this.ref.className=this.prefix+"imagePreviewer",this.ref.innerHTML=i,!document.querySelector("#"+this.prefix+"style")){var h=document.createElement("style");h.id=this.prefix+"style",h.innerHTML=a,document.querySelector("head").appendChild(h)}this.ref.querySelector("."+this.prefix+"imgContainer").append(this.actionExecutor.ref),document.body.appendChild(this.ref)},t.prototype.handleReausetAnimate=function(){window.requestAnimationFrame||(window.requestAnimationFrame=window.webkitRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60),0})},t.prototype.close=function(t){t.stopImmediatePropagation(),clearTimeout(this.performerClick),this[this.envClient+"BeforeClose"](),this.toggleClass(this.ref,this.defToggleClass)},t.prototype.pcBeforeClose=function(){document.body.style.overflow=document.body.dataset.imgPreOverflow},t.prototype.mobileBeforeClose=function(){},t.prototype.show=function(t){this.actionExecutor.curIndex=t,this.actionExecutor.draw(t),this.toggleClass(this.ref,this.defToggleClass)},t.prototype.mobileReadyShow=function(){},t.prototype.pcReadyShow=function(){var t=window.getComputedStyle(document.body);document.body.dataset.imgPreOverflow=t.overflow,document.body.style.overflow="hidden"},t.prototype.toggleClass=function(t,e){var i=t.className.split(" "),n=i.indexOf(e);-1!==n?i.splice(n,1):i.push(e),t.className=i.join(" ")},t.prototype.getMovePoints=function(t){var e=this;if(!(this.movePoints.length>this.maxMovePointCounts)){this.movePoints.push({x:t.touches[0].clientX,y:t.touches[0].clientY});this.addTouchEndTask("resetMovePoints",{priority:1,callback:function(){return e.movePoints=[]}})}},t.prototype.decideMoveDirection=function(){var t=this,e=this.movePoints.length,i=this.movePoints[e-1],n=this.movePoints[0],r=i.x-n.x,o=i.y-n.y,s=180*Math.atan2(o,r)/Math.PI;Math.abs(90-Math.abs(s))<30?this.fingerDirection="vertical":this.fingerDirection="horizontal";this.addTouchEndTask("resetFingerDirection",{priority:1,callback:function(){t.fingerDirection=""}})},t.prototype.destroy=function(){this.ref.parentNode.removeChild(this.ref),window.removeEventListener("resize",this.handleResize),window.removeEventListener("orientationchange",this.handleResize)},t.prototype.testEnv=function(){return/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)?"mobile":"pc"},t=P([r],t)}();E=S,[o,s,l].forEach((function(t){Object.getOwnPropertyNames(t.prototype).forEach((function(e){E.prototype[e]=t.prototype[e]}))}));export{S as ImagePreview}; +var t,e=(t=function(e,i){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(e,i)},function(e,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}),i=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},n=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]0?(h=-(i-s)*u,a=-(e-o)*u,l=1+u,c=1+u):(h=(i-s)*u,a=(e-o)*u,l=1-u,c=1-u),r.eventsHanlder.handleZoom(l,c,a,h),this.isZooming=!1,this.isAnimating=!1,this.actionExecutor.isEnlargement?this.ref.style.cursor="grab":this.ref.style.cursor="initial",[2]}))}))},r.prototype.handlePCDoubleClick=function(t){return i(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return this.isAnimating?[2]:(this.isAnimating=!0,[4,this.actionExecutor.eventsHanlder.handleDoubleClick({clientX:t.clientX,clientY:t.clientY})]);case 1:return e.sent(),this.isAnimating=!1,this.actionExecutor.isEnlargement?this.ref.style.cursor="grab":this.ref.style.cursor="initial",[2]}}))}))},r.prototype.handleMouseDown=function(t){var e=this,i=t.target.dataset.type;this[i]?this[i](t):(this.mouseDown=!0,this.actionExecutor.isEnlargement?(this.startX=t.clientX,this.startY=t.clientY,this.ref.style.cursor="grabbing"):this.ref.style.cursor="initial",Date.now()-this.lastClick0?"right":"left",s=this.actionExecutor.viewRect,a=s.left,h=s.right,l=this.actionExecutor.viewWidth/this.actionExecutor.dpr;if(this.fingerDirection)if(this.actionExecutor.isEnlargement)if(a>=0&&h<=l)if("right"!=o&&"left"!=o&&!this.isEnlargeMove||"horizontal"!=this.fingerDirection)this.handleMoveEnlage(t);else{this.isEnlargeMove=!0,this.handleMoveNormal(t);var c="resetEnlargeMove";this.addTouchEndTask(c,{priority:1,callback:function(){e.isEnlargeMove=!1}})}else if(i&&"right"==o||n&&"left"==o||this.isEnlargeMove){this.isEnlargeMove=!0,this.handleMoveNormal(t);c="resetEnlargeMove";this.addTouchEndTask(c,{priority:1,callback:function(){return e.isEnlargeMove=!1}})}else this.handleMoveEnlage(t);else this.handleMoveNormal(t);else{if(this.actionExecutor.isEnlargement&&(a<0||h>l)||!this.actionExecutor.isEnlargement)return void(!this.actionExecutor.isEnlargement||r||this.normalMoved?this.actionExecutor.isEnlargement?(r||this.normalMoved)&&(this.normalMoved?this.handleMoveNormal(t):"right"==o?i?this.handleMoveNormal(t):this.handleMoveEnlage(t):"left"==o&&n?this.handleMoveNormal(t):this.handleMoveEnlage(t)):this.handleMoveNormal(t):this.handleMoveEnlage(t));if(this.getMovePoints(t),this.movePoints.lengthn?p:0,s=Math.round(c)<0||Math.round(u)>r?g:0,e.eventsHanlder.handleMoveEnlage(a,s,0);this.addTouchEndTask("handleTendEnlarte",{priority:10,callback:this.handleTEndEnlarge.bind(this)}),this.startX=d,this.startY=f}},t.prototype.autoMove=function(t,e,i,n){var r=n.maxTop,o=n.minTop,s=n.maxLeft,a=n.minLeft,h=this.imgContainer.getBoundingClientRect(),l=h.width,c=h.height,u=this.actionExecutor,d=u.viewRect,f=u.eventsHanlder,p=d,g=p.top,v=p.bottom,m=p.left,w=p.right;t=t/180*Math.PI;var x=e+300*Math.cos(t),y=i+300*Math.sin(t);x>s?x=s:xr?y=r:y=0&&w<=l||(M=x-e),g>=0&&v<=c||(b=y-i),f.moveCurPlaneTo(M,b,0)},t}(),s=function(){function t(){}return t.prototype.handleZoom=function(t){if(!(this.isNormalMove&&this.normalMoved||this.isAnimating||this.actionExecutor.isLoadingError())){this.isZooming||(this.curStartPoint1={x:this.curPoint1.x,y:this.curPoint1.y},this.curStartPoint2={x:this.curPoint2.x,y:this.curPoint2.y}),this.isZooming=!0,this.isAnimating=!0;var e=this.actionExecutor,i=Math.pow(this.curPoint1.x-this.curPoint2.x,2)+Math.pow(this.curPoint1.y-this.curPoint2.y,2),n=Math.pow(t.touches[0].clientX-t.touches[1].clientX,2)+Math.pow(t.touches[0].clientY-t.touches[1].clientY,2),r=(this.curStartPoint1.x+this.curStartPoint2.x)/2,o=(this.curStartPoint1.y+this.curStartPoint2.y)/2,s=e.viewWidth/(2*e.dpr),a=e.viewHeight/(2*e.dpr);this.curPoint1.x=t.touches[0].clientX,this.curPoint1.y=t.touches[0].clientY,this.curPoint2.x=t.touches[1].clientX,this.curPoint2.y=t.touches[1].clientY;var h=0,l=0,c=1,u=1;if(i>n)l=(o-a)*this.zoomScale,h=(r-s)*this.zoomScale,c=1-this.zoomScale,u=1-this.zoomScale;else{if(!(i0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]d;){if(i=this.getX(r)-t,Math.abs(i)0?u=r:d=r,r=(u+d)/2}return r},t.prototype.solve=function(t){return this.cachedY.get(t)||this.cachedY.set(t,this.getY(this.solveCurveX(t))),this.cachedY.get(t)},t}(),f=new d(0,0,1,1);new d(.25,.1,.25,1),new d(.42,0,1,1),new d(0,0,.58,1),new d(.42,0,.58,1);var p=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},g=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]4*s||(l*t=this.throldDeg?(o=t.curIndex,-1!=(s=t.curIndex+1*r)&&s!=t.imgUrls.length?[3,2]:(t.curIndex=o,[4,t.rotate(-n)])):[3,6];case 1:return a.sent(),[3,5];case 2:return[4,t.rotate(r*Math.PI/2-n)];case 3:return a.sent(),t.curIndex=s,t.modelMatrix=t.baseModel=t.initialModel,t.gl.uniformMatrix4fv(t.gl.getUniformLocation(t.shaderProgram,"uModelViewMatrix"),!1,t.modelMatrix),[4,t.draw(s)];case 4:a.sent(),a.label=5;case 5:return[3,8];case 6:return[4,t.rotate(-n)];case 7:a.sent(),a.label=8;case 8:return t.modelMatrix=t.baseModel=t.initialModel,[2,"handled"]}}))}))},t.prototype.handleTEndEnlarge=function(t,e,i,n){return p(this,void 0,void 0,(function(){var t;return g(this,(function(n){switch(n.label){case 0:return t=this.viewInstance,e*=t.dpr,i*=-t.dpr,t.dpr,this.curBehaviorCanBreak=!0,[4,t.moveCurPlane(e,i,0)];case 1:return n.sent(),this.curBehaviorCanBreak=!1,0!==e&&(t.isBoudriedSide=!0),[2]}}))}))},t.prototype.moveCurPlaneTo=function(t,e,i){return p(this,void 0,void 0,(function(){var i;return g(this,(function(n){switch(n.label){case 0:return i=this.viewInstance,t*=i.dpr,e*=-i.dpr,i.dpr,this.curBehaviorCanBreak=!0,[4,i.moveCurPlane(t,e,0)];case 1:return n.sent(),this.curBehaviorCanBreak=!1,[2]}}))}))},t}();var m=function(t,e,i){var n=t.naturalWidth,r=t.naturalHeight,o=document.createElement("canvas"),s=o.getContext("2d"),a=window.devicePixelRatio||1;return o.width=e*a,o.height=i*a,s.drawImage(t,0,0,n,r,0,0,e*a,i*a),o},w=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},x=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]n&&(e=n-1,r=n),this.imgUrls.splice(e+1,0,t),e+1>this.imgs.length?this.imgs[r]=null:this.imgs.splice(e+1,0,null),t instanceof Image)if(void 0===t._id&&(t._id=this.imgId++),t.complete)this.imgUrls[e+1]=this.validateImg(t);else{var o=function(){var e=i.imgUrls.indexOf(t);t.loadError=!0,~[-2,-1,0].indexOf(e-i.curIndex)&&i.draw(i.curIndex)};t.addEventListener("load",(function(){var e=i.imgUrls.indexOf(t);i.imgUrls[e]=i.validateImg(t),~[-2,-1,0].indexOf(e-i.curIndex)&&i.draw(i.curIndex)})),t.addEventListener("error",o),t.addEventListener("abort",o)}~[-2,-1,0].indexOf(e-this.curIndex)&&this.draw(this.curIndex)},t.prototype.delImg=function(t){var e=this.imgUrls.length;t<=-1?t=0:t>=e&&(t=e-1),this.imgUrls.splice(t,1),this.imgs[t]&&this.textures.delete(this.imgs[t]._id),this.imgs.splice(t,1),t-=this.curIndex,~[-1,0,1].indexOf(t)&&this.draw(this.curIndex)},t.prototype.initOtherTexture=function(){var t=this,e=this.gl,i=e.createTexture();this.texturesOther.set(0,i),e.bindTexture(e.TEXTURE_2D,i),i.cubicBgd=!0;e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,new Uint8Array([0,0,0,255]));var n=new Image;n.onload=function(){var i=e.createTexture();t.texturesOther.set(1,i),e.bindTexture(e.TEXTURE_2D,i),t.texImage(n),t.setTexParameteri(n.width,n.height)},n.src="data:image/svg+xml;base64,PHN2ZyB0PSIxNjI1ODExNDgwNTgyIiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEzNDIgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjYwNjkiIHdpZHRoPSIyMDAiIGhlaWdodD0iMjAwIj48cGF0aCBkPSJNMTIxNi4zNTcgMTM5LjAzYy0xMC4xNTctMTEuNDI3LTI0Ljc1OS0xNy43NzUtMzkuOTk1LTE4LjQxTDc0My40IDEwMy40OGwtMzIuMzc3IDczLjAwNiA0NS4wNzQgMTM1Ljg1Ni04MS4yNiAxNTQuMjY3IDMzLjAxMiAxMjQuNDI5IDgyLjUzIDEwNi42NTMgMTE5LjM1LTEwOS44MjdjMTEuNDI3LTEwLjc5MyAyOS44MzctMTAuMTU4IDM5Ljk5NCAxLjkwNGwxNTIuOTk3IDE2NS42OTRjMTAuNzkzIDExLjQyNyAxMC4xNTggMjkuODM3LTEuMjcgNDAuNjMtNS43MTMgNS4wNzgtMTIuNjk2IDguMjUzLTIwLjMxNCA3LjYxOGwtNDE5LjYzLTE2LjUwNi0yMC45NSA2MC4zMSAyMi44NTQgNTMuOTYyIDQ4Mi40OCAxOC40MWMzMS43NDIgMS4yNyA1OC40MDUtMjMuNDkgNTkuMDQtNTUuMjMxbDI2LjY2My02ODQuMzZjMC42MzUtMTUuMjM2LTQuNDQ0LTMwLjQ3Mi0xNS4yMzYtNDEuMjY1ek05MDYuNTU0IDQ1My4yNzdjLTQ3LjYxMy0xLjkwNC04NC40MzQtNDEuOS04Mi41My04OC44NzggMS45MDUtNDcuNjEzIDQxLjktODQuNDM0IDg4Ljg3OS04Mi41MyA0Ni45NzggMS45MDUgODQuNDM0IDQxLjkgODIuNTMgODguODc5LTEuOTA1IDQ2Ljk3OC00MS45IDg0LjQzNC04OC44NzkgODIuNTN6TTU5NS40ODIgODQ4LjE1bDE0LjYwMS02My40ODQtMzQwLjkxIDIzLjQ4OWMtMTUuODcxIDEuMjctMjkuMjAzLTEwLjE1OC0zMC40NzItMjYuMDI5YTI4LjEyIDI4LjEyIDAgMCAxIDYuOTgzLTIwLjk1TDQ5OC4zNSA0NzEuMDUzYzUuMDc5LTYuMzQ5IDEyLjY5Ny05LjUyMyAyMC45NS05LjUyMyA3LjYxOCAwIDE1LjIzNiAzLjE3NCAyMC45NSA4Ljg4OGw4NC40MzMgODguMjQzLTM2LjE4Ni05My45NTcgNjQuNzU0LTE2Mi41Mi01OS4wNC0xMzAuMTQyIDI0LjEyNC03NC45MTEtNDY0LjcwNCAzMi4zNzdjLTMxLjc0MiAxLjkwNC01NS4yMzIgMjkuMjAyLTUzLjMyNyA2MC45NDVsNDYuOTc4IDY4NC4zNmMwLjYzNSAxNS4yMzUgNy42MTggMjkuMjAyIDE5LjY4IDM4LjcyNSAxMS40MjggMTAuMTU3IDI2LjAyOSAxNS4yMzYgNDEuMjY1IDEzLjk2Nmw0MTUuMTg3LTI4LjU2OC0yNy45MzMtNTAuNzg3eiIgcC1pZD0iNjA3MCIgZmlsbD0iI2JmYmZiZiIvPjwvc3ZnPg=="},t.prototype.initData=function(){this.draw(this.curIndex)},t.prototype.slideNext=function(){return w(this,void 0,void 0,(function(){var t=this;return x(this,(function(e){return this.curIndex==this.imgUrls.length-1?[2,[!0]]:[2,this.slide(.5*Math.PI,(function(){return t.curIndex++}))]}))}))},t.prototype.slideBefore=function(){return w(this,void 0,void 0,(function(){var t=this;return x(this,(function(e){return 0==this.curIndex?[2,[!0]]:[2,this.slide(-.5*Math.PI,(function(){return t.curIndex--}))]}))}))},t.prototype.slide=function(t,e){return w(this,void 0,void 0,(function(){return x(this,(function(i){switch(i.label){case 0:return this.baseModel=this.modelMatrix,[4,this.rotate(t)];case 1:return i.sent(),e(),this.modelMatrix=this.baseModel=this.initialModel,this.gl.uniformMatrix4fv(this.gl.getUniformLocation(this.shaderProgram,"uModelViewMatrix"),!1,this.modelMatrix),[4,this.draw(this.curIndex)];case 2:return i.sent(),this.modelMatrix=this.baseModel=this.initialModel,[2,[!1]]}}))}))},t.prototype.rotate=function(t){var e,i=this;return this.animate({allTime:this.defaultAnimateTime,timingFun:f,ends:[t],playGame:(e=i.rotatePosition.bind(i),function(t){i.clear(),e(t)})})},t.prototype.rotateZ=function(t){var e=this;this.curPlane=this.positions.slice(this.curPointAt,this.curPointAt+16);var i=this.imgShape,n=this.imgShapeInitinal;this.imgShape=u.multiplyPoint(i,u.rotateZMatrix(t)),this.imgShapeInitinal=u.multiplyPoint(n,u.rotateZMatrix(t));var r=this.curCenterCoordinate,o=-r[0],s=-r[1];return this.animate({allTime:this.defaultAnimateTime,timingFun:f,ends:[t,o,s],playGame:function(){for(var t=[],i=0;ic?c:this.viewWidth):(i=c,n=u),p=-(t-r)*(d=i/a-1),g=(e-o)*(f=n/h-1),this.curIsLongImg()&&(p=0);return[d,f,p,g]},t.prototype.decideImgViewSize=function(t,e){var i=0,n=0;return(n=e/t*(i=this.viewWidth>=t?t:this.viewWidth))>this.viewHeight&&(i=(n=this.viewHeight)*t/e),[i,n]},t.prototype.draw=function(t){this.positions=[];for(var e=this.imgUrls.length,i=0,n=0,r=t-1;r<=t+1;r++)if(-1!==r&&r<=e-1){var o=void 0;this.imgs[r]?o=this.imgs[r]:"string"==typeof this.imgUrls[r]?o=this.loadImage(this.imgUrls[r],r):void 0===(o=this.imgUrls[r])._id&&(this.imgUrls[r]=this.validateImg(o),o=this.imgUrls[r]),this.imgs[r]=o;var s=o.naturalWidth,a=o.naturalHeight;o.loadError&&(s=a=200);var h=this.decideImgViewSize(s*this.dpr,a*this.dpr),l=h[0],c=h[1];r==this.curIndex&&(this.imgShape=[s*this.dpr,a*this.dpr,0,1],this.imgShapeInitinal=[l,c,0,1]),this.genPostion(l,c,r),i=Math.max(l,i),n=Math.max(c,n)}this.generateCube(i,n),this.bindPostion(),this.drawPosition()},t.prototype.createPerspectiveMatrix=function(){var t=this.fieldOfViewInRadians,e=this.viewWidth/this.viewHeight,i=this.zNear,n=this.zFar,r=1/Math.tan(t/2),o=1/(i-n);return[r/e,0,0,0,0,r,0,0,0,0,(i+n)*o,-1,0,0,i*n*o*2,0]},Object.defineProperty(t.prototype,"curPointAt",{get:function(){var t=64;return 0==this.curIndex&&(t=48),t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"IsBoundaryLeft",{get:function(){var t=this.viewRect;return Math.round(t.left)>=0&&this.isBoudriedSide},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isBoundaryRight",{get:function(){var t=this.viewRect;return Math.round(t.right*this.dpr)<=Math.round(this.viewWidth/1)&&this.isBoudriedSide},enumerable:!1,configurable:!0}),t.prototype.curIsLongImg=function(){var t=this.imgShape,e=t[0],i=t[1];return 2*Math.abs(e)<=Math.abs(i)},Object.defineProperty(t.prototype,"curCenterCoordinate",{get:function(){var t=this.curPointAt;return[(this.positions[t]+this.positions[t+8])/2,(this.positions[t+1]+this.positions[t+9])/2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"viewRect",{get:function(){for(var t=-this.viewWidth/2,e=this.viewHeight/2,i=this.curPointAt,n=1/0,r=-1/0,o=1/0,s=-1/0,a=i;athis.viewWidth||e.height*this.dpr-1>this.viewHeight},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isEnlargementForScale",{get:function(){var t=this.imgShapeInitinal,e=t[0],i=t[1],n=this.viewRect;return Math.round(n.width*this.dpr)>Math.round(Math.abs(e))||Math.round(n.height*this.dpr)>Math.round(Math.abs(i))},enumerable:!1,configurable:!0}),t.prototype.isLoadingError=function(t){return 0==arguments.length&&(t=this.curIndex),this.imgs[t].loadError},t.prototype.loadImage=function(t,e){var i=this,n=new Image;return n._id=this.imgId++,this.imgs[e]=n,n.onload=function(){i.handleImgLoaded(n,e)},n.onerror=function(){n.loadError=!0,i.handleImgLoaded(n,e)},n.onabort=function(){n.loadError=!0,i.handleImgLoaded(n,e)},n.crossOrigin="anonymous",n.src=t,n},t.prototype.handleImgLoaded=function(t,e){e=this.imgs.indexOf(t),t.loadError||(t=this.validateImg(t),this.imgs[e]=t),~[-1,0,1].indexOf(e-this.curIndex)&&(this.updatePosition(t,e-this.curIndex),this.bindPostion(),this.drawPosition())},t.prototype.validateImg=function(t){var e=this.gl.MAX_TEXTURE_SIZE,i=t.naturalWidth,n=t.naturalHeight;if(Math.max(n,i)>=e){var r=this.dpr,o=e/r,s=n/i*o;s>=e&&(o=i/n*(s=e/r));var a=m(t,o,s);return a._id=this.imgId++,a.naturalHeight=s,a.naturalWidth=o,a.complete=!0,a}return t},t.prototype.clear=function(){var t=this.gl;t.clearColor(0,0,0,1),t.clearDepth(1),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT)},t.prototype.bindShader=function(t,e,i){var n=this.loadShader(t,t.VERTEX_SHADER,i),r=this.loadShader(t,t.FRAGMENT_SHADER,e),o=t.createProgram();return t.attachShader(o,n),t.attachShader(o,r),t.linkProgram(o),t.getProgramParameter(o,t.LINK_STATUS)?o:(console.error("Unable to initialize the shader program: "+t.getProgramInfoLog(o)),null)},t.prototype.loadShader=function(t,e,i){var n=t.createShader(e);return t.shaderSource(n,i),t.compileShader(n),t.getShaderParameter(n,t.COMPILE_STATUS)?n:(console.error("An error occurred compiling the shaders: "+t.getShaderInfoLog(n)),t.deleteShader(n),null)},t.prototype.createPlane=function(t){return t.x,t.y,t.width,t.height,{}},t.prototype.intialView=function(){var t=document.createElement("canvas");t.style.cssText="\n position: absolute;\n top: 0;\n left:0;\n z-index: 9;\n width:"+window.innerWidth+"px;\n height:"+window.innerHeight+"px;\n user-select:none;\n font-size:0;\n ",t.width=window.innerWidth*this.dpr,t.height=window.innerHeight*this.dpr,this.ref=t;var e=t.getContext("webgl",{antialias:!0});return e||console.error("webgl is not supported. please use before version."),this.viewWidth=t.width,this.viewHeight=t.height,e},t.prototype.animate=function(t){var e,i=this,n=t.allTime,r=t.timingFun,o=t.ends,s=t.playGame,a=t.callback,h=Date.now(),l=h,c=new Promise((function(t){return e=t})),u=o.length,d=function(){if(i.curAimateBreaked)return e([!1,3]),void(i.curAimateBreaked=!1);var t=l-h;t>n&&(t=n);var c=t/n;c>1&&(c=1);var f=r.solve(c);f>=1&&(f=1);var p=new Array(u);o.forEach((function(t,e){p[e]=t*f})),s.apply(void 0,p),c<1?requestAnimationFrame(d):(a&&a(),e([!1,1])),l=Date.now()};return d(),c},t}(),P=function(t,e,i,n){var r,o=arguments.length,s=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(s=(o<3?r(s):o>3?r(e,i,s):r(e,i))||s);return o>3&&s&&Object.defineProperty(e,i,s),s},I=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},A=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]d?(w=d-g,m=!0):gc?(x=c-p,v=!0):p=0&&l<=n&&(m=!1,w=0),s<=r&&(v=!1,x=0),m||v?(this.isAnimating=!0,[4,e.eventsHanlder.handleTEndEnlarge(t,w,x,0)]):[3,2];case 1:return I.sent(),this.isAnimating=!1,[3,4];case 2:return this.moveEndTime=Date.now(),y={x:this.startX,y:this.startY},M={x:this.touchStartX,y:this.touchStartY},b=y.x-M.x,E=y.y-M.y,T=180*Math.atan2(E,b)/Math.PI,this.moveEndTime-this.moveStartTime<90&&Math.abs(b)+Math.abs(E)>5?(P={maxTop:c,minTop:u,maxLeft:d,minLeft:n-o},this.isAnimating=!0,[4,this.autoMove(T,h,a,P)]):[3,4];case 3:I.sent(),this.isAnimating=!1,I.label=4;case 4:return this.moveStartTime=0,[2]}}))}))},t.prototype.handleTEndEnNormal=function(t){return I(this,void 0,void 0,(function(){var e,i,n;return A(this,(function(r){switch(r.label){case 0:return this.isAnimating?[2]:(e=t.changedTouches[0].clientX,i=this.actionExecutor.eventsHanlder,0===(n=e-this.touchStartX)?[2]:(this.isAnimating=!0,[4,i.handleTEndEnNormal(t,n)]));case 1:return r.sent(),this.isAnimating=!1,[2]}}))}))},t.prototype.genFrame=function(){var t=this,e=this.options.imgs;!e||e.length,this.imgsNumber=e.length,this.curIndex=0;var i='\n
\n \n \n \n \n
\n
\n
\n '+("pc"==this.envClient?'
\n \n
\n
\n \n
':"")+'\n
\n \n
\n
\n \n
\n
\n ',n=/iphone/gi.test(window.navigator.userAgent)&&window.devicePixelRatio&&3===window.devicePixelRatio&&375===window.screen.width&&812===window.screen.height,r=/iphone/gi.test(window.navigator.userAgent)&&window.devicePixelRatio&&3===window.devicePixelRatio&&414===window.screen.width&&896===window.screen.height,o=/iphone/gi.test(window.navigator.userAgent)&&window.devicePixelRatio&&2===window.devicePixelRatio&&414===window.screen.width&&896===window.screen.height,s=n||r||o,a="\n ."+this.prefix+"imagePreviewer{\n position: fixed;\n top:0;\n left: 100%;\n width: 100%;\n height: 100%;\n background: "+function(e){switch(e){case"conBackground":return"pc"==t.envClient?"rgba(0,0,0,0.8)":"rgba(0,0,0,1)";case"imgWidth":return t.envClient,"100%";case"itemHeight":return"pc"==t.envClient?"100%":"auto";case"itemScroll":return"pc"==t.envClient?"auto ":"hidden";case"item-text-align":return"pc"==t.envClient?"center ":"initial";default:return""}}("conBackground")+";\n color:#fff;\n transform: translate3d(0,0,0);\n transition: left 0.5s;\n overflow:hidden;\n user-select: none;\n }\n \n ."+this.prefix+"imagePreviewer."+this.defToggleClass+"{\n left: 0%;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"close{\n position: absolute;\n top: 20px;\n right: 20px;\n z-index: 10;\n box-sizing: border-box;\n width: 22px;\n height: 22px;\n cursor:pointer;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"close svg{\n width: 100%;\n height: 100%; \n }\n ."+this.prefix+"imagePreviewer svg{\n overflow:visible;\n }\n ."+this.prefix+"imagePreviewer svg path{\n stroke: #948888;\n stroke-width: 30px;\n }\n \n ."+this.prefix+"imagePreviewer "+this.prefix+".close."+this.prefix+"scroll{\n height: 0;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"imgContainer{\n position: relative;\n height: 100%;\n font-size: 0;\n white-space: nowrap;\n }\n \n ."+this.prefix+"imagePreviewer ."+this.prefix+"bottom{\n position: absolute;\n bottom: "+(s?20:0)+"px;\n left: 20px;\n right: 20px;\n z-index: 10;\n padding: 0 10px;\n text-align: center;\n border-top: 1px solid rgba(255, 255, 255, .2);\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"bottom ."+this.prefix+"item{\n display:inline-block;\n width: 42px;\n height: 42px;\n cursor:pointer;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"bottom ."+this.prefix+"item svg{\n box-sizing: border-box;\n width: 100%;\n height: 100%;\n padding:10px;\n }\n ";if(this.ref=document.createElement("div"),this.ref.className=this.prefix+"imagePreviewer",this.ref.innerHTML=i,!document.querySelector("#"+this.prefix+"style")){var h=document.createElement("style");h.id=this.prefix+"style",h.innerHTML=a,document.querySelector("head").appendChild(h)}this.ref.querySelector("."+this.prefix+"imgContainer").append(this.actionExecutor.ref),document.body.appendChild(this.ref)},t.prototype.handleReausetAnimate=function(){window.requestAnimationFrame||(window.requestAnimationFrame=window.webkitRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60),0})},t.prototype.close=function(t){t.stopImmediatePropagation(),clearTimeout(this.performerClick),this[this.envClient+"BeforeClose"](),this.toggleClass(this.ref,this.defToggleClass)},t.prototype.pcBeforeClose=function(){document.body.style.overflow=document.body.dataset.imgPreOverflow},t.prototype.mobileBeforeClose=function(){},t.prototype.show=function(t){this.actionExecutor.curIndex=t,this.actionExecutor.draw(t),this.toggleClass(this.ref,this.defToggleClass)},t.prototype.mobileReadyShow=function(){},t.prototype.pcReadyShow=function(){var t=window.getComputedStyle(document.body);document.body.dataset.imgPreOverflow=t.overflow,document.body.style.overflow="hidden"},t.prototype.toggleClass=function(t,e){var i=t.className.split(" "),n=i.indexOf(e);-1!==n?i.splice(n,1):i.push(e),t.className=i.join(" ")},t.prototype.getMovePoints=function(t){var e=this;if(!(this.movePoints.length>this.maxMovePointCounts)){this.movePoints.push({x:t.touches[0].clientX,y:t.touches[0].clientY});this.addTouchEndTask("resetMovePoints",{priority:1,callback:function(){return e.movePoints=[]}})}},t.prototype.decideMoveDirection=function(){var t=this,e=this.movePoints.length,i=this.movePoints[e-1],n=this.movePoints[0],r=i.x-n.x,o=i.y-n.y,s=180*Math.atan2(o,r)/Math.PI;Math.abs(90-Math.abs(s))<30?this.fingerDirection="vertical":this.fingerDirection="horizontal";this.addTouchEndTask("resetFingerDirection",{priority:1,callback:function(){t.fingerDirection=""}})},t.prototype.destroy=function(){this.ref.parentNode.removeChild(this.ref),window.removeEventListener("resize",this.handleResize),window.removeEventListener("orientationchange",this.handleResize)},t.prototype.testEnv=function(){return/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)?"mobile":"pc"},t=P([r],t)}();E=S,[o,s,l].forEach((function(t){Object.getOwnPropertyNames(t.prototype).forEach((function(e){E.prototype[e]=t.prototype[e]}))}));export{S as ImagePreview}; diff --git a/release/image-preview/image-preview-esm.js b/release/image-preview/image-preview-esm.js index cc0ea65..225c548 100644 --- a/release/image-preview/image-preview-esm.js +++ b/release/image-preview/image-preview-esm.js @@ -762,6 +762,7 @@ var matrix = { var cubicBezier = (function () { function cubicBezier(x1, y1, x2, y2) { + this.cachedY = new Map(); this.precision = 1e-5; this.p1 = { x: x1, @@ -821,7 +822,10 @@ var cubicBezier = (function () { return t2; }; cubicBezier.prototype.solve = function (x) { - return this.getY(this.solveCurveX(x)); + if (!this.cachedY.get(x)) { + this.cachedY.set(x, this.getY(this.solveCurveX(x))); + } + return this.cachedY.get(x); }; return cubicBezier; }()); @@ -1339,7 +1343,8 @@ var webGl = (function () { }; webGl.prototype.genPostion = function (width, height, index) { var _a; - var z = -(this.viewHeight) / (2 * Math.tan(this.fieldOfViewInRadians / 2)) - forDev; + var zNearHeight = (2 * Math.tan(this.fieldOfViewInRadians / 2)); + var z = -(this.viewHeight) / (zNearHeight) - forDev; var viewWidth = this.viewWidth; var sideZAxis = z - (viewWidth - width) / 2; var positionsMap = [ diff --git a/release/image-preview/image-preview-iife-min.js b/release/image-preview/image-preview-iife-min.js index 903c11b..a33a8c2 100644 --- a/release/image-preview/image-preview-iife-min.js +++ b/release/image-preview/image-preview-iife-min.js @@ -1 +1 @@ -var imagePreviewModule=function(t){"use strict";var e,i=(e=function(t,i){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(t,i)},function(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}),n=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},r=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]0?(h=-(i-s)*u,a=-(e-o)*u,l=1+u,c=1+u):(h=(i-s)*u,a=(e-o)*u,l=1-u,c=1-u),n.eventsHanlder.handleZoom(l,c,a,h),this.isZooming=!1,this.isAnimating=!1,this.actionExecutor.isEnlargement?this.ref.style.cursor="grab":this.ref.style.cursor="initial",[2]}))}))},e.prototype.handlePCDoubleClick=function(t){return n(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return this.isAnimating?[2]:(this.isAnimating=!0,[4,this.actionExecutor.eventsHanlder.handleDoubleClick({clientX:t.clientX,clientY:t.clientY})]);case 1:return e.sent(),this.isAnimating=!1,this.actionExecutor.isEnlargement?this.ref.style.cursor="grab":this.ref.style.cursor="initial",[2]}}))}))},e.prototype.handleMouseDown=function(t){var e=this,i=t.target.dataset.type;this[i]?this[i](t):(this.mouseDown=!0,this.actionExecutor.isEnlargement?(this.startX=t.clientX,this.startY=t.clientY,this.ref.style.cursor="grabbing"):this.ref.style.cursor="initial",Date.now()-this.lastClick0?"right":"left",s=this.actionExecutor.viewRect,a=s.left,h=s.right,l=this.actionExecutor.viewWidth/this.actionExecutor.dpr;if(this.fingerDirection)if(this.actionExecutor.isEnlargement)if(a>=0&&h<=l)if("right"!=o&&"left"!=o&&!this.isEnlargeMove||"horizontal"!=this.fingerDirection)this.handleMoveEnlage(t);else{this.isEnlargeMove=!0,this.handleMoveNormal(t);var c="resetEnlargeMove";this.addTouchEndTask(c,{priority:1,callback:function(){e.isEnlargeMove=!1}})}else if(i&&"right"==o||n&&"left"==o||this.isEnlargeMove){this.isEnlargeMove=!0,this.handleMoveNormal(t);c="resetEnlargeMove";this.addTouchEndTask(c,{priority:1,callback:function(){return e.isEnlargeMove=!1}})}else this.handleMoveEnlage(t);else this.handleMoveNormal(t);else{if(this.actionExecutor.isEnlargement&&(a<0||h>l)||!this.actionExecutor.isEnlargement)return void(!this.actionExecutor.isEnlargement||r||this.normalMoved?this.actionExecutor.isEnlargement?(r||this.normalMoved)&&(this.normalMoved?this.handleMoveNormal(t):"right"==o?i?this.handleMoveNormal(t):this.handleMoveEnlage(t):"left"==o&&n?this.handleMoveNormal(t):this.handleMoveEnlage(t)):this.handleMoveNormal(t):this.handleMoveEnlage(t));if(this.getMovePoints(t),this.movePoints.lengthn?p:0,s=Math.round(c)<0||Math.round(u)>r?g:0,e.eventsHanlder.handleMoveEnlage(a,s,0);this.addTouchEndTask("handleTendEnlarte",{priority:10,callback:this.handleTEndEnlarge.bind(this)}),this.startX=d,this.startY=f}},t.prototype.autoMove=function(t,e,i,n){var r=n.maxTop,o=n.minTop,s=n.maxLeft,a=n.minLeft,h=this.imgContainer.getBoundingClientRect(),l=h.width,c=h.height,u=this.actionExecutor,d=u.viewRect,f=u.eventsHanlder,p=d,g=p.top,v=p.bottom,m=p.left,w=p.right;t=t/180*Math.PI;var x=e+300*Math.cos(t),y=i+300*Math.sin(t);x>s?x=s:xr?y=r:y=0&&w<=l||(M=x-e),g>=0&&v<=c||(b=y-i),f.moveCurPlaneTo(M,b,0)},t}(),a=function(){function t(){}return t.prototype.handleZoom=function(t){if(!(this.isNormalMove&&this.normalMoved||this.isAnimating||this.actionExecutor.isLoadingError())){this.isZooming||(this.curStartPoint1={x:this.curPoint1.x,y:this.curPoint1.y},this.curStartPoint2={x:this.curPoint2.x,y:this.curPoint2.y}),this.isZooming=!0,this.isAnimating=!0;var e=this.actionExecutor,i=Math.pow(this.curPoint1.x-this.curPoint2.x,2)+Math.pow(this.curPoint1.y-this.curPoint2.y,2),n=Math.pow(t.touches[0].clientX-t.touches[1].clientX,2)+Math.pow(t.touches[0].clientY-t.touches[1].clientY,2),r=(this.curStartPoint1.x+this.curStartPoint2.x)/2,o=(this.curStartPoint1.y+this.curStartPoint2.y)/2,s=e.viewWidth/(2*e.dpr),a=e.viewHeight/(2*e.dpr);this.curPoint1.x=t.touches[0].clientX,this.curPoint1.y=t.touches[0].clientY,this.curPoint2.x=t.touches[1].clientX,this.curPoint2.y=t.touches[1].clientY;var h=0,l=0,c=1,u=1;if(i>n)l=(o-a)*this.zoomScale,h=(r-s)*this.zoomScale,c=1-this.zoomScale,u=1-this.zoomScale;else{if(!(i0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]d;){if(i=this.getX(r)-t,Math.abs(i)0?u=r:d=r,r=(u+d)/2}return r},t.prototype.solve=function(t){return this.getY(this.solveCurveX(t))},t}(),p=new f(0,0,1,1);new f(.25,.1,.25,1),new f(.42,0,1,1),new f(0,0,.58,1),new f(.42,0,.58,1);var g=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},v=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]4*s||(l*t=this.throldDeg?(o=t.curIndex,-1!=(s=t.curIndex+1*r)&&s!=t.imgUrls.length?[3,2]:(t.curIndex=o,[4,t.rotate(-n)])):[3,6];case 1:return a.sent(),[3,5];case 2:return[4,t.rotate(r*Math.PI/2-n)];case 3:return a.sent(),t.curIndex=s,t.modelMatrix=t.baseModel=t.initialModel,t.gl.uniformMatrix4fv(t.gl.getUniformLocation(t.shaderProgram,"uModelViewMatrix"),!1,t.modelMatrix),[4,t.draw(s)];case 4:a.sent(),a.label=5;case 5:return[3,8];case 6:return[4,t.rotate(-n)];case 7:a.sent(),a.label=8;case 8:return t.modelMatrix=t.baseModel=t.initialModel,[2,"handled"]}}))}))},t.prototype.handleTEndEnlarge=function(t,e,i,n){return g(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return t=this.viewInstance,e*=t.dpr,i*=-t.dpr,t.dpr,this.curBehaviorCanBreak=!0,[4,t.moveCurPlane(e,i,0)];case 1:return n.sent(),this.curBehaviorCanBreak=!1,0!==e&&(t.isBoudriedSide=!0),[2]}}))}))},t.prototype.moveCurPlaneTo=function(t,e,i){return g(this,void 0,void 0,(function(){var i;return v(this,(function(n){switch(n.label){case 0:return i=this.viewInstance,t*=i.dpr,e*=-i.dpr,i.dpr,this.curBehaviorCanBreak=!0,[4,i.moveCurPlane(t,e,0)];case 1:return n.sent(),this.curBehaviorCanBreak=!1,[2]}}))}))},t}();var w=function(t,e,i){var n=t.naturalWidth,r=t.naturalHeight,o=document.createElement("canvas"),s=o.getContext("2d"),a=window.devicePixelRatio||1;return o.width=e*a,o.height=i*a,s.drawImage(t,0,0,n,r,0,0,e*a,i*a),o},x=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},y=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]n&&(e=n-1,r=n),this.imgUrls.splice(e+1,0,t),e+1>this.imgs.length?this.imgs[r]=null:this.imgs.splice(e+1,0,null),t instanceof Image)if(void 0===t._id&&(t._id=this.imgId++),t.complete)this.imgUrls[e+1]=this.validateImg(t);else{var o=function(){var e=i.imgUrls.indexOf(t);t.loadError=!0,~[-2,-1,0].indexOf(e-i.curIndex)&&i.draw(i.curIndex)};t.addEventListener("load",(function(){var e=i.imgUrls.indexOf(t);i.imgUrls[e]=i.validateImg(t),~[-2,-1,0].indexOf(e-i.curIndex)&&i.draw(i.curIndex)})),t.addEventListener("error",o),t.addEventListener("abort",o)}~[-2,-1,0].indexOf(e-this.curIndex)&&this.draw(this.curIndex)},t.prototype.delImg=function(t){var e=this.imgUrls.length;t<=-1?t=0:t>=e&&(t=e-1),this.imgUrls.splice(t,1),this.imgs[t]&&this.textures.delete(this.imgs[t]._id),this.imgs.splice(t,1),t-=this.curIndex,~[-1,0,1].indexOf(t)&&this.draw(this.curIndex)},t.prototype.initOtherTexture=function(){var t=this,e=this.gl,i=e.createTexture();this.texturesOther.set(0,i),e.bindTexture(e.TEXTURE_2D,i),i.cubicBgd=!0;e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,new Uint8Array([0,0,0,255]));var n=new Image;n.onload=function(){var i=e.createTexture();t.texturesOther.set(1,i),e.bindTexture(e.TEXTURE_2D,i),t.texImage(n),t.setTexParameteri(n.width,n.height)},n.src="data:image/svg+xml;base64,PHN2ZyB0PSIxNjI1ODExNDgwNTgyIiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEzNDIgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjYwNjkiIHdpZHRoPSIyMDAiIGhlaWdodD0iMjAwIj48cGF0aCBkPSJNMTIxNi4zNTcgMTM5LjAzYy0xMC4xNTctMTEuNDI3LTI0Ljc1OS0xNy43NzUtMzkuOTk1LTE4LjQxTDc0My40IDEwMy40OGwtMzIuMzc3IDczLjAwNiA0NS4wNzQgMTM1Ljg1Ni04MS4yNiAxNTQuMjY3IDMzLjAxMiAxMjQuNDI5IDgyLjUzIDEwNi42NTMgMTE5LjM1LTEwOS44MjdjMTEuNDI3LTEwLjc5MyAyOS44MzctMTAuMTU4IDM5Ljk5NCAxLjkwNGwxNTIuOTk3IDE2NS42OTRjMTAuNzkzIDExLjQyNyAxMC4xNTggMjkuODM3LTEuMjcgNDAuNjMtNS43MTMgNS4wNzgtMTIuNjk2IDguMjUzLTIwLjMxNCA3LjYxOGwtNDE5LjYzLTE2LjUwNi0yMC45NSA2MC4zMSAyMi44NTQgNTMuOTYyIDQ4Mi40OCAxOC40MWMzMS43NDIgMS4yNyA1OC40MDUtMjMuNDkgNTkuMDQtNTUuMjMxbDI2LjY2My02ODQuMzZjMC42MzUtMTUuMjM2LTQuNDQ0LTMwLjQ3Mi0xNS4yMzYtNDEuMjY1ek05MDYuNTU0IDQ1My4yNzdjLTQ3LjYxMy0xLjkwNC04NC40MzQtNDEuOS04Mi41My04OC44NzggMS45MDUtNDcuNjEzIDQxLjktODQuNDM0IDg4Ljg3OS04Mi41MyA0Ni45NzggMS45MDUgODQuNDM0IDQxLjkgODIuNTMgODguODc5LTEuOTA1IDQ2Ljk3OC00MS45IDg0LjQzNC04OC44NzkgODIuNTN6TTU5NS40ODIgODQ4LjE1bDE0LjYwMS02My40ODQtMzQwLjkxIDIzLjQ4OWMtMTUuODcxIDEuMjctMjkuMjAzLTEwLjE1OC0zMC40NzItMjYuMDI5YTI4LjEyIDI4LjEyIDAgMCAxIDYuOTgzLTIwLjk1TDQ5OC4zNSA0NzEuMDUzYzUuMDc5LTYuMzQ5IDEyLjY5Ny05LjUyMyAyMC45NS05LjUyMyA3LjYxOCAwIDE1LjIzNiAzLjE3NCAyMC45NSA4Ljg4OGw4NC40MzMgODguMjQzLTM2LjE4Ni05My45NTcgNjQuNzU0LTE2Mi41Mi01OS4wNC0xMzAuMTQyIDI0LjEyNC03NC45MTEtNDY0LjcwNCAzMi4zNzdjLTMxLjc0MiAxLjkwNC01NS4yMzIgMjkuMjAyLTUzLjMyNyA2MC45NDVsNDYuOTc4IDY4NC4zNmMwLjYzNSAxNS4yMzUgNy42MTggMjkuMjAyIDE5LjY4IDM4LjcyNSAxMS40MjggMTAuMTU3IDI2LjAyOSAxNS4yMzYgNDEuMjY1IDEzLjk2Nmw0MTUuMTg3LTI4LjU2OC0yNy45MzMtNTAuNzg3eiIgcC1pZD0iNjA3MCIgZmlsbD0iI2JmYmZiZiIvPjwvc3ZnPg=="},t.prototype.initData=function(){this.draw(this.curIndex)},t.prototype.slideNext=function(){return x(this,void 0,void 0,(function(){var t=this;return y(this,(function(e){return this.curIndex==this.imgUrls.length-1?[2,[!0]]:[2,this.slide(.5*Math.PI,(function(){return t.curIndex++}))]}))}))},t.prototype.slideBefore=function(){return x(this,void 0,void 0,(function(){var t=this;return y(this,(function(e){return 0==this.curIndex?[2,[!0]]:[2,this.slide(-.5*Math.PI,(function(){return t.curIndex--}))]}))}))},t.prototype.slide=function(t,e){return x(this,void 0,void 0,(function(){return y(this,(function(i){switch(i.label){case 0:return this.baseModel=this.modelMatrix,[4,this.rotate(t)];case 1:return i.sent(),e(),this.modelMatrix=this.baseModel=this.initialModel,this.gl.uniformMatrix4fv(this.gl.getUniformLocation(this.shaderProgram,"uModelViewMatrix"),!1,this.modelMatrix),[4,this.draw(this.curIndex)];case 2:return i.sent(),this.modelMatrix=this.baseModel=this.initialModel,[2,[!1]]}}))}))},t.prototype.rotate=function(t){var e,i=this;return this.animate({allTime:this.defaultAnimateTime,timingFun:p,ends:[t],playGame:(e=i.rotatePosition.bind(i),function(t){i.clear(),e(t)})})},t.prototype.rotateZ=function(t){var e=this;this.curPlane=this.positions.slice(this.curPointAt,this.curPointAt+16);var i=this.imgShape,n=this.imgShapeInitinal;this.imgShape=d.multiplyPoint(i,d.rotateZMatrix(t)),this.imgShapeInitinal=d.multiplyPoint(n,d.rotateZMatrix(t));var r=this.curCenterCoordinate,o=-r[0],s=-r[1];return this.animate({allTime:this.defaultAnimateTime,timingFun:p,ends:[t,o,s],playGame:function(){for(var t=[],i=0;ic?c:this.viewWidth):(i=c,n=u),p=-(t-r)*(d=i/a-1),g=(e-o)*(f=n/h-1),this.curIsLongImg()&&(p=0);return[d,f,p,g]},t.prototype.decideImgViewSize=function(t,e){var i=0,n=0;return(n=e/t*(i=this.viewWidth>=t?t:this.viewWidth))>this.viewHeight&&(i=(n=this.viewHeight)*t/e),[i,n]},t.prototype.draw=function(t){this.positions=[];for(var e=this.imgUrls.length,i=0,n=0,r=t-1;r<=t+1;r++)if(-1!==r&&r<=e-1){var o=void 0;this.imgs[r]?o=this.imgs[r]:"string"==typeof this.imgUrls[r]?o=this.loadImage(this.imgUrls[r],r):void 0===(o=this.imgUrls[r])._id&&(this.imgUrls[r]=this.validateImg(o),o=this.imgUrls[r]),this.imgs[r]=o;var s=o.naturalWidth,a=o.naturalHeight;o.loadError&&(s=a=200);var h=this.decideImgViewSize(s*this.dpr,a*this.dpr),l=h[0],c=h[1];r==this.curIndex&&(this.imgShape=[s*this.dpr,a*this.dpr,0,1],this.imgShapeInitinal=[l,c,0,1]),this.genPostion(l,c,r),i=Math.max(l,i),n=Math.max(c,n)}this.generateCube(i,n),this.bindPostion(),this.drawPosition()},t.prototype.createPerspectiveMatrix=function(){var t=this.fieldOfViewInRadians,e=this.viewWidth/this.viewHeight,i=this.zNear,n=this.zFar,r=1/Math.tan(t/2),o=1/(i-n);return[r/e,0,0,0,0,r,0,0,0,0,(i+n)*o,-1,0,0,i*n*o*2,0]},Object.defineProperty(t.prototype,"curPointAt",{get:function(){var t=64;return 0==this.curIndex&&(t=48),t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"IsBoundaryLeft",{get:function(){var t=this.viewRect;return Math.round(t.left)>=0&&this.isBoudriedSide},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isBoundaryRight",{get:function(){var t=this.viewRect;return Math.round(t.right*this.dpr)<=Math.round(this.viewWidth/1)&&this.isBoudriedSide},enumerable:!1,configurable:!0}),t.prototype.curIsLongImg=function(){var t=this.imgShape,e=t[0],i=t[1];return 2*Math.abs(e)<=Math.abs(i)},Object.defineProperty(t.prototype,"curCenterCoordinate",{get:function(){var t=this.curPointAt;return[(this.positions[t]+this.positions[t+8])/2,(this.positions[t+1]+this.positions[t+9])/2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"viewRect",{get:function(){for(var t=-this.viewWidth/2,e=this.viewHeight/2,i=this.curPointAt,n=1/0,r=-1/0,o=1/0,s=-1/0,a=i;athis.viewWidth||e.height*this.dpr-1>this.viewHeight},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isEnlargementForScale",{get:function(){var t=this.imgShapeInitinal,e=t[0],i=t[1],n=this.viewRect;return Math.round(n.width*this.dpr)>Math.round(Math.abs(e))||Math.round(n.height*this.dpr)>Math.round(Math.abs(i))},enumerable:!1,configurable:!0}),t.prototype.isLoadingError=function(t){return 0==arguments.length&&(t=this.curIndex),this.imgs[t].loadError},t.prototype.loadImage=function(t,e){var i=this,n=new Image;return n._id=this.imgId++,this.imgs[e]=n,n.onload=function(){i.handleImgLoaded(n,e)},n.onerror=function(){n.loadError=!0,i.handleImgLoaded(n,e)},n.onabort=function(){n.loadError=!0,i.handleImgLoaded(n,e)},n.crossOrigin="anonymous",n.src=t,n},t.prototype.handleImgLoaded=function(t,e){e=this.imgs.indexOf(t),t.loadError||(t=this.validateImg(t),this.imgs[e]=t),~[-1,0,1].indexOf(e-this.curIndex)&&(this.updatePosition(t,e-this.curIndex),this.bindPostion(),this.drawPosition())},t.prototype.validateImg=function(t){var e=this.gl.MAX_TEXTURE_SIZE,i=t.naturalWidth,n=t.naturalHeight;if(Math.max(n,i)>=e){var r=this.dpr,o=e/r,s=n/i*o;s>=e&&(o=i/n*(s=e/r));var a=w(t,o,s);return a._id=this.imgId++,a.naturalHeight=s,a.naturalWidth=o,a.complete=!0,a}return t},t.prototype.clear=function(){var t=this.gl;t.clearColor(0,0,0,1),t.clearDepth(1),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT)},t.prototype.bindShader=function(t,e,i){var n=this.loadShader(t,t.VERTEX_SHADER,i),r=this.loadShader(t,t.FRAGMENT_SHADER,e),o=t.createProgram();return t.attachShader(o,n),t.attachShader(o,r),t.linkProgram(o),t.getProgramParameter(o,t.LINK_STATUS)?o:(console.error("Unable to initialize the shader program: "+t.getProgramInfoLog(o)),null)},t.prototype.loadShader=function(t,e,i){var n=t.createShader(e);return t.shaderSource(n,i),t.compileShader(n),t.getShaderParameter(n,t.COMPILE_STATUS)?n:(console.error("An error occurred compiling the shaders: "+t.getShaderInfoLog(n)),t.deleteShader(n),null)},t.prototype.createPlane=function(t){return t.x,t.y,t.width,t.height,{}},t.prototype.intialView=function(){var t=document.createElement("canvas");t.style.cssText="\n position: absolute;\n top: 0;\n left:0;\n z-index: 9;\n width:"+window.innerWidth+"px;\n height:"+window.innerHeight+"px;\n user-select:none;\n font-size:0;\n ",t.width=window.innerWidth*this.dpr,t.height=window.innerHeight*this.dpr,this.ref=t;var e=t.getContext("webgl",{antialias:!0});return e||console.error("webgl is not supported. please use before version."),this.viewWidth=t.width,this.viewHeight=t.height,e},t.prototype.animate=function(t){var e,i=this,n=t.allTime,r=t.timingFun,o=t.ends,s=t.playGame,a=t.callback,h=Date.now(),l=h,c=new Promise((function(t){return e=t})),u=o.length,d=function(){if(i.curAimateBreaked)return e([!1,3]),void(i.curAimateBreaked=!1);var t=l-h;t>n&&(t=n);var c=t/n;c>1&&(c=1);var f=r.solve(c);f>=1&&(f=1);var p=new Array(u);o.forEach((function(t,e){p[e]=t*f})),s.apply(void 0,p),c<1?requestAnimationFrame(d):(a&&a(),e([!1,1])),l=Date.now()};return d(),c},t}(),I=function(t,e,i,n){var r,o=arguments.length,s=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(s=(o<3?r(s):o>3?r(e,i,s):r(e,i))||s);return o>3&&s&&Object.defineProperty(e,i,s),s},A=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},S=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]d?(w=d-g,m=!0):gc?(x=c-p,v=!0):p=0&&l<=n&&(m=!1,w=0),s<=r&&(v=!1,x=0),m||v?(this.isAnimating=!0,[4,e.eventsHanlder.handleTEndEnlarge(t,w,x,0)]):[3,2];case 1:return I.sent(),this.isAnimating=!1,[3,4];case 2:return this.moveEndTime=Date.now(),y={x:this.startX,y:this.startY},M={x:this.touchStartX,y:this.touchStartY},b=y.x-M.x,E=y.y-M.y,T=180*Math.atan2(E,b)/Math.PI,this.moveEndTime-this.moveStartTime<90&&Math.abs(b)+Math.abs(E)>5?(P={maxTop:c,minTop:u,maxLeft:d,minLeft:n-o},this.isAnimating=!0,[4,this.autoMove(T,h,a,P)]):[3,4];case 3:I.sent(),this.isAnimating=!1,I.label=4;case 4:return this.moveStartTime=0,[2]}}))}))},t.prototype.handleTEndEnNormal=function(t){return A(this,void 0,void 0,(function(){var e,i,n;return S(this,(function(r){switch(r.label){case 0:return this.isAnimating?[2]:(e=t.changedTouches[0].clientX,i=this.actionExecutor.eventsHanlder,0===(n=e-this.touchStartX)?[2]:(this.isAnimating=!0,[4,i.handleTEndEnNormal(t,n)]));case 1:return r.sent(),this.isAnimating=!1,[2]}}))}))},t.prototype.genFrame=function(){var t=this,e=this.options.imgs;!e||e.length,this.imgsNumber=e.length,this.curIndex=0;var i='\n
\n \n \n \n \n
\n
\n
\n '+("pc"==this.envClient?'
\n \n
\n
\n \n
':"")+'\n
\n \n
\n
\n \n
\n
\n ',n=/iphone/gi.test(window.navigator.userAgent)&&window.devicePixelRatio&&3===window.devicePixelRatio&&375===window.screen.width&&812===window.screen.height,r=/iphone/gi.test(window.navigator.userAgent)&&window.devicePixelRatio&&3===window.devicePixelRatio&&414===window.screen.width&&896===window.screen.height,o=/iphone/gi.test(window.navigator.userAgent)&&window.devicePixelRatio&&2===window.devicePixelRatio&&414===window.screen.width&&896===window.screen.height,s=n||r||o,a="\n ."+this.prefix+"imagePreviewer{\n position: fixed;\n top:0;\n left: 100%;\n width: 100%;\n height: 100%;\n background: "+function(e){switch(e){case"conBackground":return"pc"==t.envClient?"rgba(0,0,0,0.8)":"rgba(0,0,0,1)";case"imgWidth":return t.envClient,"100%";case"itemHeight":return"pc"==t.envClient?"100%":"auto";case"itemScroll":return"pc"==t.envClient?"auto ":"hidden";case"item-text-align":return"pc"==t.envClient?"center ":"initial";default:return""}}("conBackground")+";\n color:#fff;\n transform: translate3d(0,0,0);\n transition: left 0.5s;\n overflow:hidden;\n user-select: none;\n }\n \n ."+this.prefix+"imagePreviewer."+this.defToggleClass+"{\n left: 0%;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"close{\n position: absolute;\n top: 20px;\n right: 20px;\n z-index: 10;\n box-sizing: border-box;\n width: 22px;\n height: 22px;\n cursor:pointer;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"close svg{\n width: 100%;\n height: 100%; \n }\n ."+this.prefix+"imagePreviewer svg{\n overflow:visible;\n }\n ."+this.prefix+"imagePreviewer svg path{\n stroke: #948888;\n stroke-width: 30px;\n }\n \n ."+this.prefix+"imagePreviewer "+this.prefix+".close."+this.prefix+"scroll{\n height: 0;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"imgContainer{\n position: relative;\n height: 100%;\n font-size: 0;\n white-space: nowrap;\n }\n \n ."+this.prefix+"imagePreviewer ."+this.prefix+"bottom{\n position: absolute;\n bottom: "+(s?20:0)+"px;\n left: 20px;\n right: 20px;\n z-index: 10;\n padding: 0 10px;\n text-align: center;\n border-top: 1px solid rgba(255, 255, 255, .2);\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"bottom ."+this.prefix+"item{\n display:inline-block;\n width: 42px;\n height: 42px;\n cursor:pointer;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"bottom ."+this.prefix+"item svg{\n box-sizing: border-box;\n width: 100%;\n height: 100%;\n padding:10px;\n }\n ";if(this.ref=document.createElement("div"),this.ref.className=this.prefix+"imagePreviewer",this.ref.innerHTML=i,!document.querySelector("#"+this.prefix+"style")){var h=document.createElement("style");h.id=this.prefix+"style",h.innerHTML=a,document.querySelector("head").appendChild(h)}this.ref.querySelector("."+this.prefix+"imgContainer").append(this.actionExecutor.ref),document.body.appendChild(this.ref)},t.prototype.handleReausetAnimate=function(){window.requestAnimationFrame||(window.requestAnimationFrame=window.webkitRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60),0})},t.prototype.close=function(t){t.stopImmediatePropagation(),clearTimeout(this.performerClick),this[this.envClient+"BeforeClose"](),this.toggleClass(this.ref,this.defToggleClass)},t.prototype.pcBeforeClose=function(){document.body.style.overflow=document.body.dataset.imgPreOverflow},t.prototype.mobileBeforeClose=function(){},t.prototype.show=function(t){this.actionExecutor.curIndex=t,this.actionExecutor.draw(t),this.toggleClass(this.ref,this.defToggleClass)},t.prototype.mobileReadyShow=function(){},t.prototype.pcReadyShow=function(){var t=window.getComputedStyle(document.body);document.body.dataset.imgPreOverflow=t.overflow,document.body.style.overflow="hidden"},t.prototype.toggleClass=function(t,e){var i=t.className.split(" "),n=i.indexOf(e);-1!==n?i.splice(n,1):i.push(e),t.className=i.join(" ")},t.prototype.getMovePoints=function(t){var e=this;if(!(this.movePoints.length>this.maxMovePointCounts)){this.movePoints.push({x:t.touches[0].clientX,y:t.touches[0].clientY});this.addTouchEndTask("resetMovePoints",{priority:1,callback:function(){return e.movePoints=[]}})}},t.prototype.decideMoveDirection=function(){var t=this,e=this.movePoints.length,i=this.movePoints[e-1],n=this.movePoints[0],r=i.x-n.x,o=i.y-n.y,s=180*Math.atan2(o,r)/Math.PI;Math.abs(90-Math.abs(s))<30?this.fingerDirection="vertical":this.fingerDirection="horizontal";this.addTouchEndTask("resetFingerDirection",{priority:1,callback:function(){t.fingerDirection=""}})},t.prototype.destroy=function(){this.ref.parentNode.removeChild(this.ref),window.removeEventListener("resize",this.handleResize),window.removeEventListener("orientationchange",this.handleResize)},t.prototype.testEnv=function(){return/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)?"mobile":"pc"},t=I([o],t)}();return T=D,[s,a,c].forEach((function(t){Object.getOwnPropertyNames(t.prototype).forEach((function(e){T.prototype[e]=t.prototype[e]}))})),t.ImagePreview=D,Object.defineProperty(t,"__esModule",{value:!0}),t}({}); +var imagePreviewModule=function(t){"use strict";var e,i=(e=function(t,i){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(t,i)},function(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}),n=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},r=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]0?(h=-(i-s)*u,a=-(e-o)*u,l=1+u,c=1+u):(h=(i-s)*u,a=(e-o)*u,l=1-u,c=1-u),n.eventsHanlder.handleZoom(l,c,a,h),this.isZooming=!1,this.isAnimating=!1,this.actionExecutor.isEnlargement?this.ref.style.cursor="grab":this.ref.style.cursor="initial",[2]}))}))},e.prototype.handlePCDoubleClick=function(t){return n(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return this.isAnimating?[2]:(this.isAnimating=!0,[4,this.actionExecutor.eventsHanlder.handleDoubleClick({clientX:t.clientX,clientY:t.clientY})]);case 1:return e.sent(),this.isAnimating=!1,this.actionExecutor.isEnlargement?this.ref.style.cursor="grab":this.ref.style.cursor="initial",[2]}}))}))},e.prototype.handleMouseDown=function(t){var e=this,i=t.target.dataset.type;this[i]?this[i](t):(this.mouseDown=!0,this.actionExecutor.isEnlargement?(this.startX=t.clientX,this.startY=t.clientY,this.ref.style.cursor="grabbing"):this.ref.style.cursor="initial",Date.now()-this.lastClick0?"right":"left",s=this.actionExecutor.viewRect,a=s.left,h=s.right,l=this.actionExecutor.viewWidth/this.actionExecutor.dpr;if(this.fingerDirection)if(this.actionExecutor.isEnlargement)if(a>=0&&h<=l)if("right"!=o&&"left"!=o&&!this.isEnlargeMove||"horizontal"!=this.fingerDirection)this.handleMoveEnlage(t);else{this.isEnlargeMove=!0,this.handleMoveNormal(t);var c="resetEnlargeMove";this.addTouchEndTask(c,{priority:1,callback:function(){e.isEnlargeMove=!1}})}else if(i&&"right"==o||n&&"left"==o||this.isEnlargeMove){this.isEnlargeMove=!0,this.handleMoveNormal(t);c="resetEnlargeMove";this.addTouchEndTask(c,{priority:1,callback:function(){return e.isEnlargeMove=!1}})}else this.handleMoveEnlage(t);else this.handleMoveNormal(t);else{if(this.actionExecutor.isEnlargement&&(a<0||h>l)||!this.actionExecutor.isEnlargement)return void(!this.actionExecutor.isEnlargement||r||this.normalMoved?this.actionExecutor.isEnlargement?(r||this.normalMoved)&&(this.normalMoved?this.handleMoveNormal(t):"right"==o?i?this.handleMoveNormal(t):this.handleMoveEnlage(t):"left"==o&&n?this.handleMoveNormal(t):this.handleMoveEnlage(t)):this.handleMoveNormal(t):this.handleMoveEnlage(t));if(this.getMovePoints(t),this.movePoints.lengthn?p:0,s=Math.round(c)<0||Math.round(u)>r?g:0,e.eventsHanlder.handleMoveEnlage(a,s,0);this.addTouchEndTask("handleTendEnlarte",{priority:10,callback:this.handleTEndEnlarge.bind(this)}),this.startX=d,this.startY=f}},t.prototype.autoMove=function(t,e,i,n){var r=n.maxTop,o=n.minTop,s=n.maxLeft,a=n.minLeft,h=this.imgContainer.getBoundingClientRect(),l=h.width,c=h.height,u=this.actionExecutor,d=u.viewRect,f=u.eventsHanlder,p=d,g=p.top,v=p.bottom,m=p.left,w=p.right;t=t/180*Math.PI;var x=e+300*Math.cos(t),y=i+300*Math.sin(t);x>s?x=s:xr?y=r:y=0&&w<=l||(M=x-e),g>=0&&v<=c||(b=y-i),f.moveCurPlaneTo(M,b,0)},t}(),a=function(){function t(){}return t.prototype.handleZoom=function(t){if(!(this.isNormalMove&&this.normalMoved||this.isAnimating||this.actionExecutor.isLoadingError())){this.isZooming||(this.curStartPoint1={x:this.curPoint1.x,y:this.curPoint1.y},this.curStartPoint2={x:this.curPoint2.x,y:this.curPoint2.y}),this.isZooming=!0,this.isAnimating=!0;var e=this.actionExecutor,i=Math.pow(this.curPoint1.x-this.curPoint2.x,2)+Math.pow(this.curPoint1.y-this.curPoint2.y,2),n=Math.pow(t.touches[0].clientX-t.touches[1].clientX,2)+Math.pow(t.touches[0].clientY-t.touches[1].clientY,2),r=(this.curStartPoint1.x+this.curStartPoint2.x)/2,o=(this.curStartPoint1.y+this.curStartPoint2.y)/2,s=e.viewWidth/(2*e.dpr),a=e.viewHeight/(2*e.dpr);this.curPoint1.x=t.touches[0].clientX,this.curPoint1.y=t.touches[0].clientY,this.curPoint2.x=t.touches[1].clientX,this.curPoint2.y=t.touches[1].clientY;var h=0,l=0,c=1,u=1;if(i>n)l=(o-a)*this.zoomScale,h=(r-s)*this.zoomScale,c=1-this.zoomScale,u=1-this.zoomScale;else{if(!(i0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]d;){if(i=this.getX(r)-t,Math.abs(i)0?u=r:d=r,r=(u+d)/2}return r},t.prototype.solve=function(t){return this.cachedY.get(t)||this.cachedY.set(t,this.getY(this.solveCurveX(t))),this.cachedY.get(t)},t}(),p=new f(0,0,1,1);new f(.25,.1,.25,1),new f(.42,0,1,1),new f(0,0,.58,1),new f(.42,0,.58,1);var g=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},v=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]4*s||(l*t=this.throldDeg?(o=t.curIndex,-1!=(s=t.curIndex+1*r)&&s!=t.imgUrls.length?[3,2]:(t.curIndex=o,[4,t.rotate(-n)])):[3,6];case 1:return a.sent(),[3,5];case 2:return[4,t.rotate(r*Math.PI/2-n)];case 3:return a.sent(),t.curIndex=s,t.modelMatrix=t.baseModel=t.initialModel,t.gl.uniformMatrix4fv(t.gl.getUniformLocation(t.shaderProgram,"uModelViewMatrix"),!1,t.modelMatrix),[4,t.draw(s)];case 4:a.sent(),a.label=5;case 5:return[3,8];case 6:return[4,t.rotate(-n)];case 7:a.sent(),a.label=8;case 8:return t.modelMatrix=t.baseModel=t.initialModel,[2,"handled"]}}))}))},t.prototype.handleTEndEnlarge=function(t,e,i,n){return g(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return t=this.viewInstance,e*=t.dpr,i*=-t.dpr,t.dpr,this.curBehaviorCanBreak=!0,[4,t.moveCurPlane(e,i,0)];case 1:return n.sent(),this.curBehaviorCanBreak=!1,0!==e&&(t.isBoudriedSide=!0),[2]}}))}))},t.prototype.moveCurPlaneTo=function(t,e,i){return g(this,void 0,void 0,(function(){var i;return v(this,(function(n){switch(n.label){case 0:return i=this.viewInstance,t*=i.dpr,e*=-i.dpr,i.dpr,this.curBehaviorCanBreak=!0,[4,i.moveCurPlane(t,e,0)];case 1:return n.sent(),this.curBehaviorCanBreak=!1,[2]}}))}))},t}();var w=function(t,e,i){var n=t.naturalWidth,r=t.naturalHeight,o=document.createElement("canvas"),s=o.getContext("2d"),a=window.devicePixelRatio||1;return o.width=e*a,o.height=i*a,s.drawImage(t,0,0,n,r,0,0,e*a,i*a),o},x=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},y=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]n&&(e=n-1,r=n),this.imgUrls.splice(e+1,0,t),e+1>this.imgs.length?this.imgs[r]=null:this.imgs.splice(e+1,0,null),t instanceof Image)if(void 0===t._id&&(t._id=this.imgId++),t.complete)this.imgUrls[e+1]=this.validateImg(t);else{var o=function(){var e=i.imgUrls.indexOf(t);t.loadError=!0,~[-2,-1,0].indexOf(e-i.curIndex)&&i.draw(i.curIndex)};t.addEventListener("load",(function(){var e=i.imgUrls.indexOf(t);i.imgUrls[e]=i.validateImg(t),~[-2,-1,0].indexOf(e-i.curIndex)&&i.draw(i.curIndex)})),t.addEventListener("error",o),t.addEventListener("abort",o)}~[-2,-1,0].indexOf(e-this.curIndex)&&this.draw(this.curIndex)},t.prototype.delImg=function(t){var e=this.imgUrls.length;t<=-1?t=0:t>=e&&(t=e-1),this.imgUrls.splice(t,1),this.imgs[t]&&this.textures.delete(this.imgs[t]._id),this.imgs.splice(t,1),t-=this.curIndex,~[-1,0,1].indexOf(t)&&this.draw(this.curIndex)},t.prototype.initOtherTexture=function(){var t=this,e=this.gl,i=e.createTexture();this.texturesOther.set(0,i),e.bindTexture(e.TEXTURE_2D,i),i.cubicBgd=!0;e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,new Uint8Array([0,0,0,255]));var n=new Image;n.onload=function(){var i=e.createTexture();t.texturesOther.set(1,i),e.bindTexture(e.TEXTURE_2D,i),t.texImage(n),t.setTexParameteri(n.width,n.height)},n.src="data:image/svg+xml;base64,PHN2ZyB0PSIxNjI1ODExNDgwNTgyIiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEzNDIgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjYwNjkiIHdpZHRoPSIyMDAiIGhlaWdodD0iMjAwIj48cGF0aCBkPSJNMTIxNi4zNTcgMTM5LjAzYy0xMC4xNTctMTEuNDI3LTI0Ljc1OS0xNy43NzUtMzkuOTk1LTE4LjQxTDc0My40IDEwMy40OGwtMzIuMzc3IDczLjAwNiA0NS4wNzQgMTM1Ljg1Ni04MS4yNiAxNTQuMjY3IDMzLjAxMiAxMjQuNDI5IDgyLjUzIDEwNi42NTMgMTE5LjM1LTEwOS44MjdjMTEuNDI3LTEwLjc5MyAyOS44MzctMTAuMTU4IDM5Ljk5NCAxLjkwNGwxNTIuOTk3IDE2NS42OTRjMTAuNzkzIDExLjQyNyAxMC4xNTggMjkuODM3LTEuMjcgNDAuNjMtNS43MTMgNS4wNzgtMTIuNjk2IDguMjUzLTIwLjMxNCA3LjYxOGwtNDE5LjYzLTE2LjUwNi0yMC45NSA2MC4zMSAyMi44NTQgNTMuOTYyIDQ4Mi40OCAxOC40MWMzMS43NDIgMS4yNyA1OC40MDUtMjMuNDkgNTkuMDQtNTUuMjMxbDI2LjY2My02ODQuMzZjMC42MzUtMTUuMjM2LTQuNDQ0LTMwLjQ3Mi0xNS4yMzYtNDEuMjY1ek05MDYuNTU0IDQ1My4yNzdjLTQ3LjYxMy0xLjkwNC04NC40MzQtNDEuOS04Mi41My04OC44NzggMS45MDUtNDcuNjEzIDQxLjktODQuNDM0IDg4Ljg3OS04Mi41MyA0Ni45NzggMS45MDUgODQuNDM0IDQxLjkgODIuNTMgODguODc5LTEuOTA1IDQ2Ljk3OC00MS45IDg0LjQzNC04OC44NzkgODIuNTN6TTU5NS40ODIgODQ4LjE1bDE0LjYwMS02My40ODQtMzQwLjkxIDIzLjQ4OWMtMTUuODcxIDEuMjctMjkuMjAzLTEwLjE1OC0zMC40NzItMjYuMDI5YTI4LjEyIDI4LjEyIDAgMCAxIDYuOTgzLTIwLjk1TDQ5OC4zNSA0NzEuMDUzYzUuMDc5LTYuMzQ5IDEyLjY5Ny05LjUyMyAyMC45NS05LjUyMyA3LjYxOCAwIDE1LjIzNiAzLjE3NCAyMC45NSA4Ljg4OGw4NC40MzMgODguMjQzLTM2LjE4Ni05My45NTcgNjQuNzU0LTE2Mi41Mi01OS4wNC0xMzAuMTQyIDI0LjEyNC03NC45MTEtNDY0LjcwNCAzMi4zNzdjLTMxLjc0MiAxLjkwNC01NS4yMzIgMjkuMjAyLTUzLjMyNyA2MC45NDVsNDYuOTc4IDY4NC4zNmMwLjYzNSAxNS4yMzUgNy42MTggMjkuMjAyIDE5LjY4IDM4LjcyNSAxMS40MjggMTAuMTU3IDI2LjAyOSAxNS4yMzYgNDEuMjY1IDEzLjk2Nmw0MTUuMTg3LTI4LjU2OC0yNy45MzMtNTAuNzg3eiIgcC1pZD0iNjA3MCIgZmlsbD0iI2JmYmZiZiIvPjwvc3ZnPg=="},t.prototype.initData=function(){this.draw(this.curIndex)},t.prototype.slideNext=function(){return x(this,void 0,void 0,(function(){var t=this;return y(this,(function(e){return this.curIndex==this.imgUrls.length-1?[2,[!0]]:[2,this.slide(.5*Math.PI,(function(){return t.curIndex++}))]}))}))},t.prototype.slideBefore=function(){return x(this,void 0,void 0,(function(){var t=this;return y(this,(function(e){return 0==this.curIndex?[2,[!0]]:[2,this.slide(-.5*Math.PI,(function(){return t.curIndex--}))]}))}))},t.prototype.slide=function(t,e){return x(this,void 0,void 0,(function(){return y(this,(function(i){switch(i.label){case 0:return this.baseModel=this.modelMatrix,[4,this.rotate(t)];case 1:return i.sent(),e(),this.modelMatrix=this.baseModel=this.initialModel,this.gl.uniformMatrix4fv(this.gl.getUniformLocation(this.shaderProgram,"uModelViewMatrix"),!1,this.modelMatrix),[4,this.draw(this.curIndex)];case 2:return i.sent(),this.modelMatrix=this.baseModel=this.initialModel,[2,[!1]]}}))}))},t.prototype.rotate=function(t){var e,i=this;return this.animate({allTime:this.defaultAnimateTime,timingFun:p,ends:[t],playGame:(e=i.rotatePosition.bind(i),function(t){i.clear(),e(t)})})},t.prototype.rotateZ=function(t){var e=this;this.curPlane=this.positions.slice(this.curPointAt,this.curPointAt+16);var i=this.imgShape,n=this.imgShapeInitinal;this.imgShape=d.multiplyPoint(i,d.rotateZMatrix(t)),this.imgShapeInitinal=d.multiplyPoint(n,d.rotateZMatrix(t));var r=this.curCenterCoordinate,o=-r[0],s=-r[1];return this.animate({allTime:this.defaultAnimateTime,timingFun:p,ends:[t,o,s],playGame:function(){for(var t=[],i=0;ic?c:this.viewWidth):(i=c,n=u),p=-(t-r)*(d=i/a-1),g=(e-o)*(f=n/h-1),this.curIsLongImg()&&(p=0);return[d,f,p,g]},t.prototype.decideImgViewSize=function(t,e){var i=0,n=0;return(n=e/t*(i=this.viewWidth>=t?t:this.viewWidth))>this.viewHeight&&(i=(n=this.viewHeight)*t/e),[i,n]},t.prototype.draw=function(t){this.positions=[];for(var e=this.imgUrls.length,i=0,n=0,r=t-1;r<=t+1;r++)if(-1!==r&&r<=e-1){var o=void 0;this.imgs[r]?o=this.imgs[r]:"string"==typeof this.imgUrls[r]?o=this.loadImage(this.imgUrls[r],r):void 0===(o=this.imgUrls[r])._id&&(this.imgUrls[r]=this.validateImg(o),o=this.imgUrls[r]),this.imgs[r]=o;var s=o.naturalWidth,a=o.naturalHeight;o.loadError&&(s=a=200);var h=this.decideImgViewSize(s*this.dpr,a*this.dpr),l=h[0],c=h[1];r==this.curIndex&&(this.imgShape=[s*this.dpr,a*this.dpr,0,1],this.imgShapeInitinal=[l,c,0,1]),this.genPostion(l,c,r),i=Math.max(l,i),n=Math.max(c,n)}this.generateCube(i,n),this.bindPostion(),this.drawPosition()},t.prototype.createPerspectiveMatrix=function(){var t=this.fieldOfViewInRadians,e=this.viewWidth/this.viewHeight,i=this.zNear,n=this.zFar,r=1/Math.tan(t/2),o=1/(i-n);return[r/e,0,0,0,0,r,0,0,0,0,(i+n)*o,-1,0,0,i*n*o*2,0]},Object.defineProperty(t.prototype,"curPointAt",{get:function(){var t=64;return 0==this.curIndex&&(t=48),t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"IsBoundaryLeft",{get:function(){var t=this.viewRect;return Math.round(t.left)>=0&&this.isBoudriedSide},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isBoundaryRight",{get:function(){var t=this.viewRect;return Math.round(t.right*this.dpr)<=Math.round(this.viewWidth/1)&&this.isBoudriedSide},enumerable:!1,configurable:!0}),t.prototype.curIsLongImg=function(){var t=this.imgShape,e=t[0],i=t[1];return 2*Math.abs(e)<=Math.abs(i)},Object.defineProperty(t.prototype,"curCenterCoordinate",{get:function(){var t=this.curPointAt;return[(this.positions[t]+this.positions[t+8])/2,(this.positions[t+1]+this.positions[t+9])/2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"viewRect",{get:function(){for(var t=-this.viewWidth/2,e=this.viewHeight/2,i=this.curPointAt,n=1/0,r=-1/0,o=1/0,s=-1/0,a=i;athis.viewWidth||e.height*this.dpr-1>this.viewHeight},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isEnlargementForScale",{get:function(){var t=this.imgShapeInitinal,e=t[0],i=t[1],n=this.viewRect;return Math.round(n.width*this.dpr)>Math.round(Math.abs(e))||Math.round(n.height*this.dpr)>Math.round(Math.abs(i))},enumerable:!1,configurable:!0}),t.prototype.isLoadingError=function(t){return 0==arguments.length&&(t=this.curIndex),this.imgs[t].loadError},t.prototype.loadImage=function(t,e){var i=this,n=new Image;return n._id=this.imgId++,this.imgs[e]=n,n.onload=function(){i.handleImgLoaded(n,e)},n.onerror=function(){n.loadError=!0,i.handleImgLoaded(n,e)},n.onabort=function(){n.loadError=!0,i.handleImgLoaded(n,e)},n.crossOrigin="anonymous",n.src=t,n},t.prototype.handleImgLoaded=function(t,e){e=this.imgs.indexOf(t),t.loadError||(t=this.validateImg(t),this.imgs[e]=t),~[-1,0,1].indexOf(e-this.curIndex)&&(this.updatePosition(t,e-this.curIndex),this.bindPostion(),this.drawPosition())},t.prototype.validateImg=function(t){var e=this.gl.MAX_TEXTURE_SIZE,i=t.naturalWidth,n=t.naturalHeight;if(Math.max(n,i)>=e){var r=this.dpr,o=e/r,s=n/i*o;s>=e&&(o=i/n*(s=e/r));var a=w(t,o,s);return a._id=this.imgId++,a.naturalHeight=s,a.naturalWidth=o,a.complete=!0,a}return t},t.prototype.clear=function(){var t=this.gl;t.clearColor(0,0,0,1),t.clearDepth(1),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT)},t.prototype.bindShader=function(t,e,i){var n=this.loadShader(t,t.VERTEX_SHADER,i),r=this.loadShader(t,t.FRAGMENT_SHADER,e),o=t.createProgram();return t.attachShader(o,n),t.attachShader(o,r),t.linkProgram(o),t.getProgramParameter(o,t.LINK_STATUS)?o:(console.error("Unable to initialize the shader program: "+t.getProgramInfoLog(o)),null)},t.prototype.loadShader=function(t,e,i){var n=t.createShader(e);return t.shaderSource(n,i),t.compileShader(n),t.getShaderParameter(n,t.COMPILE_STATUS)?n:(console.error("An error occurred compiling the shaders: "+t.getShaderInfoLog(n)),t.deleteShader(n),null)},t.prototype.createPlane=function(t){return t.x,t.y,t.width,t.height,{}},t.prototype.intialView=function(){var t=document.createElement("canvas");t.style.cssText="\n position: absolute;\n top: 0;\n left:0;\n z-index: 9;\n width:"+window.innerWidth+"px;\n height:"+window.innerHeight+"px;\n user-select:none;\n font-size:0;\n ",t.width=window.innerWidth*this.dpr,t.height=window.innerHeight*this.dpr,this.ref=t;var e=t.getContext("webgl",{antialias:!0});return e||console.error("webgl is not supported. please use before version."),this.viewWidth=t.width,this.viewHeight=t.height,e},t.prototype.animate=function(t){var e,i=this,n=t.allTime,r=t.timingFun,o=t.ends,s=t.playGame,a=t.callback,h=Date.now(),l=h,c=new Promise((function(t){return e=t})),u=o.length,d=function(){if(i.curAimateBreaked)return e([!1,3]),void(i.curAimateBreaked=!1);var t=l-h;t>n&&(t=n);var c=t/n;c>1&&(c=1);var f=r.solve(c);f>=1&&(f=1);var p=new Array(u);o.forEach((function(t,e){p[e]=t*f})),s.apply(void 0,p),c<1?requestAnimationFrame(d):(a&&a(),e([!1,1])),l=Date.now()};return d(),c},t}(),I=function(t,e,i,n){var r,o=arguments.length,s=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(s=(o<3?r(s):o>3?r(e,i,s):r(e,i))||s);return o>3&&s&&Object.defineProperty(e,i,s),s},A=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},S=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]d?(w=d-g,m=!0):gc?(x=c-p,v=!0):p=0&&l<=n&&(m=!1,w=0),s<=r&&(v=!1,x=0),m||v?(this.isAnimating=!0,[4,e.eventsHanlder.handleTEndEnlarge(t,w,x,0)]):[3,2];case 1:return I.sent(),this.isAnimating=!1,[3,4];case 2:return this.moveEndTime=Date.now(),y={x:this.startX,y:this.startY},M={x:this.touchStartX,y:this.touchStartY},b=y.x-M.x,E=y.y-M.y,T=180*Math.atan2(E,b)/Math.PI,this.moveEndTime-this.moveStartTime<90&&Math.abs(b)+Math.abs(E)>5?(P={maxTop:c,minTop:u,maxLeft:d,minLeft:n-o},this.isAnimating=!0,[4,this.autoMove(T,h,a,P)]):[3,4];case 3:I.sent(),this.isAnimating=!1,I.label=4;case 4:return this.moveStartTime=0,[2]}}))}))},t.prototype.handleTEndEnNormal=function(t){return A(this,void 0,void 0,(function(){var e,i,n;return S(this,(function(r){switch(r.label){case 0:return this.isAnimating?[2]:(e=t.changedTouches[0].clientX,i=this.actionExecutor.eventsHanlder,0===(n=e-this.touchStartX)?[2]:(this.isAnimating=!0,[4,i.handleTEndEnNormal(t,n)]));case 1:return r.sent(),this.isAnimating=!1,[2]}}))}))},t.prototype.genFrame=function(){var t=this,e=this.options.imgs;!e||e.length,this.imgsNumber=e.length,this.curIndex=0;var i='\n
\n \n \n \n \n
\n
\n
\n '+("pc"==this.envClient?'
\n \n
\n
\n \n
':"")+'\n
\n \n
\n
\n \n
\n
\n ',n=/iphone/gi.test(window.navigator.userAgent)&&window.devicePixelRatio&&3===window.devicePixelRatio&&375===window.screen.width&&812===window.screen.height,r=/iphone/gi.test(window.navigator.userAgent)&&window.devicePixelRatio&&3===window.devicePixelRatio&&414===window.screen.width&&896===window.screen.height,o=/iphone/gi.test(window.navigator.userAgent)&&window.devicePixelRatio&&2===window.devicePixelRatio&&414===window.screen.width&&896===window.screen.height,s=n||r||o,a="\n ."+this.prefix+"imagePreviewer{\n position: fixed;\n top:0;\n left: 100%;\n width: 100%;\n height: 100%;\n background: "+function(e){switch(e){case"conBackground":return"pc"==t.envClient?"rgba(0,0,0,0.8)":"rgba(0,0,0,1)";case"imgWidth":return t.envClient,"100%";case"itemHeight":return"pc"==t.envClient?"100%":"auto";case"itemScroll":return"pc"==t.envClient?"auto ":"hidden";case"item-text-align":return"pc"==t.envClient?"center ":"initial";default:return""}}("conBackground")+";\n color:#fff;\n transform: translate3d(0,0,0);\n transition: left 0.5s;\n overflow:hidden;\n user-select: none;\n }\n \n ."+this.prefix+"imagePreviewer."+this.defToggleClass+"{\n left: 0%;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"close{\n position: absolute;\n top: 20px;\n right: 20px;\n z-index: 10;\n box-sizing: border-box;\n width: 22px;\n height: 22px;\n cursor:pointer;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"close svg{\n width: 100%;\n height: 100%; \n }\n ."+this.prefix+"imagePreviewer svg{\n overflow:visible;\n }\n ."+this.prefix+"imagePreviewer svg path{\n stroke: #948888;\n stroke-width: 30px;\n }\n \n ."+this.prefix+"imagePreviewer "+this.prefix+".close."+this.prefix+"scroll{\n height: 0;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"imgContainer{\n position: relative;\n height: 100%;\n font-size: 0;\n white-space: nowrap;\n }\n \n ."+this.prefix+"imagePreviewer ."+this.prefix+"bottom{\n position: absolute;\n bottom: "+(s?20:0)+"px;\n left: 20px;\n right: 20px;\n z-index: 10;\n padding: 0 10px;\n text-align: center;\n border-top: 1px solid rgba(255, 255, 255, .2);\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"bottom ."+this.prefix+"item{\n display:inline-block;\n width: 42px;\n height: 42px;\n cursor:pointer;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"bottom ."+this.prefix+"item svg{\n box-sizing: border-box;\n width: 100%;\n height: 100%;\n padding:10px;\n }\n ";if(this.ref=document.createElement("div"),this.ref.className=this.prefix+"imagePreviewer",this.ref.innerHTML=i,!document.querySelector("#"+this.prefix+"style")){var h=document.createElement("style");h.id=this.prefix+"style",h.innerHTML=a,document.querySelector("head").appendChild(h)}this.ref.querySelector("."+this.prefix+"imgContainer").append(this.actionExecutor.ref),document.body.appendChild(this.ref)},t.prototype.handleReausetAnimate=function(){window.requestAnimationFrame||(window.requestAnimationFrame=window.webkitRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60),0})},t.prototype.close=function(t){t.stopImmediatePropagation(),clearTimeout(this.performerClick),this[this.envClient+"BeforeClose"](),this.toggleClass(this.ref,this.defToggleClass)},t.prototype.pcBeforeClose=function(){document.body.style.overflow=document.body.dataset.imgPreOverflow},t.prototype.mobileBeforeClose=function(){},t.prototype.show=function(t){this.actionExecutor.curIndex=t,this.actionExecutor.draw(t),this.toggleClass(this.ref,this.defToggleClass)},t.prototype.mobileReadyShow=function(){},t.prototype.pcReadyShow=function(){var t=window.getComputedStyle(document.body);document.body.dataset.imgPreOverflow=t.overflow,document.body.style.overflow="hidden"},t.prototype.toggleClass=function(t,e){var i=t.className.split(" "),n=i.indexOf(e);-1!==n?i.splice(n,1):i.push(e),t.className=i.join(" ")},t.prototype.getMovePoints=function(t){var e=this;if(!(this.movePoints.length>this.maxMovePointCounts)){this.movePoints.push({x:t.touches[0].clientX,y:t.touches[0].clientY});this.addTouchEndTask("resetMovePoints",{priority:1,callback:function(){return e.movePoints=[]}})}},t.prototype.decideMoveDirection=function(){var t=this,e=this.movePoints.length,i=this.movePoints[e-1],n=this.movePoints[0],r=i.x-n.x,o=i.y-n.y,s=180*Math.atan2(o,r)/Math.PI;Math.abs(90-Math.abs(s))<30?this.fingerDirection="vertical":this.fingerDirection="horizontal";this.addTouchEndTask("resetFingerDirection",{priority:1,callback:function(){t.fingerDirection=""}})},t.prototype.destroy=function(){this.ref.parentNode.removeChild(this.ref),window.removeEventListener("resize",this.handleResize),window.removeEventListener("orientationchange",this.handleResize)},t.prototype.testEnv=function(){return/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)?"mobile":"pc"},t=I([o],t)}();return T=D,[s,a,c].forEach((function(t){Object.getOwnPropertyNames(t.prototype).forEach((function(e){T.prototype[e]=t.prototype[e]}))})),t.ImagePreview=D,Object.defineProperty(t,"__esModule",{value:!0}),t}({}); diff --git a/release/image-preview/image-preview-iife.js b/release/image-preview/image-preview-iife.js index be740dd..4b3cf6d 100644 --- a/release/image-preview/image-preview-iife.js +++ b/release/image-preview/image-preview-iife.js @@ -765,6 +765,7 @@ var imagePreviewModule = (function (exports) { var cubicBezier = (function () { function cubicBezier(x1, y1, x2, y2) { + this.cachedY = new Map(); this.precision = 1e-5; this.p1 = { x: x1, @@ -824,7 +825,10 @@ var imagePreviewModule = (function (exports) { return t2; }; cubicBezier.prototype.solve = function (x) { - return this.getY(this.solveCurveX(x)); + if (!this.cachedY.get(x)) { + this.cachedY.set(x, this.getY(this.solveCurveX(x))); + } + return this.cachedY.get(x); }; return cubicBezier; }()); @@ -1342,7 +1346,8 @@ var imagePreviewModule = (function (exports) { }; webGl.prototype.genPostion = function (width, height, index) { var _a; - var z = -(this.viewHeight) / (2 * Math.tan(this.fieldOfViewInRadians / 2)) - forDev; + var zNearHeight = (2 * Math.tan(this.fieldOfViewInRadians / 2)); + var z = -(this.viewHeight) / (zNearHeight) - forDev; var viewWidth = this.viewWidth; var sideZAxis = z - (viewWidth - width) / 2; var positionsMap = [ diff --git a/release/image-preview/image-preview-umd-min.js b/release/image-preview/image-preview-umd-min.js index eba6f5e..c6f2a5b 100644 --- a/release/image-preview/image-preview-umd-min.js +++ b/release/image-preview/image-preview-umd-min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).imagePreviewModule={})}(this,(function(t){"use strict";var e,i=(e=function(t,i){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(t,i)},function(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}),n=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},r=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]0?(h=-(i-s)*u,a=-(e-o)*u,l=1+u,c=1+u):(h=(i-s)*u,a=(e-o)*u,l=1-u,c=1-u),n.eventsHanlder.handleZoom(l,c,a,h),this.isZooming=!1,this.isAnimating=!1,this.actionExecutor.isEnlargement?this.ref.style.cursor="grab":this.ref.style.cursor="initial",[2]}))}))},e.prototype.handlePCDoubleClick=function(t){return n(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return this.isAnimating?[2]:(this.isAnimating=!0,[4,this.actionExecutor.eventsHanlder.handleDoubleClick({clientX:t.clientX,clientY:t.clientY})]);case 1:return e.sent(),this.isAnimating=!1,this.actionExecutor.isEnlargement?this.ref.style.cursor="grab":this.ref.style.cursor="initial",[2]}}))}))},e.prototype.handleMouseDown=function(t){var e=this,i=t.target.dataset.type;this[i]?this[i](t):(this.mouseDown=!0,this.actionExecutor.isEnlargement?(this.startX=t.clientX,this.startY=t.clientY,this.ref.style.cursor="grabbing"):this.ref.style.cursor="initial",Date.now()-this.lastClick0?"right":"left",s=this.actionExecutor.viewRect,a=s.left,h=s.right,l=this.actionExecutor.viewWidth/this.actionExecutor.dpr;if(this.fingerDirection)if(this.actionExecutor.isEnlargement)if(a>=0&&h<=l)if("right"!=o&&"left"!=o&&!this.isEnlargeMove||"horizontal"!=this.fingerDirection)this.handleMoveEnlage(t);else{this.isEnlargeMove=!0,this.handleMoveNormal(t);var c="resetEnlargeMove";this.addTouchEndTask(c,{priority:1,callback:function(){e.isEnlargeMove=!1}})}else if(i&&"right"==o||n&&"left"==o||this.isEnlargeMove){this.isEnlargeMove=!0,this.handleMoveNormal(t);c="resetEnlargeMove";this.addTouchEndTask(c,{priority:1,callback:function(){return e.isEnlargeMove=!1}})}else this.handleMoveEnlage(t);else this.handleMoveNormal(t);else{if(this.actionExecutor.isEnlargement&&(a<0||h>l)||!this.actionExecutor.isEnlargement)return void(!this.actionExecutor.isEnlargement||r||this.normalMoved?this.actionExecutor.isEnlargement?(r||this.normalMoved)&&(this.normalMoved?this.handleMoveNormal(t):"right"==o?i?this.handleMoveNormal(t):this.handleMoveEnlage(t):"left"==o&&n?this.handleMoveNormal(t):this.handleMoveEnlage(t)):this.handleMoveNormal(t):this.handleMoveEnlage(t));if(this.getMovePoints(t),this.movePoints.lengthn?p:0,s=Math.round(c)<0||Math.round(u)>r?g:0,e.eventsHanlder.handleMoveEnlage(a,s,0);this.addTouchEndTask("handleTendEnlarte",{priority:10,callback:this.handleTEndEnlarge.bind(this)}),this.startX=d,this.startY=f}},t.prototype.autoMove=function(t,e,i,n){var r=n.maxTop,o=n.minTop,s=n.maxLeft,a=n.minLeft,h=this.imgContainer.getBoundingClientRect(),l=h.width,c=h.height,u=this.actionExecutor,d=u.viewRect,f=u.eventsHanlder,p=d,g=p.top,v=p.bottom,m=p.left,w=p.right;t=t/180*Math.PI;var x=e+300*Math.cos(t),y=i+300*Math.sin(t);x>s?x=s:xr?y=r:y=0&&w<=l||(M=x-e),g>=0&&v<=c||(b=y-i),f.moveCurPlaneTo(M,b,0)},t}(),a=function(){function t(){}return t.prototype.handleZoom=function(t){if(!(this.isNormalMove&&this.normalMoved||this.isAnimating||this.actionExecutor.isLoadingError())){this.isZooming||(this.curStartPoint1={x:this.curPoint1.x,y:this.curPoint1.y},this.curStartPoint2={x:this.curPoint2.x,y:this.curPoint2.y}),this.isZooming=!0,this.isAnimating=!0;var e=this.actionExecutor,i=Math.pow(this.curPoint1.x-this.curPoint2.x,2)+Math.pow(this.curPoint1.y-this.curPoint2.y,2),n=Math.pow(t.touches[0].clientX-t.touches[1].clientX,2)+Math.pow(t.touches[0].clientY-t.touches[1].clientY,2),r=(this.curStartPoint1.x+this.curStartPoint2.x)/2,o=(this.curStartPoint1.y+this.curStartPoint2.y)/2,s=e.viewWidth/(2*e.dpr),a=e.viewHeight/(2*e.dpr);this.curPoint1.x=t.touches[0].clientX,this.curPoint1.y=t.touches[0].clientY,this.curPoint2.x=t.touches[1].clientX,this.curPoint2.y=t.touches[1].clientY;var h=0,l=0,c=1,u=1;if(i>n)l=(o-a)*this.zoomScale,h=(r-s)*this.zoomScale,c=1-this.zoomScale,u=1-this.zoomScale;else{if(!(i0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]d;){if(i=this.getX(r)-t,Math.abs(i)0?u=r:d=r,r=(u+d)/2}return r},t.prototype.solve=function(t){return this.getY(this.solveCurveX(t))},t}(),p=new f(0,0,1,1);new f(.25,.1,.25,1),new f(.42,0,1,1),new f(0,0,.58,1),new f(.42,0,.58,1);var g=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},v=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]4*s||(l*t=this.throldDeg?(o=t.curIndex,-1!=(s=t.curIndex+1*r)&&s!=t.imgUrls.length?[3,2]:(t.curIndex=o,[4,t.rotate(-n)])):[3,6];case 1:return a.sent(),[3,5];case 2:return[4,t.rotate(r*Math.PI/2-n)];case 3:return a.sent(),t.curIndex=s,t.modelMatrix=t.baseModel=t.initialModel,t.gl.uniformMatrix4fv(t.gl.getUniformLocation(t.shaderProgram,"uModelViewMatrix"),!1,t.modelMatrix),[4,t.draw(s)];case 4:a.sent(),a.label=5;case 5:return[3,8];case 6:return[4,t.rotate(-n)];case 7:a.sent(),a.label=8;case 8:return t.modelMatrix=t.baseModel=t.initialModel,[2,"handled"]}}))}))},t.prototype.handleTEndEnlarge=function(t,e,i,n){return g(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return t=this.viewInstance,e*=t.dpr,i*=-t.dpr,t.dpr,this.curBehaviorCanBreak=!0,[4,t.moveCurPlane(e,i,0)];case 1:return n.sent(),this.curBehaviorCanBreak=!1,0!==e&&(t.isBoudriedSide=!0),[2]}}))}))},t.prototype.moveCurPlaneTo=function(t,e,i){return g(this,void 0,void 0,(function(){var i;return v(this,(function(n){switch(n.label){case 0:return i=this.viewInstance,t*=i.dpr,e*=-i.dpr,i.dpr,this.curBehaviorCanBreak=!0,[4,i.moveCurPlane(t,e,0)];case 1:return n.sent(),this.curBehaviorCanBreak=!1,[2]}}))}))},t}();var w=function(t,e,i){var n=t.naturalWidth,r=t.naturalHeight,o=document.createElement("canvas"),s=o.getContext("2d"),a=window.devicePixelRatio||1;return o.width=e*a,o.height=i*a,s.drawImage(t,0,0,n,r,0,0,e*a,i*a),o},x=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},y=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]n&&(e=n-1,r=n),this.imgUrls.splice(e+1,0,t),e+1>this.imgs.length?this.imgs[r]=null:this.imgs.splice(e+1,0,null),t instanceof Image)if(void 0===t._id&&(t._id=this.imgId++),t.complete)this.imgUrls[e+1]=this.validateImg(t);else{var o=function(){var e=i.imgUrls.indexOf(t);t.loadError=!0,~[-2,-1,0].indexOf(e-i.curIndex)&&i.draw(i.curIndex)};t.addEventListener("load",(function(){var e=i.imgUrls.indexOf(t);i.imgUrls[e]=i.validateImg(t),~[-2,-1,0].indexOf(e-i.curIndex)&&i.draw(i.curIndex)})),t.addEventListener("error",o),t.addEventListener("abort",o)}~[-2,-1,0].indexOf(e-this.curIndex)&&this.draw(this.curIndex)},t.prototype.delImg=function(t){var e=this.imgUrls.length;t<=-1?t=0:t>=e&&(t=e-1),this.imgUrls.splice(t,1),this.imgs[t]&&this.textures.delete(this.imgs[t]._id),this.imgs.splice(t,1),t-=this.curIndex,~[-1,0,1].indexOf(t)&&this.draw(this.curIndex)},t.prototype.initOtherTexture=function(){var t=this,e=this.gl,i=e.createTexture();this.texturesOther.set(0,i),e.bindTexture(e.TEXTURE_2D,i),i.cubicBgd=!0;e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,new Uint8Array([0,0,0,255]));var n=new Image;n.onload=function(){var i=e.createTexture();t.texturesOther.set(1,i),e.bindTexture(e.TEXTURE_2D,i),t.texImage(n),t.setTexParameteri(n.width,n.height)},n.src="data:image/svg+xml;base64,PHN2ZyB0PSIxNjI1ODExNDgwNTgyIiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEzNDIgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjYwNjkiIHdpZHRoPSIyMDAiIGhlaWdodD0iMjAwIj48cGF0aCBkPSJNMTIxNi4zNTcgMTM5LjAzYy0xMC4xNTctMTEuNDI3LTI0Ljc1OS0xNy43NzUtMzkuOTk1LTE4LjQxTDc0My40IDEwMy40OGwtMzIuMzc3IDczLjAwNiA0NS4wNzQgMTM1Ljg1Ni04MS4yNiAxNTQuMjY3IDMzLjAxMiAxMjQuNDI5IDgyLjUzIDEwNi42NTMgMTE5LjM1LTEwOS44MjdjMTEuNDI3LTEwLjc5MyAyOS44MzctMTAuMTU4IDM5Ljk5NCAxLjkwNGwxNTIuOTk3IDE2NS42OTRjMTAuNzkzIDExLjQyNyAxMC4xNTggMjkuODM3LTEuMjcgNDAuNjMtNS43MTMgNS4wNzgtMTIuNjk2IDguMjUzLTIwLjMxNCA3LjYxOGwtNDE5LjYzLTE2LjUwNi0yMC45NSA2MC4zMSAyMi44NTQgNTMuOTYyIDQ4Mi40OCAxOC40MWMzMS43NDIgMS4yNyA1OC40MDUtMjMuNDkgNTkuMDQtNTUuMjMxbDI2LjY2My02ODQuMzZjMC42MzUtMTUuMjM2LTQuNDQ0LTMwLjQ3Mi0xNS4yMzYtNDEuMjY1ek05MDYuNTU0IDQ1My4yNzdjLTQ3LjYxMy0xLjkwNC04NC40MzQtNDEuOS04Mi41My04OC44NzggMS45MDUtNDcuNjEzIDQxLjktODQuNDM0IDg4Ljg3OS04Mi41MyA0Ni45NzggMS45MDUgODQuNDM0IDQxLjkgODIuNTMgODguODc5LTEuOTA1IDQ2Ljk3OC00MS45IDg0LjQzNC04OC44NzkgODIuNTN6TTU5NS40ODIgODQ4LjE1bDE0LjYwMS02My40ODQtMzQwLjkxIDIzLjQ4OWMtMTUuODcxIDEuMjctMjkuMjAzLTEwLjE1OC0zMC40NzItMjYuMDI5YTI4LjEyIDI4LjEyIDAgMCAxIDYuOTgzLTIwLjk1TDQ5OC4zNSA0NzEuMDUzYzUuMDc5LTYuMzQ5IDEyLjY5Ny05LjUyMyAyMC45NS05LjUyMyA3LjYxOCAwIDE1LjIzNiAzLjE3NCAyMC45NSA4Ljg4OGw4NC40MzMgODguMjQzLTM2LjE4Ni05My45NTcgNjQuNzU0LTE2Mi41Mi01OS4wNC0xMzAuMTQyIDI0LjEyNC03NC45MTEtNDY0LjcwNCAzMi4zNzdjLTMxLjc0MiAxLjkwNC01NS4yMzIgMjkuMjAyLTUzLjMyNyA2MC45NDVsNDYuOTc4IDY4NC4zNmMwLjYzNSAxNS4yMzUgNy42MTggMjkuMjAyIDE5LjY4IDM4LjcyNSAxMS40MjggMTAuMTU3IDI2LjAyOSAxNS4yMzYgNDEuMjY1IDEzLjk2Nmw0MTUuMTg3LTI4LjU2OC0yNy45MzMtNTAuNzg3eiIgcC1pZD0iNjA3MCIgZmlsbD0iI2JmYmZiZiIvPjwvc3ZnPg=="},t.prototype.initData=function(){this.draw(this.curIndex)},t.prototype.slideNext=function(){return x(this,void 0,void 0,(function(){var t=this;return y(this,(function(e){return this.curIndex==this.imgUrls.length-1?[2,[!0]]:[2,this.slide(.5*Math.PI,(function(){return t.curIndex++}))]}))}))},t.prototype.slideBefore=function(){return x(this,void 0,void 0,(function(){var t=this;return y(this,(function(e){return 0==this.curIndex?[2,[!0]]:[2,this.slide(-.5*Math.PI,(function(){return t.curIndex--}))]}))}))},t.prototype.slide=function(t,e){return x(this,void 0,void 0,(function(){return y(this,(function(i){switch(i.label){case 0:return this.baseModel=this.modelMatrix,[4,this.rotate(t)];case 1:return i.sent(),e(),this.modelMatrix=this.baseModel=this.initialModel,this.gl.uniformMatrix4fv(this.gl.getUniformLocation(this.shaderProgram,"uModelViewMatrix"),!1,this.modelMatrix),[4,this.draw(this.curIndex)];case 2:return i.sent(),this.modelMatrix=this.baseModel=this.initialModel,[2,[!1]]}}))}))},t.prototype.rotate=function(t){var e,i=this;return this.animate({allTime:this.defaultAnimateTime,timingFun:p,ends:[t],playGame:(e=i.rotatePosition.bind(i),function(t){i.clear(),e(t)})})},t.prototype.rotateZ=function(t){var e=this;this.curPlane=this.positions.slice(this.curPointAt,this.curPointAt+16);var i=this.imgShape,n=this.imgShapeInitinal;this.imgShape=d.multiplyPoint(i,d.rotateZMatrix(t)),this.imgShapeInitinal=d.multiplyPoint(n,d.rotateZMatrix(t));var r=this.curCenterCoordinate,o=-r[0],s=-r[1];return this.animate({allTime:this.defaultAnimateTime,timingFun:p,ends:[t,o,s],playGame:function(){for(var t=[],i=0;ic?c:this.viewWidth):(i=c,n=u),p=-(t-r)*(d=i/a-1),g=(e-o)*(f=n/h-1),this.curIsLongImg()&&(p=0);return[d,f,p,g]},t.prototype.decideImgViewSize=function(t,e){var i=0,n=0;return(n=e/t*(i=this.viewWidth>=t?t:this.viewWidth))>this.viewHeight&&(i=(n=this.viewHeight)*t/e),[i,n]},t.prototype.draw=function(t){this.positions=[];for(var e=this.imgUrls.length,i=0,n=0,r=t-1;r<=t+1;r++)if(-1!==r&&r<=e-1){var o=void 0;this.imgs[r]?o=this.imgs[r]:"string"==typeof this.imgUrls[r]?o=this.loadImage(this.imgUrls[r],r):void 0===(o=this.imgUrls[r])._id&&(this.imgUrls[r]=this.validateImg(o),o=this.imgUrls[r]),this.imgs[r]=o;var s=o.naturalWidth,a=o.naturalHeight;o.loadError&&(s=a=200);var h=this.decideImgViewSize(s*this.dpr,a*this.dpr),l=h[0],c=h[1];r==this.curIndex&&(this.imgShape=[s*this.dpr,a*this.dpr,0,1],this.imgShapeInitinal=[l,c,0,1]),this.genPostion(l,c,r),i=Math.max(l,i),n=Math.max(c,n)}this.generateCube(i,n),this.bindPostion(),this.drawPosition()},t.prototype.createPerspectiveMatrix=function(){var t=this.fieldOfViewInRadians,e=this.viewWidth/this.viewHeight,i=this.zNear,n=this.zFar,r=1/Math.tan(t/2),o=1/(i-n);return[r/e,0,0,0,0,r,0,0,0,0,(i+n)*o,-1,0,0,i*n*o*2,0]},Object.defineProperty(t.prototype,"curPointAt",{get:function(){var t=64;return 0==this.curIndex&&(t=48),t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"IsBoundaryLeft",{get:function(){var t=this.viewRect;return Math.round(t.left)>=0&&this.isBoudriedSide},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isBoundaryRight",{get:function(){var t=this.viewRect;return Math.round(t.right*this.dpr)<=Math.round(this.viewWidth/1)&&this.isBoudriedSide},enumerable:!1,configurable:!0}),t.prototype.curIsLongImg=function(){var t=this.imgShape,e=t[0],i=t[1];return 2*Math.abs(e)<=Math.abs(i)},Object.defineProperty(t.prototype,"curCenterCoordinate",{get:function(){var t=this.curPointAt;return[(this.positions[t]+this.positions[t+8])/2,(this.positions[t+1]+this.positions[t+9])/2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"viewRect",{get:function(){for(var t=-this.viewWidth/2,e=this.viewHeight/2,i=this.curPointAt,n=1/0,r=-1/0,o=1/0,s=-1/0,a=i;athis.viewWidth||e.height*this.dpr-1>this.viewHeight},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isEnlargementForScale",{get:function(){var t=this.imgShapeInitinal,e=t[0],i=t[1],n=this.viewRect;return Math.round(n.width*this.dpr)>Math.round(Math.abs(e))||Math.round(n.height*this.dpr)>Math.round(Math.abs(i))},enumerable:!1,configurable:!0}),t.prototype.isLoadingError=function(t){return 0==arguments.length&&(t=this.curIndex),this.imgs[t].loadError},t.prototype.loadImage=function(t,e){var i=this,n=new Image;return n._id=this.imgId++,this.imgs[e]=n,n.onload=function(){i.handleImgLoaded(n,e)},n.onerror=function(){n.loadError=!0,i.handleImgLoaded(n,e)},n.onabort=function(){n.loadError=!0,i.handleImgLoaded(n,e)},n.crossOrigin="anonymous",n.src=t,n},t.prototype.handleImgLoaded=function(t,e){e=this.imgs.indexOf(t),t.loadError||(t=this.validateImg(t),this.imgs[e]=t),~[-1,0,1].indexOf(e-this.curIndex)&&(this.updatePosition(t,e-this.curIndex),this.bindPostion(),this.drawPosition())},t.prototype.validateImg=function(t){var e=this.gl.MAX_TEXTURE_SIZE,i=t.naturalWidth,n=t.naturalHeight;if(Math.max(n,i)>=e){var r=this.dpr,o=e/r,s=n/i*o;s>=e&&(o=i/n*(s=e/r));var a=w(t,o,s);return a._id=this.imgId++,a.naturalHeight=s,a.naturalWidth=o,a.complete=!0,a}return t},t.prototype.clear=function(){var t=this.gl;t.clearColor(0,0,0,1),t.clearDepth(1),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT)},t.prototype.bindShader=function(t,e,i){var n=this.loadShader(t,t.VERTEX_SHADER,i),r=this.loadShader(t,t.FRAGMENT_SHADER,e),o=t.createProgram();return t.attachShader(o,n),t.attachShader(o,r),t.linkProgram(o),t.getProgramParameter(o,t.LINK_STATUS)?o:(console.error("Unable to initialize the shader program: "+t.getProgramInfoLog(o)),null)},t.prototype.loadShader=function(t,e,i){var n=t.createShader(e);return t.shaderSource(n,i),t.compileShader(n),t.getShaderParameter(n,t.COMPILE_STATUS)?n:(console.error("An error occurred compiling the shaders: "+t.getShaderInfoLog(n)),t.deleteShader(n),null)},t.prototype.createPlane=function(t){return t.x,t.y,t.width,t.height,{}},t.prototype.intialView=function(){var t=document.createElement("canvas");t.style.cssText="\n position: absolute;\n top: 0;\n left:0;\n z-index: 9;\n width:"+window.innerWidth+"px;\n height:"+window.innerHeight+"px;\n user-select:none;\n font-size:0;\n ",t.width=window.innerWidth*this.dpr,t.height=window.innerHeight*this.dpr,this.ref=t;var e=t.getContext("webgl",{antialias:!0});return e||console.error("webgl is not supported. please use before version."),this.viewWidth=t.width,this.viewHeight=t.height,e},t.prototype.animate=function(t){var e,i=this,n=t.allTime,r=t.timingFun,o=t.ends,s=t.playGame,a=t.callback,h=Date.now(),l=h,c=new Promise((function(t){return e=t})),u=o.length,d=function(){if(i.curAimateBreaked)return e([!1,3]),void(i.curAimateBreaked=!1);var t=l-h;t>n&&(t=n);var c=t/n;c>1&&(c=1);var f=r.solve(c);f>=1&&(f=1);var p=new Array(u);o.forEach((function(t,e){p[e]=t*f})),s.apply(void 0,p),c<1?requestAnimationFrame(d):(a&&a(),e([!1,1])),l=Date.now()};return d(),c},t}(),I=function(t,e,i,n){var r,o=arguments.length,s=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(s=(o<3?r(s):o>3?r(e,i,s):r(e,i))||s);return o>3&&s&&Object.defineProperty(e,i,s),s},A=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},S=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]d?(w=d-g,m=!0):gc?(x=c-p,v=!0):p=0&&l<=n&&(m=!1,w=0),s<=r&&(v=!1,x=0),m||v?(this.isAnimating=!0,[4,e.eventsHanlder.handleTEndEnlarge(t,w,x,0)]):[3,2];case 1:return I.sent(),this.isAnimating=!1,[3,4];case 2:return this.moveEndTime=Date.now(),y={x:this.startX,y:this.startY},M={x:this.touchStartX,y:this.touchStartY},b=y.x-M.x,E=y.y-M.y,T=180*Math.atan2(E,b)/Math.PI,this.moveEndTime-this.moveStartTime<90&&Math.abs(b)+Math.abs(E)>5?(P={maxTop:c,minTop:u,maxLeft:d,minLeft:n-o},this.isAnimating=!0,[4,this.autoMove(T,h,a,P)]):[3,4];case 3:I.sent(),this.isAnimating=!1,I.label=4;case 4:return this.moveStartTime=0,[2]}}))}))},t.prototype.handleTEndEnNormal=function(t){return A(this,void 0,void 0,(function(){var e,i,n;return S(this,(function(r){switch(r.label){case 0:return this.isAnimating?[2]:(e=t.changedTouches[0].clientX,i=this.actionExecutor.eventsHanlder,0===(n=e-this.touchStartX)?[2]:(this.isAnimating=!0,[4,i.handleTEndEnNormal(t,n)]));case 1:return r.sent(),this.isAnimating=!1,[2]}}))}))},t.prototype.genFrame=function(){var t=this,e=this.options.imgs;!e||e.length,this.imgsNumber=e.length,this.curIndex=0;var i='\n
\n \n \n \n \n
\n
\n
\n '+("pc"==this.envClient?'
\n \n
\n
\n \n
':"")+'\n
\n \n
\n
\n \n
\n
\n ',n=/iphone/gi.test(window.navigator.userAgent)&&window.devicePixelRatio&&3===window.devicePixelRatio&&375===window.screen.width&&812===window.screen.height,r=/iphone/gi.test(window.navigator.userAgent)&&window.devicePixelRatio&&3===window.devicePixelRatio&&414===window.screen.width&&896===window.screen.height,o=/iphone/gi.test(window.navigator.userAgent)&&window.devicePixelRatio&&2===window.devicePixelRatio&&414===window.screen.width&&896===window.screen.height,s=n||r||o,a="\n ."+this.prefix+"imagePreviewer{\n position: fixed;\n top:0;\n left: 100%;\n width: 100%;\n height: 100%;\n background: "+function(e){switch(e){case"conBackground":return"pc"==t.envClient?"rgba(0,0,0,0.8)":"rgba(0,0,0,1)";case"imgWidth":return t.envClient,"100%";case"itemHeight":return"pc"==t.envClient?"100%":"auto";case"itemScroll":return"pc"==t.envClient?"auto ":"hidden";case"item-text-align":return"pc"==t.envClient?"center ":"initial";default:return""}}("conBackground")+";\n color:#fff;\n transform: translate3d(0,0,0);\n transition: left 0.5s;\n overflow:hidden;\n user-select: none;\n }\n \n ."+this.prefix+"imagePreviewer."+this.defToggleClass+"{\n left: 0%;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"close{\n position: absolute;\n top: 20px;\n right: 20px;\n z-index: 10;\n box-sizing: border-box;\n width: 22px;\n height: 22px;\n cursor:pointer;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"close svg{\n width: 100%;\n height: 100%; \n }\n ."+this.prefix+"imagePreviewer svg{\n overflow:visible;\n }\n ."+this.prefix+"imagePreviewer svg path{\n stroke: #948888;\n stroke-width: 30px;\n }\n \n ."+this.prefix+"imagePreviewer "+this.prefix+".close."+this.prefix+"scroll{\n height: 0;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"imgContainer{\n position: relative;\n height: 100%;\n font-size: 0;\n white-space: nowrap;\n }\n \n ."+this.prefix+"imagePreviewer ."+this.prefix+"bottom{\n position: absolute;\n bottom: "+(s?20:0)+"px;\n left: 20px;\n right: 20px;\n z-index: 10;\n padding: 0 10px;\n text-align: center;\n border-top: 1px solid rgba(255, 255, 255, .2);\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"bottom ."+this.prefix+"item{\n display:inline-block;\n width: 42px;\n height: 42px;\n cursor:pointer;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"bottom ."+this.prefix+"item svg{\n box-sizing: border-box;\n width: 100%;\n height: 100%;\n padding:10px;\n }\n ";if(this.ref=document.createElement("div"),this.ref.className=this.prefix+"imagePreviewer",this.ref.innerHTML=i,!document.querySelector("#"+this.prefix+"style")){var h=document.createElement("style");h.id=this.prefix+"style",h.innerHTML=a,document.querySelector("head").appendChild(h)}this.ref.querySelector("."+this.prefix+"imgContainer").append(this.actionExecutor.ref),document.body.appendChild(this.ref)},t.prototype.handleReausetAnimate=function(){window.requestAnimationFrame||(window.requestAnimationFrame=window.webkitRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60),0})},t.prototype.close=function(t){t.stopImmediatePropagation(),clearTimeout(this.performerClick),this[this.envClient+"BeforeClose"](),this.toggleClass(this.ref,this.defToggleClass)},t.prototype.pcBeforeClose=function(){document.body.style.overflow=document.body.dataset.imgPreOverflow},t.prototype.mobileBeforeClose=function(){},t.prototype.show=function(t){this.actionExecutor.curIndex=t,this.actionExecutor.draw(t),this.toggleClass(this.ref,this.defToggleClass)},t.prototype.mobileReadyShow=function(){},t.prototype.pcReadyShow=function(){var t=window.getComputedStyle(document.body);document.body.dataset.imgPreOverflow=t.overflow,document.body.style.overflow="hidden"},t.prototype.toggleClass=function(t,e){var i=t.className.split(" "),n=i.indexOf(e);-1!==n?i.splice(n,1):i.push(e),t.className=i.join(" ")},t.prototype.getMovePoints=function(t){var e=this;if(!(this.movePoints.length>this.maxMovePointCounts)){this.movePoints.push({x:t.touches[0].clientX,y:t.touches[0].clientY});this.addTouchEndTask("resetMovePoints",{priority:1,callback:function(){return e.movePoints=[]}})}},t.prototype.decideMoveDirection=function(){var t=this,e=this.movePoints.length,i=this.movePoints[e-1],n=this.movePoints[0],r=i.x-n.x,o=i.y-n.y,s=180*Math.atan2(o,r)/Math.PI;Math.abs(90-Math.abs(s))<30?this.fingerDirection="vertical":this.fingerDirection="horizontal";this.addTouchEndTask("resetFingerDirection",{priority:1,callback:function(){t.fingerDirection=""}})},t.prototype.destroy=function(){this.ref.parentNode.removeChild(this.ref),window.removeEventListener("resize",this.handleResize),window.removeEventListener("orientationchange",this.handleResize)},t.prototype.testEnv=function(){return/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)?"mobile":"pc"},t=I([o],t)}();T=D,[s,a,c].forEach((function(t){Object.getOwnPropertyNames(t.prototype).forEach((function(e){T.prototype[e]=t.prototype[e]}))})),t.ImagePreview=D,Object.defineProperty(t,"__esModule",{value:!0})})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).imagePreviewModule={})}(this,(function(t){"use strict";var e,i=(e=function(t,i){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(t,i)},function(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}),n=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},r=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]0?(h=-(i-s)*u,a=-(e-o)*u,l=1+u,c=1+u):(h=(i-s)*u,a=(e-o)*u,l=1-u,c=1-u),n.eventsHanlder.handleZoom(l,c,a,h),this.isZooming=!1,this.isAnimating=!1,this.actionExecutor.isEnlargement?this.ref.style.cursor="grab":this.ref.style.cursor="initial",[2]}))}))},e.prototype.handlePCDoubleClick=function(t){return n(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return this.isAnimating?[2]:(this.isAnimating=!0,[4,this.actionExecutor.eventsHanlder.handleDoubleClick({clientX:t.clientX,clientY:t.clientY})]);case 1:return e.sent(),this.isAnimating=!1,this.actionExecutor.isEnlargement?this.ref.style.cursor="grab":this.ref.style.cursor="initial",[2]}}))}))},e.prototype.handleMouseDown=function(t){var e=this,i=t.target.dataset.type;this[i]?this[i](t):(this.mouseDown=!0,this.actionExecutor.isEnlargement?(this.startX=t.clientX,this.startY=t.clientY,this.ref.style.cursor="grabbing"):this.ref.style.cursor="initial",Date.now()-this.lastClick0?"right":"left",s=this.actionExecutor.viewRect,a=s.left,h=s.right,l=this.actionExecutor.viewWidth/this.actionExecutor.dpr;if(this.fingerDirection)if(this.actionExecutor.isEnlargement)if(a>=0&&h<=l)if("right"!=o&&"left"!=o&&!this.isEnlargeMove||"horizontal"!=this.fingerDirection)this.handleMoveEnlage(t);else{this.isEnlargeMove=!0,this.handleMoveNormal(t);var c="resetEnlargeMove";this.addTouchEndTask(c,{priority:1,callback:function(){e.isEnlargeMove=!1}})}else if(i&&"right"==o||n&&"left"==o||this.isEnlargeMove){this.isEnlargeMove=!0,this.handleMoveNormal(t);c="resetEnlargeMove";this.addTouchEndTask(c,{priority:1,callback:function(){return e.isEnlargeMove=!1}})}else this.handleMoveEnlage(t);else this.handleMoveNormal(t);else{if(this.actionExecutor.isEnlargement&&(a<0||h>l)||!this.actionExecutor.isEnlargement)return void(!this.actionExecutor.isEnlargement||r||this.normalMoved?this.actionExecutor.isEnlargement?(r||this.normalMoved)&&(this.normalMoved?this.handleMoveNormal(t):"right"==o?i?this.handleMoveNormal(t):this.handleMoveEnlage(t):"left"==o&&n?this.handleMoveNormal(t):this.handleMoveEnlage(t)):this.handleMoveNormal(t):this.handleMoveEnlage(t));if(this.getMovePoints(t),this.movePoints.lengthn?p:0,s=Math.round(c)<0||Math.round(u)>r?g:0,e.eventsHanlder.handleMoveEnlage(a,s,0);this.addTouchEndTask("handleTendEnlarte",{priority:10,callback:this.handleTEndEnlarge.bind(this)}),this.startX=d,this.startY=f}},t.prototype.autoMove=function(t,e,i,n){var r=n.maxTop,o=n.minTop,s=n.maxLeft,a=n.minLeft,h=this.imgContainer.getBoundingClientRect(),l=h.width,c=h.height,u=this.actionExecutor,d=u.viewRect,f=u.eventsHanlder,p=d,g=p.top,v=p.bottom,m=p.left,w=p.right;t=t/180*Math.PI;var x=e+300*Math.cos(t),y=i+300*Math.sin(t);x>s?x=s:xr?y=r:y=0&&w<=l||(M=x-e),g>=0&&v<=c||(b=y-i),f.moveCurPlaneTo(M,b,0)},t}(),a=function(){function t(){}return t.prototype.handleZoom=function(t){if(!(this.isNormalMove&&this.normalMoved||this.isAnimating||this.actionExecutor.isLoadingError())){this.isZooming||(this.curStartPoint1={x:this.curPoint1.x,y:this.curPoint1.y},this.curStartPoint2={x:this.curPoint2.x,y:this.curPoint2.y}),this.isZooming=!0,this.isAnimating=!0;var e=this.actionExecutor,i=Math.pow(this.curPoint1.x-this.curPoint2.x,2)+Math.pow(this.curPoint1.y-this.curPoint2.y,2),n=Math.pow(t.touches[0].clientX-t.touches[1].clientX,2)+Math.pow(t.touches[0].clientY-t.touches[1].clientY,2),r=(this.curStartPoint1.x+this.curStartPoint2.x)/2,o=(this.curStartPoint1.y+this.curStartPoint2.y)/2,s=e.viewWidth/(2*e.dpr),a=e.viewHeight/(2*e.dpr);this.curPoint1.x=t.touches[0].clientX,this.curPoint1.y=t.touches[0].clientY,this.curPoint2.x=t.touches[1].clientX,this.curPoint2.y=t.touches[1].clientY;var h=0,l=0,c=1,u=1;if(i>n)l=(o-a)*this.zoomScale,h=(r-s)*this.zoomScale,c=1-this.zoomScale,u=1-this.zoomScale;else{if(!(i0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]d;){if(i=this.getX(r)-t,Math.abs(i)0?u=r:d=r,r=(u+d)/2}return r},t.prototype.solve=function(t){return this.cachedY.get(t)||this.cachedY.set(t,this.getY(this.solveCurveX(t))),this.cachedY.get(t)},t}(),p=new f(0,0,1,1);new f(.25,.1,.25,1),new f(.42,0,1,1),new f(0,0,.58,1),new f(.42,0,.58,1);var g=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},v=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]4*s||(l*t=this.throldDeg?(o=t.curIndex,-1!=(s=t.curIndex+1*r)&&s!=t.imgUrls.length?[3,2]:(t.curIndex=o,[4,t.rotate(-n)])):[3,6];case 1:return a.sent(),[3,5];case 2:return[4,t.rotate(r*Math.PI/2-n)];case 3:return a.sent(),t.curIndex=s,t.modelMatrix=t.baseModel=t.initialModel,t.gl.uniformMatrix4fv(t.gl.getUniformLocation(t.shaderProgram,"uModelViewMatrix"),!1,t.modelMatrix),[4,t.draw(s)];case 4:a.sent(),a.label=5;case 5:return[3,8];case 6:return[4,t.rotate(-n)];case 7:a.sent(),a.label=8;case 8:return t.modelMatrix=t.baseModel=t.initialModel,[2,"handled"]}}))}))},t.prototype.handleTEndEnlarge=function(t,e,i,n){return g(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return t=this.viewInstance,e*=t.dpr,i*=-t.dpr,t.dpr,this.curBehaviorCanBreak=!0,[4,t.moveCurPlane(e,i,0)];case 1:return n.sent(),this.curBehaviorCanBreak=!1,0!==e&&(t.isBoudriedSide=!0),[2]}}))}))},t.prototype.moveCurPlaneTo=function(t,e,i){return g(this,void 0,void 0,(function(){var i;return v(this,(function(n){switch(n.label){case 0:return i=this.viewInstance,t*=i.dpr,e*=-i.dpr,i.dpr,this.curBehaviorCanBreak=!0,[4,i.moveCurPlane(t,e,0)];case 1:return n.sent(),this.curBehaviorCanBreak=!1,[2]}}))}))},t}();var w=function(t,e,i){var n=t.naturalWidth,r=t.naturalHeight,o=document.createElement("canvas"),s=o.getContext("2d"),a=window.devicePixelRatio||1;return o.width=e*a,o.height=i*a,s.drawImage(t,0,0,n,r,0,0,e*a,i*a),o},x=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},y=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]n&&(e=n-1,r=n),this.imgUrls.splice(e+1,0,t),e+1>this.imgs.length?this.imgs[r]=null:this.imgs.splice(e+1,0,null),t instanceof Image)if(void 0===t._id&&(t._id=this.imgId++),t.complete)this.imgUrls[e+1]=this.validateImg(t);else{var o=function(){var e=i.imgUrls.indexOf(t);t.loadError=!0,~[-2,-1,0].indexOf(e-i.curIndex)&&i.draw(i.curIndex)};t.addEventListener("load",(function(){var e=i.imgUrls.indexOf(t);i.imgUrls[e]=i.validateImg(t),~[-2,-1,0].indexOf(e-i.curIndex)&&i.draw(i.curIndex)})),t.addEventListener("error",o),t.addEventListener("abort",o)}~[-2,-1,0].indexOf(e-this.curIndex)&&this.draw(this.curIndex)},t.prototype.delImg=function(t){var e=this.imgUrls.length;t<=-1?t=0:t>=e&&(t=e-1),this.imgUrls.splice(t,1),this.imgs[t]&&this.textures.delete(this.imgs[t]._id),this.imgs.splice(t,1),t-=this.curIndex,~[-1,0,1].indexOf(t)&&this.draw(this.curIndex)},t.prototype.initOtherTexture=function(){var t=this,e=this.gl,i=e.createTexture();this.texturesOther.set(0,i),e.bindTexture(e.TEXTURE_2D,i),i.cubicBgd=!0;e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,new Uint8Array([0,0,0,255]));var n=new Image;n.onload=function(){var i=e.createTexture();t.texturesOther.set(1,i),e.bindTexture(e.TEXTURE_2D,i),t.texImage(n),t.setTexParameteri(n.width,n.height)},n.src="data:image/svg+xml;base64,PHN2ZyB0PSIxNjI1ODExNDgwNTgyIiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEzNDIgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjYwNjkiIHdpZHRoPSIyMDAiIGhlaWdodD0iMjAwIj48cGF0aCBkPSJNMTIxNi4zNTcgMTM5LjAzYy0xMC4xNTctMTEuNDI3LTI0Ljc1OS0xNy43NzUtMzkuOTk1LTE4LjQxTDc0My40IDEwMy40OGwtMzIuMzc3IDczLjAwNiA0NS4wNzQgMTM1Ljg1Ni04MS4yNiAxNTQuMjY3IDMzLjAxMiAxMjQuNDI5IDgyLjUzIDEwNi42NTMgMTE5LjM1LTEwOS44MjdjMTEuNDI3LTEwLjc5MyAyOS44MzctMTAuMTU4IDM5Ljk5NCAxLjkwNGwxNTIuOTk3IDE2NS42OTRjMTAuNzkzIDExLjQyNyAxMC4xNTggMjkuODM3LTEuMjcgNDAuNjMtNS43MTMgNS4wNzgtMTIuNjk2IDguMjUzLTIwLjMxNCA3LjYxOGwtNDE5LjYzLTE2LjUwNi0yMC45NSA2MC4zMSAyMi44NTQgNTMuOTYyIDQ4Mi40OCAxOC40MWMzMS43NDIgMS4yNyA1OC40MDUtMjMuNDkgNTkuMDQtNTUuMjMxbDI2LjY2My02ODQuMzZjMC42MzUtMTUuMjM2LTQuNDQ0LTMwLjQ3Mi0xNS4yMzYtNDEuMjY1ek05MDYuNTU0IDQ1My4yNzdjLTQ3LjYxMy0xLjkwNC04NC40MzQtNDEuOS04Mi41My04OC44NzggMS45MDUtNDcuNjEzIDQxLjktODQuNDM0IDg4Ljg3OS04Mi41MyA0Ni45NzggMS45MDUgODQuNDM0IDQxLjkgODIuNTMgODguODc5LTEuOTA1IDQ2Ljk3OC00MS45IDg0LjQzNC04OC44NzkgODIuNTN6TTU5NS40ODIgODQ4LjE1bDE0LjYwMS02My40ODQtMzQwLjkxIDIzLjQ4OWMtMTUuODcxIDEuMjctMjkuMjAzLTEwLjE1OC0zMC40NzItMjYuMDI5YTI4LjEyIDI4LjEyIDAgMCAxIDYuOTgzLTIwLjk1TDQ5OC4zNSA0NzEuMDUzYzUuMDc5LTYuMzQ5IDEyLjY5Ny05LjUyMyAyMC45NS05LjUyMyA3LjYxOCAwIDE1LjIzNiAzLjE3NCAyMC45NSA4Ljg4OGw4NC40MzMgODguMjQzLTM2LjE4Ni05My45NTcgNjQuNzU0LTE2Mi41Mi01OS4wNC0xMzAuMTQyIDI0LjEyNC03NC45MTEtNDY0LjcwNCAzMi4zNzdjLTMxLjc0MiAxLjkwNC01NS4yMzIgMjkuMjAyLTUzLjMyNyA2MC45NDVsNDYuOTc4IDY4NC4zNmMwLjYzNSAxNS4yMzUgNy42MTggMjkuMjAyIDE5LjY4IDM4LjcyNSAxMS40MjggMTAuMTU3IDI2LjAyOSAxNS4yMzYgNDEuMjY1IDEzLjk2Nmw0MTUuMTg3LTI4LjU2OC0yNy45MzMtNTAuNzg3eiIgcC1pZD0iNjA3MCIgZmlsbD0iI2JmYmZiZiIvPjwvc3ZnPg=="},t.prototype.initData=function(){this.draw(this.curIndex)},t.prototype.slideNext=function(){return x(this,void 0,void 0,(function(){var t=this;return y(this,(function(e){return this.curIndex==this.imgUrls.length-1?[2,[!0]]:[2,this.slide(.5*Math.PI,(function(){return t.curIndex++}))]}))}))},t.prototype.slideBefore=function(){return x(this,void 0,void 0,(function(){var t=this;return y(this,(function(e){return 0==this.curIndex?[2,[!0]]:[2,this.slide(-.5*Math.PI,(function(){return t.curIndex--}))]}))}))},t.prototype.slide=function(t,e){return x(this,void 0,void 0,(function(){return y(this,(function(i){switch(i.label){case 0:return this.baseModel=this.modelMatrix,[4,this.rotate(t)];case 1:return i.sent(),e(),this.modelMatrix=this.baseModel=this.initialModel,this.gl.uniformMatrix4fv(this.gl.getUniformLocation(this.shaderProgram,"uModelViewMatrix"),!1,this.modelMatrix),[4,this.draw(this.curIndex)];case 2:return i.sent(),this.modelMatrix=this.baseModel=this.initialModel,[2,[!1]]}}))}))},t.prototype.rotate=function(t){var e,i=this;return this.animate({allTime:this.defaultAnimateTime,timingFun:p,ends:[t],playGame:(e=i.rotatePosition.bind(i),function(t){i.clear(),e(t)})})},t.prototype.rotateZ=function(t){var e=this;this.curPlane=this.positions.slice(this.curPointAt,this.curPointAt+16);var i=this.imgShape,n=this.imgShapeInitinal;this.imgShape=d.multiplyPoint(i,d.rotateZMatrix(t)),this.imgShapeInitinal=d.multiplyPoint(n,d.rotateZMatrix(t));var r=this.curCenterCoordinate,o=-r[0],s=-r[1];return this.animate({allTime:this.defaultAnimateTime,timingFun:p,ends:[t,o,s],playGame:function(){for(var t=[],i=0;ic?c:this.viewWidth):(i=c,n=u),p=-(t-r)*(d=i/a-1),g=(e-o)*(f=n/h-1),this.curIsLongImg()&&(p=0);return[d,f,p,g]},t.prototype.decideImgViewSize=function(t,e){var i=0,n=0;return(n=e/t*(i=this.viewWidth>=t?t:this.viewWidth))>this.viewHeight&&(i=(n=this.viewHeight)*t/e),[i,n]},t.prototype.draw=function(t){this.positions=[];for(var e=this.imgUrls.length,i=0,n=0,r=t-1;r<=t+1;r++)if(-1!==r&&r<=e-1){var o=void 0;this.imgs[r]?o=this.imgs[r]:"string"==typeof this.imgUrls[r]?o=this.loadImage(this.imgUrls[r],r):void 0===(o=this.imgUrls[r])._id&&(this.imgUrls[r]=this.validateImg(o),o=this.imgUrls[r]),this.imgs[r]=o;var s=o.naturalWidth,a=o.naturalHeight;o.loadError&&(s=a=200);var h=this.decideImgViewSize(s*this.dpr,a*this.dpr),l=h[0],c=h[1];r==this.curIndex&&(this.imgShape=[s*this.dpr,a*this.dpr,0,1],this.imgShapeInitinal=[l,c,0,1]),this.genPostion(l,c,r),i=Math.max(l,i),n=Math.max(c,n)}this.generateCube(i,n),this.bindPostion(),this.drawPosition()},t.prototype.createPerspectiveMatrix=function(){var t=this.fieldOfViewInRadians,e=this.viewWidth/this.viewHeight,i=this.zNear,n=this.zFar,r=1/Math.tan(t/2),o=1/(i-n);return[r/e,0,0,0,0,r,0,0,0,0,(i+n)*o,-1,0,0,i*n*o*2,0]},Object.defineProperty(t.prototype,"curPointAt",{get:function(){var t=64;return 0==this.curIndex&&(t=48),t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"IsBoundaryLeft",{get:function(){var t=this.viewRect;return Math.round(t.left)>=0&&this.isBoudriedSide},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isBoundaryRight",{get:function(){var t=this.viewRect;return Math.round(t.right*this.dpr)<=Math.round(this.viewWidth/1)&&this.isBoudriedSide},enumerable:!1,configurable:!0}),t.prototype.curIsLongImg=function(){var t=this.imgShape,e=t[0],i=t[1];return 2*Math.abs(e)<=Math.abs(i)},Object.defineProperty(t.prototype,"curCenterCoordinate",{get:function(){var t=this.curPointAt;return[(this.positions[t]+this.positions[t+8])/2,(this.positions[t+1]+this.positions[t+9])/2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"viewRect",{get:function(){for(var t=-this.viewWidth/2,e=this.viewHeight/2,i=this.curPointAt,n=1/0,r=-1/0,o=1/0,s=-1/0,a=i;athis.viewWidth||e.height*this.dpr-1>this.viewHeight},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isEnlargementForScale",{get:function(){var t=this.imgShapeInitinal,e=t[0],i=t[1],n=this.viewRect;return Math.round(n.width*this.dpr)>Math.round(Math.abs(e))||Math.round(n.height*this.dpr)>Math.round(Math.abs(i))},enumerable:!1,configurable:!0}),t.prototype.isLoadingError=function(t){return 0==arguments.length&&(t=this.curIndex),this.imgs[t].loadError},t.prototype.loadImage=function(t,e){var i=this,n=new Image;return n._id=this.imgId++,this.imgs[e]=n,n.onload=function(){i.handleImgLoaded(n,e)},n.onerror=function(){n.loadError=!0,i.handleImgLoaded(n,e)},n.onabort=function(){n.loadError=!0,i.handleImgLoaded(n,e)},n.crossOrigin="anonymous",n.src=t,n},t.prototype.handleImgLoaded=function(t,e){e=this.imgs.indexOf(t),t.loadError||(t=this.validateImg(t),this.imgs[e]=t),~[-1,0,1].indexOf(e-this.curIndex)&&(this.updatePosition(t,e-this.curIndex),this.bindPostion(),this.drawPosition())},t.prototype.validateImg=function(t){var e=this.gl.MAX_TEXTURE_SIZE,i=t.naturalWidth,n=t.naturalHeight;if(Math.max(n,i)>=e){var r=this.dpr,o=e/r,s=n/i*o;s>=e&&(o=i/n*(s=e/r));var a=w(t,o,s);return a._id=this.imgId++,a.naturalHeight=s,a.naturalWidth=o,a.complete=!0,a}return t},t.prototype.clear=function(){var t=this.gl;t.clearColor(0,0,0,1),t.clearDepth(1),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT)},t.prototype.bindShader=function(t,e,i){var n=this.loadShader(t,t.VERTEX_SHADER,i),r=this.loadShader(t,t.FRAGMENT_SHADER,e),o=t.createProgram();return t.attachShader(o,n),t.attachShader(o,r),t.linkProgram(o),t.getProgramParameter(o,t.LINK_STATUS)?o:(console.error("Unable to initialize the shader program: "+t.getProgramInfoLog(o)),null)},t.prototype.loadShader=function(t,e,i){var n=t.createShader(e);return t.shaderSource(n,i),t.compileShader(n),t.getShaderParameter(n,t.COMPILE_STATUS)?n:(console.error("An error occurred compiling the shaders: "+t.getShaderInfoLog(n)),t.deleteShader(n),null)},t.prototype.createPlane=function(t){return t.x,t.y,t.width,t.height,{}},t.prototype.intialView=function(){var t=document.createElement("canvas");t.style.cssText="\n position: absolute;\n top: 0;\n left:0;\n z-index: 9;\n width:"+window.innerWidth+"px;\n height:"+window.innerHeight+"px;\n user-select:none;\n font-size:0;\n ",t.width=window.innerWidth*this.dpr,t.height=window.innerHeight*this.dpr,this.ref=t;var e=t.getContext("webgl",{antialias:!0});return e||console.error("webgl is not supported. please use before version."),this.viewWidth=t.width,this.viewHeight=t.height,e},t.prototype.animate=function(t){var e,i=this,n=t.allTime,r=t.timingFun,o=t.ends,s=t.playGame,a=t.callback,h=Date.now(),l=h,c=new Promise((function(t){return e=t})),u=o.length,d=function(){if(i.curAimateBreaked)return e([!1,3]),void(i.curAimateBreaked=!1);var t=l-h;t>n&&(t=n);var c=t/n;c>1&&(c=1);var f=r.solve(c);f>=1&&(f=1);var p=new Array(u);o.forEach((function(t,e){p[e]=t*f})),s.apply(void 0,p),c<1?requestAnimationFrame(d):(a&&a(),e([!1,1])),l=Date.now()};return d(),c},t}(),I=function(t,e,i,n){var r,o=arguments.length,s=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(s=(o<3?r(s):o>3?r(e,i,s):r(e,i))||s);return o>3&&s&&Object.defineProperty(e,i,s),s},A=function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))},S=function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]d?(w=d-g,m=!0):gc?(x=c-p,v=!0):p=0&&l<=n&&(m=!1,w=0),s<=r&&(v=!1,x=0),m||v?(this.isAnimating=!0,[4,e.eventsHanlder.handleTEndEnlarge(t,w,x,0)]):[3,2];case 1:return I.sent(),this.isAnimating=!1,[3,4];case 2:return this.moveEndTime=Date.now(),y={x:this.startX,y:this.startY},M={x:this.touchStartX,y:this.touchStartY},b=y.x-M.x,E=y.y-M.y,T=180*Math.atan2(E,b)/Math.PI,this.moveEndTime-this.moveStartTime<90&&Math.abs(b)+Math.abs(E)>5?(P={maxTop:c,minTop:u,maxLeft:d,minLeft:n-o},this.isAnimating=!0,[4,this.autoMove(T,h,a,P)]):[3,4];case 3:I.sent(),this.isAnimating=!1,I.label=4;case 4:return this.moveStartTime=0,[2]}}))}))},t.prototype.handleTEndEnNormal=function(t){return A(this,void 0,void 0,(function(){var e,i,n;return S(this,(function(r){switch(r.label){case 0:return this.isAnimating?[2]:(e=t.changedTouches[0].clientX,i=this.actionExecutor.eventsHanlder,0===(n=e-this.touchStartX)?[2]:(this.isAnimating=!0,[4,i.handleTEndEnNormal(t,n)]));case 1:return r.sent(),this.isAnimating=!1,[2]}}))}))},t.prototype.genFrame=function(){var t=this,e=this.options.imgs;!e||e.length,this.imgsNumber=e.length,this.curIndex=0;var i='\n
\n \n \n \n \n
\n
\n
\n '+("pc"==this.envClient?'
\n \n
\n
\n \n
':"")+'\n
\n \n
\n
\n \n
\n
\n ',n=/iphone/gi.test(window.navigator.userAgent)&&window.devicePixelRatio&&3===window.devicePixelRatio&&375===window.screen.width&&812===window.screen.height,r=/iphone/gi.test(window.navigator.userAgent)&&window.devicePixelRatio&&3===window.devicePixelRatio&&414===window.screen.width&&896===window.screen.height,o=/iphone/gi.test(window.navigator.userAgent)&&window.devicePixelRatio&&2===window.devicePixelRatio&&414===window.screen.width&&896===window.screen.height,s=n||r||o,a="\n ."+this.prefix+"imagePreviewer{\n position: fixed;\n top:0;\n left: 100%;\n width: 100%;\n height: 100%;\n background: "+function(e){switch(e){case"conBackground":return"pc"==t.envClient?"rgba(0,0,0,0.8)":"rgba(0,0,0,1)";case"imgWidth":return t.envClient,"100%";case"itemHeight":return"pc"==t.envClient?"100%":"auto";case"itemScroll":return"pc"==t.envClient?"auto ":"hidden";case"item-text-align":return"pc"==t.envClient?"center ":"initial";default:return""}}("conBackground")+";\n color:#fff;\n transform: translate3d(0,0,0);\n transition: left 0.5s;\n overflow:hidden;\n user-select: none;\n }\n \n ."+this.prefix+"imagePreviewer."+this.defToggleClass+"{\n left: 0%;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"close{\n position: absolute;\n top: 20px;\n right: 20px;\n z-index: 10;\n box-sizing: border-box;\n width: 22px;\n height: 22px;\n cursor:pointer;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"close svg{\n width: 100%;\n height: 100%; \n }\n ."+this.prefix+"imagePreviewer svg{\n overflow:visible;\n }\n ."+this.prefix+"imagePreviewer svg path{\n stroke: #948888;\n stroke-width: 30px;\n }\n \n ."+this.prefix+"imagePreviewer "+this.prefix+".close."+this.prefix+"scroll{\n height: 0;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"imgContainer{\n position: relative;\n height: 100%;\n font-size: 0;\n white-space: nowrap;\n }\n \n ."+this.prefix+"imagePreviewer ."+this.prefix+"bottom{\n position: absolute;\n bottom: "+(s?20:0)+"px;\n left: 20px;\n right: 20px;\n z-index: 10;\n padding: 0 10px;\n text-align: center;\n border-top: 1px solid rgba(255, 255, 255, .2);\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"bottom ."+this.prefix+"item{\n display:inline-block;\n width: 42px;\n height: 42px;\n cursor:pointer;\n }\n ."+this.prefix+"imagePreviewer ."+this.prefix+"bottom ."+this.prefix+"item svg{\n box-sizing: border-box;\n width: 100%;\n height: 100%;\n padding:10px;\n }\n ";if(this.ref=document.createElement("div"),this.ref.className=this.prefix+"imagePreviewer",this.ref.innerHTML=i,!document.querySelector("#"+this.prefix+"style")){var h=document.createElement("style");h.id=this.prefix+"style",h.innerHTML=a,document.querySelector("head").appendChild(h)}this.ref.querySelector("."+this.prefix+"imgContainer").append(this.actionExecutor.ref),document.body.appendChild(this.ref)},t.prototype.handleReausetAnimate=function(){window.requestAnimationFrame||(window.requestAnimationFrame=window.webkitRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60),0})},t.prototype.close=function(t){t.stopImmediatePropagation(),clearTimeout(this.performerClick),this[this.envClient+"BeforeClose"](),this.toggleClass(this.ref,this.defToggleClass)},t.prototype.pcBeforeClose=function(){document.body.style.overflow=document.body.dataset.imgPreOverflow},t.prototype.mobileBeforeClose=function(){},t.prototype.show=function(t){this.actionExecutor.curIndex=t,this.actionExecutor.draw(t),this.toggleClass(this.ref,this.defToggleClass)},t.prototype.mobileReadyShow=function(){},t.prototype.pcReadyShow=function(){var t=window.getComputedStyle(document.body);document.body.dataset.imgPreOverflow=t.overflow,document.body.style.overflow="hidden"},t.prototype.toggleClass=function(t,e){var i=t.className.split(" "),n=i.indexOf(e);-1!==n?i.splice(n,1):i.push(e),t.className=i.join(" ")},t.prototype.getMovePoints=function(t){var e=this;if(!(this.movePoints.length>this.maxMovePointCounts)){this.movePoints.push({x:t.touches[0].clientX,y:t.touches[0].clientY});this.addTouchEndTask("resetMovePoints",{priority:1,callback:function(){return e.movePoints=[]}})}},t.prototype.decideMoveDirection=function(){var t=this,e=this.movePoints.length,i=this.movePoints[e-1],n=this.movePoints[0],r=i.x-n.x,o=i.y-n.y,s=180*Math.atan2(o,r)/Math.PI;Math.abs(90-Math.abs(s))<30?this.fingerDirection="vertical":this.fingerDirection="horizontal";this.addTouchEndTask("resetFingerDirection",{priority:1,callback:function(){t.fingerDirection=""}})},t.prototype.destroy=function(){this.ref.parentNode.removeChild(this.ref),window.removeEventListener("resize",this.handleResize),window.removeEventListener("orientationchange",this.handleResize)},t.prototype.testEnv=function(){return/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)?"mobile":"pc"},t=I([o],t)}();T=D,[s,a,c].forEach((function(t){Object.getOwnPropertyNames(t.prototype).forEach((function(e){T.prototype[e]=t.prototype[e]}))})),t.ImagePreview=D,Object.defineProperty(t,"__esModule",{value:!0})})); diff --git a/release/image-preview/image-preview-umd.js b/release/image-preview/image-preview-umd.js index d1e71ff..6c50948 100644 --- a/release/image-preview/image-preview-umd.js +++ b/release/image-preview/image-preview-umd.js @@ -768,6 +768,7 @@ var cubicBezier = (function () { function cubicBezier(x1, y1, x2, y2) { + this.cachedY = new Map(); this.precision = 1e-5; this.p1 = { x: x1, @@ -827,7 +828,10 @@ return t2; }; cubicBezier.prototype.solve = function (x) { - return this.getY(this.solveCurveX(x)); + if (!this.cachedY.get(x)) { + this.cachedY.set(x, this.getY(this.solveCurveX(x))); + } + return this.cachedY.get(x); }; return cubicBezier; }()); @@ -1345,7 +1349,8 @@ }; webGl.prototype.genPostion = function (width, height, index) { var _a; - var z = -(this.viewHeight) / (2 * Math.tan(this.fieldOfViewInRadians / 2)) - forDev; + var zNearHeight = (2 * Math.tan(this.fieldOfViewInRadians / 2)); + var z = -(this.viewHeight) / (zNearHeight) - forDev; var viewWidth = this.viewWidth; var sideZAxis = z - (viewWidth - width) / 2; var positionsMap = [ diff --git a/release/source/animation/animateJs.js b/release/source/animation/animateJs.js index 2b77892..b20b5c3 100644 --- a/release/source/animation/animateJs.js +++ b/release/source/animation/animateJs.js @@ -1,5 +1,6 @@ var cubicBezier = (function () { function cubicBezier(x1, y1, x2, y2) { + this.cachedY = new Map(); this.precision = 1e-5; this.p1 = { x: x1, @@ -61,7 +62,10 @@ var cubicBezier = (function () { return t2; }; cubicBezier.prototype.solve = function (x) { - return this.getY(this.solveCurveX(x)); + if (!this.cachedY.get(x)) { + this.cachedY.set(x, this.getY(this.solveCurveX(x))); + } + return this.cachedY.get(x); }; return cubicBezier; }()); diff --git a/release/source/webgl/index.js b/release/source/webgl/index.js index 11b5428..c9443bd 100644 --- a/release/source/webgl/index.js +++ b/release/source/webgl/index.js @@ -310,7 +310,8 @@ var webGl = (function () { }; webGl.prototype.genPostion = function (width, height, index) { var _a; - var z = -(this.viewHeight) / (2 * Math.tan(this.fieldOfViewInRadians / 2)) - forDev; + var zNearHeight = (2 * Math.tan(this.fieldOfViewInRadians / 2)); + var z = -(this.viewHeight) / (zNearHeight) - forDev; var viewWidth = this.viewWidth; var sideZAxis = z - (viewWidth - width) / 2; var positionsMap = [ diff --git a/scripts/genModule.cmd b/scripts/genModule.cmd deleted file mode 100644 index b9083f8..0000000 --- a/scripts/genModule.cmd +++ /dev/null @@ -1,4 +0,0 @@ -cd scripts -node generateModule.js -cd .. -copy .\release\image-preview\image-preview-iife.js .\example\js\ \ No newline at end of file diff --git a/scripts/genModule.sh b/scripts/genModule.sh new file mode 100755 index 0000000..8f35465 --- /dev/null +++ b/scripts/genModule.sh @@ -0,0 +1,5 @@ +#!/bin/bash +cd scripts +node generateModule.js +cd .. +cp './release/image-preview/image-preview-iife.js' './example/js/' \ No newline at end of file diff --git a/scripts/generateModule.js b/scripts/generateModule.js index f943028..2dcf8b6 100644 --- a/scripts/generateModule.js +++ b/scripts/generateModule.js @@ -7,9 +7,9 @@ try{ function compile(index,mini){ let mod = moduler[index]; let mininame = mini ? '-min': ''; - let filename = `${releasePath}\\image-preview-${mod}${mininame}.js`; + let filename = `${releasePath}/image-preview-${mod}${mininame}.js`; let miniParam = mini ? '--compact' : ''; - childProcess.exec(`..\\node_modules\\.bin\\rollup -c -f ${mod} -o ${filename} ${miniParam}`,(err,stdout)=>{ + childProcess.exec(`../node_modules/.bin/rollup -c -f ${mod} -o ${filename} ${miniParam}`,(err,stdout)=>{ if(err){ console.log(err) console.log('编译失败') diff --git a/src/animation/animateJs.ts b/src/animation/animateJs.ts index 8031a52..b1713ed 100644 --- a/src/animation/animateJs.ts +++ b/src/animation/animateJs.ts @@ -12,6 +12,7 @@ type coordinate = { export class cubicBezier{ p1: coordinate p2: coordinate + cachedY: Map = new Map(); precision = 1e-5; constructor(x1,y1,x2,y2){ this.p1 = { @@ -89,7 +90,10 @@ export class cubicBezier{ return t2; } solve(x:number){ - return this.getY( this.solveCurveX(x) ) + if( !this.cachedY.get(x)){ + this.cachedY.set(x,this.getY( this.solveCurveX(x) )) + } + return this.cachedY.get(x) } } export var linear = new cubicBezier(0, 0, 1, 1); diff --git a/src/core/image-preview.ts b/src/core/image-preview.ts index 8f1823a..5732a30 100644 --- a/src/core/image-preview.ts +++ b/src/core/image-preview.ts @@ -1,5 +1,5 @@ /** - * image-preview [2.1.0] + * image-preview [2.1.1] * author:zilong * https://github.com/daxiazilong * Released under the MIT License diff --git a/src/webgl/index.ts b/src/webgl/index.ts index 575d00b..9b56d07 100644 --- a/src/webgl/index.ts +++ b/src/webgl/index.ts @@ -311,7 +311,12 @@ class webGl { }) } genPostion(width: number, height: number,index:number) { - const z = -(this.viewHeight) / (2 * Math.tan(this.fieldOfViewInRadians / 2)) - forDev; + // zNearHeight = zNear * 2tan + // z zNear + // - = - => z = viewHeight / 2tan + // viewHeight zNearHeight + const zNearHeight = (2 * Math.tan(this.fieldOfViewInRadians / 2)); + const z = -(this.viewHeight) / (zNearHeight) - forDev; const viewWidth = this.viewWidth; let sideZAxis = z - ( viewWidth - width ) / 2;