text: window.Zoomage=function(e){var s={};function n(t){if(s[t])return s[t].exports;var i=s[t]={i:t,l:!1,exports:{}};return e[t].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=s,n.d=function(t,i,e){n.o(t,i)||Object.defineProperty(t,i,{enumerable:!0,get:e})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(i,t){if(1&t&&(i=n(i)),8&t)return i;if(4&t&&"object"==typeof i&&i&&i.__esModule)return i;var e=Object.create(null);if(n.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:i}),2&t&&"string"!=typeof i)for(var s in i)n.d(e,s,function(t){return i[t]}.bind(null,s));return e},n.n=function(t){var i=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(i,"a",i),i},n.o=function(t,i){return Object.prototype.hasOwnProperty.call(t,i)},n.p="",n(n.s=1)}([function(i,t){function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function s(t){return"function"==typeof Symbol&&"symbol"===e(Symbol.iterator)?i.exports=s=function(t){return e(t)}:i.exports=s=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":e(t)},s(t)}i.exports=s},function(i,e,s){"use strict";s.r(e);var n=s(0),o=s.n(n),h=function(t){if(!t||!t.container)throw"[Zoomage.js Error] Zoomage constructor: missing arguments [container].";this.container=t.container,this.canvas=document.createElement("canvas"),this.container.appendChild(this.canvas),this.context=this.canvas.getContext("2d"),this.onZoom=t.onZoom||null,this.onRotate=t.onRotate||null,this.onDrag=t.onDrag||null,this.context.save(),this.dbclickZoomThreshold=Math.abs(t.dbclickZoomThreshold)||.1,this.maxZoom=Math.abs(t.maxZoom)||2,this.minZoom=Math.abs(t.minZoom)||.2,this.enableGestureRotate=t.enableGestureRotate||!1,this.enableDesktop=t.enableDesktop||!1,this.imgTexture=new Image,this.isImgLoaded=!1,this.isFirstTimeLoad=!0,this.lastZoomScale=null,this.lastX=null,this.lastY=null,this.zoomD=1,this.mdown=!1,this.lastTouchEndTimestamp=null,this.lastTouchEndObject=null,this.animateHandle=null,this.dbclickZoomToggle=!0,this._checkRequestAnimationFrame(),this.enableGestureRotate?("transform"in document.body.style?this.prefixedTransform="transform":"webkitTransform"in document.body.style&&(this.prefixedTransform="webkitTransform"),this._setEventListenersTransform(),requestAnimationFrame(this._animateTransform.bind(this))):(this.canvas.style.width="100%",this.canvas.style.height="100%",this.canvas.width=this.canvas.clientWidth,this.canvas.height=this.canvas.clientHeight,this._setEventListenersCanvas(),requestAnimationFrame(this._animateCanvas.bind(this)))};h.prototype={_animateTransform:function(){this.zoomD>this.maxZoom?this.zoomD=this.maxZoom:this.zoomD<this.minZoom&&(this.zoomD=this.minZoom),this.isImgLoaded&&(this.canvas.style[this.prefixedTransform]="translate("+this.moveXD+"px,"+this.moveYD+"px) translateZ(0) scale("+this.zoomD+") rotate("+this.rotate.angle+"deg)"),this.isFirstTimeLoad&&this.isImgLoaded&&(this.context.drawImage(this.imgTexture,this.position.x,this.position.y,this.scale.x*this.imgTexture.width,this.scale.y*this.imgTexture.height),this.isFirstTimeLoad=!1),requestAnimationFrame(this._animateTransform.bind(this))},_animateCanvas:function(){null!==this.imgTexture.src&&(this.isOnTouching||this.mdown?this.context.clearRect(0,0,this.canvas.width,this.canvas.height):(this.context.restore(),this.context.save()),(this.isOnTouching||this.isFirstTimeLoad||this.mdown)&&this.isImgLoaded&&(this.context.drawImage(this.imgTexture,this.position.x,this.position.y,this.scale.x*this.imgTexture.width,this.scale.y*this.imgTexture.height),this.isFirstTimeLoad=!1),requestAnimationFrame(this._animateCanvas.bind(this)))},_gesturePinchZoom:function(t){var i=!1;if(2<=t.length){var e=t[0],s=t[1],n=Math.sqrt(Math.pow(s.pageX-e.pageX,2)+Math.pow(s.pageY-e.pageY,2));this.lastZoomScale&&(i=n-this.lastZoomScale),this.lastZoomScale=n}return i},_enableGestureRotate:function(t){if(2<=t.length)var i=t[0],e=t[1],s=e.pageX-i.pageX,n=e.pageY-i.pageY,o=180*Math.atan2(n,s)/Math.PI;return{o:i,a:o}},_doZoom:function(t){if(t){var i=this.scale.x,e=this.scale.x+t,s=e-i,n=this.imgTexture.width*s,o=this.imgTexture.height*s,h=this.position.x-n/2,a=this.position.y-o/2;return!(e>this.maxZoom||e<this.minZoom)&&(this.scale.x=e,this.scale.y=e,this.position.x=h,this.position.y=a,this.isOnTouching=!0,this.zoomD=e,this._runCallback("onZoom"),!0)}},_doMove:function(t,i){if(this.lastX&&this.lastY){var e=t-this.lastX,s=i-this.lastY;this.position.x+=e,this.position.y+=s}this.lastX=t,this.lastY=i},_doRotate:function(t){null!==this.lastTouchRotateAngle&&(this.rotate.angle=this.rotate.angle+1.5*(t.a-this.lastTouchRotateAngle),this.rotate.center=t.o),this.lastTouchRotateAngle=t.a,this._runCallback("onRotate")},_zoomInAnimCanvas:function(){var i=this.dbclickZoomLength/10*2;if(.01<this.dbclickZoomLength){if(!this._doZoom(i))return cancelAnimationFrame(t),!1;this.dbclickZoomLength=this.dbclickZoomLength-i,this.animateHandle=requestAnimationFrame(this._zoomInAnimCanvas.bind(this))}else cancelAnimationFrame(this.animateHandle);return!0},_zoomOutAnimCanvas:function(){var i=this.dbclickZoomLength/10*2;if(.01<this.dbclickZoomLength){if(!this._doZoom(-i))return cancelAnimationFrame(t),!1;this.dbclickZoomLength=this.dbclickZoomLength-i,this.animateHandle=requestAnimationFrame(this._zoomOutAnimCanvas.bind(this))}else cancelAnimationFrame(this.animateHandle);return!0},_zoomInAnimTransform:function(){var t=this.dbclickZoomLength/10*2;return.01<this.dbclickZoomLength?(this.zoomD+=t,this.dbclickZoomLength=this.dbclickZoomLength-t,this.animateHandle=requestAnimationFrame(this._zoomInAnimTransform.bind(this))):cancelAnimationFrame(this.animateHandle),!0},_zoomOutAnimTransform:function(){var t=this.dbclickZoomLength/10*2;return.01<this.dbclickZoomLength?(this.zoomD-=t,this.dbclickZoomLength=this.dbclickZoomLength-t,this.animateHandle=requestAnimationFrame(this._zoomOutAnimTransform.bind(this))):cancelAnimationFrame(this.animateHandle),!0},_gestureDbClick:function(t,i){var e=t.changedTouches[0];if(null===this.lastTouchEndTimestamp||null===this.lastTouchEndObject)this.lastTouchEndTimestamp=Math.round((new Date).getTime()),this.lastTouchEndObject=e;else{var s=Math.round((new Date).getTime());s-this.lastTouchEndTimestamp<300&&Math.abs(this.lastTouchEndObject.pageX-e.pageX)<20&&Math.abs(this.lastTouchEndObject.pageY-e.pageY<20)&&i&&i(),this.lastTouchEndTimestamp=s,this.lastTouchEndObject=e}},_runCallback:function(t,i){switch(t){case"onDrag":"function"===this._type(this.onDrag)&&this.onDrag.call(this,{x:this.lastX.toFixed(3),y:this.lastY.toFixed(3)});break;case"onRotate":"function"===this._type(this.onRotate)&&this.onRotate.call(this,{rotate:(this.rotate.angle%360).toFixed(3)});break;case"onZoom":"function"===this._type(this.onZoom)&&this.onZoom.call(this,{zoom:this.zoomD.toFixed(3),scale:{width:(this.zoomD*this.imgTexture.width).toFixed(3),height:(this.zoomD*this.imgTexture.height).toFixed(3)}})}},_setEventListenersTransform:function(){this.container.addEventListener("touchend",function(t){this.lastZoomScale=null,this.lastTouchRotateAngle=null,this.enableDesktop||this._gestureDbClick(t,function(){this.dbclickZoomLength=this.dbclickZoomThreshold,this.dbclickZoomToggle?this._zoomInAnimTransform()||this._zoomOutAnimTransform():this._zoomOutAnimTransform()||this._zoomInAnimTransform(),this.dbclickZoomToggle=!this.dbclickZoomToggle}.bind(this))}.bind(this)),this.container.addEventListener("touchstart",function(t){this.lastX=null,this.lastY=null}.bind(this)),this.container.addEventListener("touchmove",function(t){t.preventDefault(),2==t.touches.length?(this.zoomD=this.zoomD+this._gesturePinchZoom(t.touches)/250,this._runCallback("onZoom"),this._doRotate(this._enableGestureRotate(t.touches))):1==t.touches.length&&(null!==this.lastX&&null!==this.lastY&&(this.moveXD+=t.touches[0].pageX-this.lastX,this.moveYD+=t.touches[0].pageY-this.lastY),this.lastX=t.touches[0].pageX,this.lastY=t.touches[0].pageY,this._runCallback("onDrag"))}.bind(this)),this.imgTexture.addEventListener("load",function(t){this.moveXD=0,this.moveYD=0,this.zoomD=1,this.lastTouchRotateAngle=null,this.rotate={center:{},angle:0},this.canvas.width=this.imgTexture.width,this.canvas.height=this.imgTexture.height,this.canvas.setAttribute("width",this.imgTexture.width+"px"),this.canvas.setAttribute("height",this.imgTexture.height+"px"),this.imgTexture.width>this.imgTexture.height?this.canvas.parentNode.clientWidth<this.imgTexture.width?(this.zoomD=this.canvas.parentNode.clientWidth/this.imgTexture.width,this.moveYD=(this.canvas.parentNode.clientHeight-this.zoomD*this.imgTexture.height)/2-this.imgTexture.height*(1-this.zoomD)/2,this.moveXD=-this.imgTexture.width*(1-this.zoomD)/2):(this.moveXD=(this.canvas.parentNode.clientWidth-this.imgTexture.width)/2,this.moveYD=(this.canvas.parentNode.clientHeight-this.imgTexture.height)/2):this.canvas.parentNode.clientWidth<this.imgTexture.width?(this.zoomD=this.canvas.parentNode.clientHeight/this.imgTexture.height,this.moveXD=(this.canvas.parentNode.clientWidth-this.zoomD*this.imgTexture.width)/2-this.imgTexture.width*(1-this.zoomD)/2,this.moveYD=-this.imgTexture.height*(1-this.zoomD)/2):(this.moveXD=(this.canvas.parentNode.clientWidth-this.imgTexture.width)/2,this.moveYD=(this.canvas.parentNode.clientHeight-this.imgTexture.height)/2),this.isImgLoaded=!0}.bind(this)),this.enableDesktop&&(window.addEventListener("keyup",function(t){187==t.keyCode?this.zoomD+=.1:189==t.keyCode&&(this.zoomD-=.1),187!=t.keyCode&&189!=t.keyCode||this._runCallback("onZoom")}.bind(this)),window.addEventListener("mousedown",function(t){this.mdown=!0,this.lastX=null,this.lastY=null}.bind(this)),window.addEventListener("mouseup",function(t){this.mdown=!1}.bind(this)),window.addEventListener("mousemove",function(t){this.mdown&&(null!==this.lastX&&null!==this.lastY&&(this.moveXD+=t.pageX-this.lastX,this.moveYD+=t.pageY-this.lastY),this.lastX=t.pageX,this.lastY=t.pageY,this._runCallback("onDrag"))}.bind(this)),window.addEventListener("dblclick",function(t){this.dbclickZoomLength=this.dbclickZoomThreshold,this.dbclickZoomToggle?this._zoomInAnimTransform()||this._zoomOutAnimTransform():this._zoomOutAnimTransform()||this._zoomInAnimTransform(),this.dbclickZoomToggle=!this.dbclickZoomToggle}.bind(this)))},_setEventListenersCanvas:function(){this.canvas.addEventListener("touchend",function(t){this.isOnTouching=!1,this.lastZoomScale=null,this.enableDesktop||this._gestureDbClick(t,function(){this.dbclickZoomLength=this.dbclickZoomThreshold,this.dbclickZoomToggle?this._zoomInAnimCanvas()||this._zoomOutAnimCanvas():this._zoomOutAnimCanvas()||this._zoomInAnimCanvas(),this.dbclickZoomToggle=!this.dbclickZoomToggle}.bind(this))}.bind(this)),this.canvas.addEventListener("touchstart",function(t){this.isOnTouching=!0,this.lastX=null,this.lastY=null}.bind(this)),this.canvas.addEventListener("touchmove",function(t){if(t.preventDefault(),2==t.targetTouches.length)this._doZoom(this._gesturePinchZoom(t.targetTouches)/250);else if(1==t.targetTouches.length){var i=t.targetTouches[0].pageX-this.canvas.getBoundingClientRect().left,e=t.targetTouches[0].pageY-this.canvas.getBoundingClientRect().top;this._doMove(i,e),this._runCallback("onDrag")}}.bind(this)),this.imgTexture.addEventListener("load",function(t){if(this.isOnTouching=!1,this.lastTouchEndTimestamp=null,this.lastTouchEndObject=null,this.dbclickZoomLength=0,this.imgTexture.width&&this.imgTexture.height){var i=1;this.imgTexture.width>this.imgTexture.height?this.canvas.clientWidth<this.imgTexture.width?(i=this.canvas.clientWidth/this.imgTexture.width,this.position.y=(this.canvas.clientHeight-i*this.imgTexture.height)/2):(this.position.x=(this.canvas.clientWidth-this.imgTexture.width)/2,this.position.y=(this.canvas.clientHeight-this.imgTexture.height)/2):this.canvas.clientWidth<this.imgTexture.width?(i=this.canvas.clientHeight/this.imgTexture.height,this.position.x=(this.canvas.clientWidth-i*this.imgTexture.width)/2):(this.position.x=(this.canvas.clientWidth-this.imgTexture.width)/2,this.position.y=(this.canvas.clientHeight-this.imgTexture.height)/2),this.scale.x=i,this.scale.y=i}this.isImgLoaded=!0}.bind(this)),this.enableDesktop&&(window.addEventListener("keyup",function(t){187==t.keyCode?this._doZoom(.05):189==t.keyCode&&this._doZoom(-.05)}.bind(this)),window.addEventListener("mousedown",function(t){this.mdown=!0,this.lastX=null,this.lastY=null}.bind(this)),window.addEventListener("mouseup",function(t){this.mdown=!1}.bind(this)),window.addEventListener("mousemove",function(t){var i=t.pageX-this.canvas.getBoundingClientRect().left,e=t.pageY-this.canvas.getBoundingClientRect().top;t.target==this.canvas&&this.mdown&&this._doMove(i,e),(i<=0||i>=this.canvas.clientWidth||e<=0||e>=this.canvas.clientHeight)&&(this.mdown=!1),this.mdown&&this._runCallback("onDrag")}.bind(this)),window.addEventListener("dblclick",function(t){this.dbclickZoomLength=this.dbclickZoomThreshold,this.dbclickZoomToggle?this._zoomInAnimCanvas()||this._zoomOutAnimCanvas():this._zoomOutAnimCanvas()||this._zoomInAnimCanvas(),this.dbclickZoomToggle=!this.dbclickZoomToggle}.bind(this)))},_type:function(t){var i={},e=i.toString;return i["[object Function]"]="function",null==t?t+"":"object"===o()(t)||"function"==typeof t?i[e.call(t)]||"object":o()(t)},_checkRequestAnimationFrame:function(){for(var o=0,t=["ms","moz","webkit","o"],i=0;i<t.length&&!window.requestAnimationFrame;++i)window.requestAnimationFrame=window[t[i]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[t[i]+"CancelAnimationFrame"]||window[t[i]+"CancelRequestAnimationFrame"];window.requestAnimationFrame||(window.requestAnimationFrame=function(t,i){var e=(new Date).getTime(),s=Math.max(0,16-(e-o)),n=window.setTimeout(function(){t(e+s)},s);return o=e+s,n}),window.cancelAnimationFrame||(window.cancelAnimationFrame=function(t){clearTimeout(t)})},zoom:function(t){this.dbclickZoomLength=Math.abs(t),this.enableGestureRotate?0<t?this._zoomInAnimTransform():this._zoomOutAnimTransform():0<t?this._zoomInAnimCanvas():this._zoomOutAnimCanvas()},load:function(t){this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.position={x:0,y:0},this.scale={x:1,y:1},this.isImgLoaded=!1,this.isFirstTimeLoad=!0,this.lastZoomScale=null,this.lastX=null,this.lastY=null,this.mdown=!1,this.lastTouchEndTimestamp=null,this.lastTouchEndObject=null,this.imgTexture.src=t}},e.default=h}]).default;