Socket
Socket
Sign inDemoInstall

pixi-viewport

Package Overview
Dependencies
32
Maintainers
1
Versions
243
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.30.0 to 4.30.1

2

dist/viewport.min.min.js
/* eslint-disable */
this.PIXI=this.PIXI||{},function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports,require("@pixi/math"),require("penner"),require("@pixi/display"),require("@pixi/ticker")):"function"==typeof define&&define.amd?define(["exports","@pixi/math","penner","@pixi/display","@pixi/ticker"],i):i((t="undefined"!=typeof globalThis?globalThis:t||self).pixi_viewport={},t.PIXI,t.Penner,t.PIXI,t.PIXI)}(this,(function(t,i,e,s,h){"use strict";function n(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var o=n(e);class r{constructor(t){this.parent=t,this.paused=!1}destroy(){}down(t){return!1}move(t){return!1}up(t){return!1}wheel(t){return!1}update(t){}resize(){}reset(){}pause(){this.paused=!0}resume(){this.paused=!1}}function a(t,i){return t?"function"==typeof t?t:"string"==typeof t?o.default[t]:void 0:o.default[i]}const p={removeOnInterrupt:!1,ease:"linear",time:1e3};class l extends r{__init(){this.startWidth=null}__init2(){this.startHeight=null}__init3(){this.deltaWidth=null}__init4(){this.deltaHeight=null}__init5(){this.width=null}__init6(){this.height=null}__init7(){this.time=0}constructor(t,i={}){super(t),l.prototype.__init.call(this),l.prototype.__init2.call(this),l.prototype.__init3.call(this),l.prototype.__init4.call(this),l.prototype.__init5.call(this),l.prototype.__init6.call(this),l.prototype.__init7.call(this),this.options=Object.assign({},p,i),this.options.ease=a(this.options.ease),this.setupPosition(),this.setupZoom(),this.time=0}setupPosition(){void 0!==this.options.position?(this.startX=this.parent.center.x,this.startY=this.parent.center.y,this.deltaX=this.options.position.x-this.parent.center.x,this.deltaY=this.options.position.y-this.parent.center.y,this.keepCenter=!1):this.keepCenter=!0}setupZoom(){this.width=null,this.height=null,void 0!==this.options.scale?this.width=this.parent.screenWidth/this.options.scale:void 0!==this.options.scaleX||void 0!==this.options.scaleY?(void 0!==this.options.scaleX&&(this.width=this.parent.screenWidth/this.options.scaleX),void 0!==this.options.scaleY&&(this.height=this.parent.screenHeight/this.options.scaleY)):(void 0!==this.options.width&&(this.width=this.options.width),void 0!==this.options.height&&(this.height=this.options.height)),null!==this.width&&(this.startWidth=this.parent.screenWidthInWorldPixels,this.deltaWidth=this.width-this.startWidth),null!==this.height&&(this.startHeight=this.parent.screenHeightInWorldPixels,this.deltaHeight=this.height-this.startHeight)}down(){return this.options.removeOnInterrupt&&this.parent.plugins.remove("animate"),!1}complete(){this.parent.plugins.remove("animate"),null!==this.width&&this.parent.fitWidth(this.width,this.keepCenter,null===this.height),null!==this.height&&this.parent.fitHeight(this.height,this.keepCenter,null===this.width),this.keepCenter||this.parent.moveCenter(this.options.position),this.parent.emit("animate-end",this.parent),this.options.callbackOnComplete&&this.options.callbackOnComplete(this.parent)}update(t){if(!this.paused)if(this.time+=t,this.time>=this.options.time)this.complete();else{const t=new i.Point(this.parent.scale.x,this.parent.scale.y),e=this.options.ease(this.time,0,1,this.options.time);if(null!==this.width){const t=this.startWidth,i=this.deltaWidth;this.parent.fitWidth(t+i*e,this.keepCenter,null===this.height)}if(null!==this.height){const t=this.startHeight,i=this.deltaHeight;this.parent.fitHeight(t+i*e,this.keepCenter,null===this.width)}if(null===this.width?this.parent.scale.x=this.parent.scale.y:null===this.height&&(this.parent.scale.y=this.parent.scale.x),!this.keepCenter){const t=this.startX,s=this.startY,h=this.deltaX,n=this.deltaY,o=new i.Point(this.parent.x,this.parent.y);this.parent.moveCenter(t+h*e,s+n*e),this.parent.emit("moved",{viewport:this.parent,original:o,type:"animate"})}(this.width||this.height)&&this.parent.emit("zoomed",{viewport:this.parent,original:t,type:"animate"})}}}function c(t){let i=void 0,e=t[0],s=1;for(;s<t.length;){const h=t[s],n=t[s+1];if(s+=2,("optionalAccess"===h||"optionalCall"===h)&&null==e)return;"access"===h||"optionalAccess"===h?(i=e,e=n(e)):"call"!==h&&"optionalCall"!==h||(e=n(((...t)=>e.call(i,...t))),i=void 0)}return e}const d={sides:"all",friction:.5,time:150,ease:"easeInOutSine",underflow:"center",bounceBox:null};class u extends r{constructor(t,i={}){super(t),this.options=Object.assign({},d,i),this.ease=a(this.options.ease,"easeInOutSine"),this.options.sides?"all"===this.options.sides?this.top=this.bottom=this.left=this.right=!0:"horizontal"===this.options.sides?(this.right=this.left=!0,this.top=this.bottom=!1):"vertical"===this.options.sides?(this.left=this.right=!1,this.top=this.bottom=!0):(this.top=-1!==this.options.sides.indexOf("top"),this.bottom=-1!==this.options.sides.indexOf("bottom"),this.left=-1!==this.options.sides.indexOf("left"),this.right=-1!==this.options.sides.indexOf("right")):this.left=this.top=this.right=this.bottom=!1;const e=this.options.underflow.toLowerCase();"center"===e?(this.underflowX=0,this.underflowY=0):(this.underflowX=-1!==e.indexOf("left")?-1:-1!==e.indexOf("right")?1:0,this.underflowY=-1!==e.indexOf("top")?-1:-1!==e.indexOf("bottom")?1:0),this.reset()}isActive(){return null!==this.toX||null!==this.toY}down(){return this.toX=this.toY=null,!1}up(){return this.bounce(),!1}update(t){if(!this.paused){if(this.bounce(),this.toX){const i=this.toX;i.time+=t,this.parent.emit("moved",{viewport:this.parent,type:"bounce-x"}),i.time>=this.options.time?(this.parent.x=i.end,this.toX=null,this.parent.emit("bounce-x-end",this.parent)):this.parent.x=this.ease(i.time,i.start,i.delta,this.options.time)}if(this.toY){const i=this.toY;i.time+=t,this.parent.emit("moved",{viewport:this.parent,type:"bounce-y"}),i.time>=this.options.time?(this.parent.y=i.end,this.toY=null,this.parent.emit("bounce-y-end",this.parent)):this.parent.y=this.ease(i.time,i.start,i.delta,this.options.time)}}}calcUnderflowX(){let t;switch(this.underflowX){case-1:t=0;break;case 1:t=this.parent.screenWidth-this.parent.screenWorldWidth;break;default:t=(this.parent.screenWidth-this.parent.screenWorldWidth)/2}return t}calcUnderflowY(){let t;switch(this.underflowY){case-1:t=0;break;case 1:t=this.parent.screenHeight-this.parent.screenWorldHeight;break;default:t=(this.parent.screenHeight-this.parent.screenWorldHeight)/2}return t}oob(){const t=this.options.bounceBox;if(t){const e=void 0===t.x?0:t.x,s=void 0===t.y?0:t.y,h=void 0===t.width?this.parent.worldWidth:t.width,n=void 0===t.height?this.parent.worldHeight:t.height;return{left:this.parent.left<e,right:this.parent.right>h,top:this.parent.top<s,bottom:this.parent.bottom>n,topLeft:new i.Point(e*this.parent.scale.x,s*this.parent.scale.y),bottomRight:new i.Point(h*this.parent.scale.x-this.parent.screenWidth,n*this.parent.scale.y-this.parent.screenHeight)}}return{left:this.parent.left<0,right:this.parent.right>this.parent.worldWidth,top:this.parent.top<0,bottom:this.parent.bottom>this.parent.worldHeight,topLeft:new i.Point(0,0),bottomRight:new i.Point(this.parent.worldWidth*this.parent.scale.x-this.parent.screenWidth,this.parent.worldHeight*this.parent.scale.y-this.parent.screenHeight)}}bounce(){if(this.paused)return;let t,i=this.parent.plugins.get("decelerate",!0);i&&(i.x||i.y)&&(i.x&&i.percentChangeX===c([i,"access",t=>t.options,"optionalAccess",t=>t.friction])||i.y&&i.percentChangeY===c([i,"access",t=>t.options,"optionalAccess",t=>t.friction]))&&(t=this.oob(),(t.left&&this.left||t.right&&this.right)&&(i.percentChangeX=this.options.friction),(t.top&&this.top||t.bottom&&this.bottom)&&(i.percentChangeY=this.options.friction));const e=this.parent.plugins.get("drag",!0)||{},s=this.parent.plugins.get("pinch",!0)||{};if(i=i||{},!(c([e,"optionalAccess",t=>t.active])||c([s,"optionalAccess",t=>t.active])||this.toX&&this.toY||i.x&&i.y)){t=t||this.oob();const e=t.topLeft,s=t.bottomRight;if(!this.toX&&!i.x){let i=null;t.left&&this.left?i=this.parent.screenWorldWidth<this.parent.screenWidth?this.calcUnderflowX():-e.x:t.right&&this.right&&(i=this.parent.screenWorldWidth<this.parent.screenWidth?this.calcUnderflowX():-s.x),null!==i&&this.parent.x!==i&&(this.toX={time:0,start:this.parent.x,delta:i-this.parent.x,end:i},this.parent.emit("bounce-x-start",this.parent))}if(!this.toY&&!i.y){let i=null;t.top&&this.top?i=this.parent.screenWorldHeight<this.parent.screenHeight?this.calcUnderflowY():-e.y:t.bottom&&this.bottom&&(i=this.parent.screenWorldHeight<this.parent.screenHeight?this.calcUnderflowY():-s.y),null!==i&&this.parent.y!==i&&(this.toY={time:0,start:this.parent.y,delta:i-this.parent.y,end:i},this.parent.emit("bounce-y-start",this.parent))}}}reset(){this.toX=this.toY=null,this.bounce()}}const g={left:!1,right:!1,top:!1,bottom:!1,direction:null,underflow:"center"};class m extends r{constructor(t,i={}){super(t),this.options=Object.assign({},g,i),this.options.direction&&(this.options.left="x"===this.options.direction||"all"===this.options.direction||null,this.options.right="x"===this.options.direction||"all"===this.options.direction||null,this.options.top="y"===this.options.direction||"all"===this.options.direction||null,this.options.bottom="y"===this.options.direction||"all"===this.options.direction||null),this.parseUnderflow(),this.last={x:null,y:null,scaleX:null,scaleY:null},this.update()}parseUnderflow(){const t=this.options.underflow.toLowerCase();"none"===t?this.noUnderflow=!0:"center"===t?(this.underflowX=this.underflowY=0,this.noUnderflow=!1):(this.underflowX=-1!==t.indexOf("left")?-1:-1!==t.indexOf("right")?1:0,this.underflowY=-1!==t.indexOf("top")?-1:-1!==t.indexOf("bottom")?1:0,this.noUnderflow=!1)}move(){return this.update(),!1}update(){if(this.paused)return;if(this.parent.x===this.last.x&&this.parent.y===this.last.y&&this.parent.scale.x===this.last.scaleX&&this.parent.scale.y===this.last.scaleY)return;const t={x:this.parent.x,y:this.parent.y},i=this.parent.plugins.decelerate||{};if(null!==this.options.left||null!==this.options.right){let e=!1;if(!this.noUnderflow&&this.parent.screenWorldWidth<this.parent.screenWidth)switch(this.underflowX){case-1:0!==this.parent.x&&(this.parent.x=0,e=!0);break;case 1:this.parent.x!==this.parent.screenWidth-this.parent.screenWorldWidth&&(this.parent.x=this.parent.screenWidth-this.parent.screenWorldWidth,e=!0);break;default:this.parent.x!==(this.parent.screenWidth-this.parent.screenWorldWidth)/2&&(this.parent.x=(this.parent.screenWidth-this.parent.screenWorldWidth)/2,e=!0)}else null!==this.options.left&&this.parent.left<(!0===this.options.left?0:this.options.left)&&(this.parent.x=-(!0===this.options.left?0:this.options.left)*this.parent.scale.x,i.x=0,e=!0),null!==this.options.right&&this.parent.right>(!0===this.options.right?this.parent.worldWidth:this.options.right)&&(this.parent.x=-(!0===this.options.right?this.parent.worldWidth:this.options.right)*this.parent.scale.x+this.parent.screenWidth,i.x=0,e=!0);e&&this.parent.emit("moved",{viewport:this.parent,original:t,type:"clamp-x"})}if(null!==this.options.top||null!==this.options.bottom){let e=!1;if(!this.noUnderflow&&this.parent.screenWorldHeight<this.parent.screenHeight)switch(this.underflowY){case-1:0!==this.parent.y&&(this.parent.y=0,e=!0);break;case 1:this.parent.y!==this.parent.screenHeight-this.parent.screenWorldHeight&&(this.parent.y=this.parent.screenHeight-this.parent.screenWorldHeight,e=!0);break;default:this.parent.y!==(this.parent.screenHeight-this.parent.screenWorldHeight)/2&&(this.parent.y=(this.parent.screenHeight-this.parent.screenWorldHeight)/2,e=!0)}else null!==this.options.top&&this.parent.top<(!0===this.options.top?0:this.options.top)&&(this.parent.y=-(!0===this.options.top?0:this.options.top)*this.parent.scale.y,i.y=0,e=!0),null!==this.options.bottom&&this.parent.bottom>(!0===this.options.bottom?this.parent.worldHeight:this.options.bottom)&&(this.parent.y=-(!0===this.options.bottom?this.parent.worldHeight:this.options.bottom)*this.parent.scale.y+this.parent.screenHeight,i.y=0,e=!0);e&&this.parent.emit("moved",{viewport:this.parent,original:t,type:"clamp-y"})}this.last.x=this.parent.x,this.last.y=this.parent.y,this.last.scaleX=this.parent.scale.x,this.last.scaleY=this.parent.scale.y}reset(){this.update()}}const w={minWidth:null,minHeight:null,maxWidth:null,maxHeight:null,minScale:null,maxScale:null};class y extends r{constructor(t,i={}){super(t),this.options=Object.assign({},w,i),this.clamp()}resize(){this.clamp()}clamp(){if(!this.paused)if(this.options.minWidth||this.options.minHeight||this.options.maxWidth||this.options.maxHeight){let t=this.parent.worldScreenWidth,i=this.parent.worldScreenHeight;if(null!==this.options.minWidth&&t<this.options.minWidth){const e=this.parent.scale.x;this.parent.fitWidth(this.options.minWidth,!1,!1,!0),this.parent.scale.y*=this.parent.scale.x/e,t=this.parent.worldScreenWidth,i=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(null!==this.options.maxWidth&&t>this.options.maxWidth){const e=this.parent.scale.x;this.parent.fitWidth(this.options.maxWidth,!1,!1,!0),this.parent.scale.y*=this.parent.scale.x/e,t=this.parent.worldScreenWidth,i=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(null!==this.options.minHeight&&i<this.options.minHeight){const e=this.parent.scale.y;this.parent.fitHeight(this.options.minHeight,!1,!1,!0),this.parent.scale.x*=this.parent.scale.y/e,t=this.parent.worldScreenWidth,i=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(null!==this.options.maxHeight&&i>this.options.maxHeight){const t=this.parent.scale.y;this.parent.fitHeight(this.options.maxHeight,!1,!1,!0),this.parent.scale.x*=this.parent.scale.y/t,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}}else{let t=this.parent.scale.x;null!==this.options.minScale&&t<this.options.minScale&&(t=this.options.minScale),null!==this.options.maxScale&&t>this.options.maxScale&&(t=this.options.maxScale),t!==this.parent.scale.x&&(this.parent.scale.set(t),this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"}))}}reset(){this.clamp()}}const x={friction:.98,bounce:.8,minSpeed:.01},f=16;class v extends r{constructor(t,i={}){super(t),this.options=Object.assign({},x,i),this.saved=[],this.timeSinceRelease=0,this.reset(),this.parent.on("moved",(t=>this.moved(t)))}down(){return this.saved=[],this.x=this.y=null,!1}isActive(){return!(!this.x&&!this.y)}move(){if(this.paused)return!1;const t=this.parent.input.count();return(1===t||t>1&&!this.parent.plugins.get("pinch",!0))&&(this.saved.push({x:this.parent.x,y:this.parent.y,time:performance.now()}),this.saved.length>60&&this.saved.splice(0,30)),!1}moved(t){if(this.saved.length){const i=this.saved[this.saved.length-1];"clamp-x"===t.type?i.x===t.original.x&&(i.x=this.parent.x):"clamp-y"===t.type&&i.y===t.original.y&&(i.y=this.parent.y)}}up(){if(0===this.parent.input.count()&&this.saved.length){const t=performance.now();for(const i of this.saved)if(i.time>=t-100){const e=t-i.time;this.x=(this.parent.x-i.x)/e,this.y=(this.parent.y-i.y)/e,this.percentChangeX=this.percentChangeY=this.options.friction,this.timeSinceRelease=0;break}}return!1}activate(t){void 0!==(t=t||{}).x&&(this.x=t.x,this.percentChangeX=this.options.friction),void 0!==t.y&&(this.y=t.y,this.percentChangeY=this.options.friction)}update(t){if(this.paused)return;const i=this.x||this.y,e=this.timeSinceRelease,s=this.timeSinceRelease+t;if(this.x){const i=this.percentChangeX,h=Math.log(i);this.parent.x+=this.x*f/h*(Math.pow(i,s/f)-Math.pow(i,e/f)),this.x*=Math.pow(this.percentChangeX,t/f)}if(this.y){const i=this.percentChangeY,h=Math.log(i);this.parent.y+=this.y*f/h*(Math.pow(i,s/f)-Math.pow(i,e/f)),this.y*=Math.pow(this.percentChangeY,t/f)}this.timeSinceRelease+=t,Math.abs(this.x||0)<this.options.minSpeed&&(this.x=0),Math.abs(this.y||0)<this.options.minSpeed&&(this.y=0),i&&this.parent.emit("moved",{viewport:this.parent,type:"decelerate"})}reset(){this.x=this.y=null}}const W={direction:"all",pressDrag:!0,wheel:!0,wheelScroll:1,reverse:!1,clampWheel:!1,underflow:"center",factor:1,mouseButtons:"all",keyToPress:null,ignoreKeyToPressOnTouch:!1,lineHeight:20};class b extends r{constructor(t,i={}){super(t),this.options=Object.assign({},W,i),this.moved=!1,this.reverse=this.options.reverse?1:-1,this.xDirection=!this.options.direction||"all"===this.options.direction||"x"===this.options.direction,this.yDirection=!this.options.direction||"all"===this.options.direction||"y"===this.options.direction,this.keyIsPressed=!1,this.parseUnderflow(),this.mouseButtons(this.options.mouseButtons),this.options.keyToPress&&this.handleKeyPresses(this.options.keyToPress)}handleKeyPresses(t){window.addEventListener("keydown",(i=>{t.includes(i.code)&&(this.keyIsPressed=!0)})),window.addEventListener("keyup",(i=>{t.includes(i.code)&&(this.keyIsPressed=!1)}))}mouseButtons(t){this.mouse=t&&"all"!==t?[-1!==t.indexOf("left"),-1!==t.indexOf("middle"),-1!==t.indexOf("right")]:[!0,!0,!0]}parseUnderflow(){const t=this.options.underflow.toLowerCase();"center"===t?(this.underflowX=0,this.underflowY=0):(this.underflowX=-1!==t.indexOf("left")?-1:-1!==t.indexOf("right")?1:0,this.underflowY=-1!==t.indexOf("top")?-1:-1!==t.indexOf("bottom")?1:0)}checkButtons(t){const i="mouse"===t.data.pointerType,e=this.parent.input.count();return!(!(1===e||e>1&&!this.parent.plugins.get("pinch",!0))||i&&!this.mouse[t.data.button])}checkKeyPress(t){return!this.options.keyToPress||this.keyIsPressed||this.options.ignoreKeyToPressOnTouch&&"touch"===t.data.pointerType}down(t){return!(this.paused||!this.options.pressDrag)&&(this.checkButtons(t)&&this.checkKeyPress(t)?(this.last={x:t.data.global.x,y:t.data.global.y},this.current=t.data.pointerId,!0):(this.last=null,!1))}get active(){return this.moved}move(t){if(this.paused||!this.options.pressDrag)return!1;if(this.last&&this.current===t.data.pointerId){const e=t.data.global.x,s=t.data.global.y,h=this.parent.input.count();if(1===h||h>1&&!this.parent.plugins.get("pinch",!0)){const h=e-this.last.x,n=s-this.last.y;if(this.moved||this.xDirection&&this.parent.input.checkThreshold(h)||this.yDirection&&this.parent.input.checkThreshold(n)){const h={x:e,y:s};return this.xDirection&&(this.parent.x+=(h.x-this.last.x)*this.options.factor),this.yDirection&&(this.parent.y+=(h.y-this.last.y)*this.options.factor),this.last=h,this.moved||this.parent.emit("drag-start",{event:t,screen:new i.Point(this.last.x,this.last.y),world:this.parent.toWorld(new i.Point(this.last.x,this.last.y)),viewport:this.parent}),this.moved=!0,this.parent.emit("moved",{viewport:this.parent,type:"drag"}),!0}}else this.moved=!1}return!1}up(t){if(this.paused)return!1;const e=this.parent.input.touches;if(1===e.length){const t=e[0];return t.last&&(this.last={x:t.last.x,y:t.last.y},this.current=t.id),this.moved=!1,!0}if(this.last&&this.moved){const e=new i.Point(this.last.x,this.last.y);return this.parent.emit("drag-end",{event:t,screen:e,world:this.parent.toWorld(e),viewport:this.parent}),this.last=null,this.moved=!1,!0}return!1}wheel(t){if(this.paused)return!1;if(this.options.wheel){if(!this.parent.plugins.get("wheel",!0)){const i=t.deltaMode?this.options.lineHeight:1;return this.xDirection&&(this.parent.x+=t.deltaX*i*this.options.wheelScroll*this.reverse),this.yDirection&&(this.parent.y+=t.deltaY*i*this.options.wheelScroll*this.reverse),this.options.clampWheel&&this.clamp(),this.parent.emit("wheel-scroll",this.parent),this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.parent.options.passiveWheel||t.preventDefault(),!0}}return!1}resume(){this.last=null,this.paused=!1}clamp(){const t=this.parent.plugins.get("decelerate",!0)||{};if("y"!==this.options.clampWheel)if(this.parent.screenWorldWidth<this.parent.screenWidth)switch(this.underflowX){case-1:this.parent.x=0;break;case 1:this.parent.x=this.parent.screenWidth-this.parent.screenWorldWidth;break;default:this.parent.x=(this.parent.screenWidth-this.parent.screenWorldWidth)/2}else this.parent.left<0?(this.parent.x=0,t.x=0):this.parent.right>this.parent.worldWidth&&(this.parent.x=-this.parent.worldWidth*this.parent.scale.x+this.parent.screenWidth,t.x=0);if("x"!==this.options.clampWheel)if(this.parent.screenWorldHeight<this.parent.screenHeight)switch(this.underflowY){case-1:this.parent.y=0;break;case 1:this.parent.y=this.parent.screenHeight-this.parent.screenWorldHeight;break;default:this.parent.y=(this.parent.screenHeight-this.parent.screenWorldHeight)/2}else this.parent.top<0&&(this.parent.y=0,t.y=0),this.parent.bottom>this.parent.worldHeight&&(this.parent.y=-this.parent.worldHeight*this.parent.scale.y+this.parent.screenHeight,t.y=0)}}const H={speed:0,acceleration:null,radius:null};class S extends r{constructor(t,i,e={}){super(t),this.target=i,this.options=Object.assign({},H,e),this.velocity={x:0,y:0}}update(t){if(this.paused)return;const i=this.parent.center;let e=this.target.x,s=this.target.y;if(this.options.radius){if(!(Math.sqrt(Math.pow(this.target.y-i.y,2)+Math.pow(this.target.x-i.x,2))>this.options.radius))return;{const t=Math.atan2(this.target.y-i.y,this.target.x-i.x);e=this.target.x-Math.cos(t)*this.options.radius,s=this.target.y-Math.sin(t)*this.options.radius}}const h=e-i.x,n=s-i.y;if(h||n)if(this.options.speed)if(this.options.acceleration){const o=Math.atan2(s-i.y,e-i.x),r=Math.sqrt(Math.pow(h,2)+Math.pow(n,2));if(r){const a=(Math.pow(this.velocity.x,2)+Math.pow(this.velocity.y,2))/(2*this.options.acceleration);this.velocity=r>a?{x:Math.min(this.velocity.x+this.options.acceleration*t,this.options.speed),y:Math.min(this.velocity.y+this.options.acceleration*t,this.options.speed)}:{x:Math.max(this.velocity.x-this.options.acceleration*this.options.speed,0),y:Math.max(this.velocity.y-this.options.acceleration*this.options.speed,0)};const p=Math.cos(o)*this.velocity.x,l=Math.sin(o)*this.velocity.y,c=Math.abs(p)>Math.abs(h)?e:i.x+p,d=Math.abs(l)>Math.abs(n)?s:i.y+l;this.parent.moveCenter(c,d),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}}else{const t=Math.atan2(s-i.y,e-i.x),o=Math.cos(t)*this.options.speed,r=Math.sin(t)*this.options.speed,a=Math.abs(o)>Math.abs(h)?e:i.x+o,p=Math.abs(r)>Math.abs(n)?s:i.y+r;this.parent.moveCenter(a,p),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}else this.parent.moveCenter(e,s),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}}const M={radius:null,distance:null,top:null,bottom:null,left:null,right:null,speed:8,reverse:!1,noDecelerate:!1,linear:!1,allowButtons:!1};class C extends r{constructor(t,i={}){super(t),this.options=Object.assign({},M,i),this.reverse=this.options.reverse?1:-1,this.radiusSquared="number"==typeof this.options.radius?Math.pow(this.options.radius,2):null,this.resize()}resize(){const t=this.options.distance;null!==t?(this.left=t,this.top=t,this.right=this.parent.worldScreenWidth-t,this.bottom=this.parent.worldScreenHeight-t):this.options.radius||(this.left=this.options.left,this.top=this.options.top,this.right=null===this.options.right?null:this.parent.worldScreenWidth-this.options.right,this.bottom=null===this.options.bottom?null:this.parent.worldScreenHeight-this.options.bottom)}down(){return this.paused||this.options.allowButtons||(this.horizontal=this.vertical=null),!1}move(t){if(this.paused)return!1;if("mouse"!==t.data.pointerType&&1!==t.data.identifier||!this.options.allowButtons&&0!==t.data.buttons)return!1;const i=t.data.global.x,e=t.data.global.y;if(this.radiusSquared){const t=this.parent.toScreen(this.parent.center);if(Math.pow(t.x-i,2)+Math.pow(t.y-e,2)>=this.radiusSquared){const s=Math.atan2(t.y-e,t.x-i);this.options.linear?(this.horizontal=Math.round(Math.cos(s))*this.options.speed*this.reverse*.06,this.vertical=Math.round(Math.sin(s))*this.options.speed*this.reverse*.06):(this.horizontal=Math.cos(s)*this.options.speed*this.reverse*.06,this.vertical=Math.sin(s)*this.options.speed*this.reverse*.06)}else this.horizontal&&this.decelerateHorizontal(),this.vertical&&this.decelerateVertical(),this.horizontal=this.vertical=0}else null!==this.left&&i<this.left?this.horizontal=Number(this.reverse)*this.options.speed*.06:null!==this.right&&i>this.right?this.horizontal=-1*this.reverse*this.options.speed*.06:(this.decelerateHorizontal(),this.horizontal=0),null!==this.top&&e<this.top?this.vertical=Number(this.reverse)*this.options.speed*.06:null!==this.bottom&&e>this.bottom?this.vertical=-1*this.reverse*this.options.speed*.06:(this.decelerateVertical(),this.vertical=0);return!1}decelerateHorizontal(){const t=this.parent.plugins.get("decelerate",!0);this.horizontal&&t&&!this.options.noDecelerate&&t.activate({x:this.horizontal*this.options.speed*this.reverse/(1e3/60)})}decelerateVertical(){const t=this.parent.plugins.get("decelerate",!0);this.vertical&&t&&!this.options.noDecelerate&&t.activate({y:this.vertical*this.options.speed*this.reverse/(1e3/60)})}up(){return this.paused||(this.horizontal&&this.decelerateHorizontal(),this.vertical&&this.decelerateVertical(),this.horizontal=this.vertical=null),!1}update(){if(!this.paused&&(this.horizontal||this.vertical)){const t=this.parent.center;this.horizontal&&(t.x+=this.horizontal*this.options.speed),this.vertical&&(t.y+=this.vertical*this.options.speed),this.parent.moveCenter(t),this.parent.emit("moved",{viewport:this.parent,type:"mouse-edges"})}}}const z={noDrag:!1,percent:1,center:null,factor:1,axis:"all"};class _ extends r{__init(){this.active=!1}__init2(){this.pinching=!1}__init3(){this.moved=!1}constructor(t,i={}){super(t),_.prototype.__init.call(this),_.prototype.__init2.call(this),_.prototype.__init3.call(this),this.options=Object.assign({},z,i)}down(){return this.parent.input.count()>=2&&(this.active=!0,!0)}isAxisX(){return["all","x"].includes(this.options.axis)}isAxisY(){return["all","y"].includes(this.options.axis)}move(t){if(this.paused||!this.active)return!1;const i=t.data.global.x,e=t.data.global.y,s=this.parent.input.touches;if(s.length>=2){const h=s[0],n=s[1],o=h.last&&n.last?Math.sqrt(Math.pow(n.last.x-h.last.x,2)+Math.pow(n.last.y-h.last.y,2)):null;if(h.id===t.data.pointerId?h.last={x:i,y:e,data:t.data}:n.id===t.data.pointerId&&(n.last={x:i,y:e,data:t.data}),o){let t;const i={x:h.last.x+(n.last.x-h.last.x)/2,y:h.last.y+(n.last.y-h.last.y)/2};this.options.center||(t=this.parent.toLocal(i));let e=Math.sqrt(Math.pow(n.last.x-h.last.x,2)+Math.pow(n.last.y-h.last.y,2));e=0===e?e=1e-10:e;const s=(1-o/e)*this.options.percent*(this.isAxisX()?this.parent.scale.x:this.parent.scale.y);this.isAxisX()&&(this.parent.scale.x+=s),this.isAxisY()&&(this.parent.scale.y+=s),this.parent.emit("zoomed",{viewport:this.parent,type:"pinch",center:i});const r=this.parent.plugins.get("clamp-zoom",!0);if(r&&r.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const e=this.parent.toGlobal(t);this.parent.x+=(i.x-e.x)*this.options.factor,this.parent.y+=(i.y-e.y)*this.options.factor,this.parent.emit("moved",{viewport:this.parent,type:"pinch"})}!this.options.noDrag&&this.lastCenter&&(this.parent.x+=(i.x-this.lastCenter.x)*this.options.factor,this.parent.y+=(i.y-this.lastCenter.y)*this.options.factor,this.parent.emit("moved",{viewport:this.parent,type:"pinch"})),this.lastCenter=i,this.moved=!0}else this.pinching||(this.parent.emit("pinch-start",this.parent),this.pinching=!0);return!0}return!1}up(){return!!(this.pinching&&this.parent.input.touches.length<=1)&&(this.active=!1,this.lastCenter=null,this.pinching=!1,this.moved=!1,this.parent.emit("pinch-end",this.parent),!0)}}const X={topLeft:!1,friction:.8,time:1e3,ease:"easeInOutSine",interrupt:!0,removeOnComplete:!1,removeOnInterrupt:!1,forceStart:!1};class k extends r{constructor(t,i,e,s={}){super(t),this.options=Object.assign({},X,s),this.ease=a(s.ease,"easeInOutSine"),this.x=i,this.y=e,this.options.forceStart&&this.snapStart()}snapStart(){this.percent=0,this.snapping={time:0};const t=this.options.topLeft?this.parent.corner:this.parent.center;this.deltaX=this.x-t.x,this.deltaY=this.y-t.y,this.startX=t.x,this.startY=t.y,this.parent.emit("snap-start",this.parent)}wheel(){return this.options.removeOnInterrupt&&this.parent.plugins.remove("snap"),!1}down(){return this.options.removeOnInterrupt?this.parent.plugins.remove("snap"):this.options.interrupt&&(this.snapping=null),!1}up(){if(0===this.parent.input.count()){const t=this.parent.plugins.get("decelerate",!0);t&&(t.x||t.y)&&(t.percentChangeX=t.percentChangeY=this.options.friction)}return!1}update(t){if(!(this.paused||this.options.interrupt&&0!==this.parent.input.count()))if(this.snapping){const i=this.snapping;let e,s,h;i.time+=t;const n=this.startX,o=this.startY,r=this.deltaX,a=this.deltaY;if(i.time>this.options.time)e=!0,s=n+r,h=o+a;else{const t=this.ease(i.time,0,1,this.options.time);s=n+r*t,h=o+a*t}this.options.topLeft?this.parent.moveCorner(s,h):this.parent.moveCenter(s,h),this.parent.emit("moved",{viewport:this.parent,type:"snap"}),e&&(this.options.removeOnComplete&&this.parent.plugins.remove("snap"),this.parent.emit("snap-end",this.parent),this.snapping=null)}else{const t=this.options.topLeft?this.parent.corner:this.parent.center;t.x===this.x&&t.y===this.y||this.snapStart()}}}const P={width:0,height:0,time:1e3,ease:"easeInOutSine",center:null,interrupt:!0,removeOnComplete:!1,removeOnInterrupt:!1,forceStart:!1,noMove:!1};class O extends r{constructor(t,i={}){super(t),this.options=Object.assign({},P,i),this.ease=a(this.options.ease),this.xIndependent=!1,this.yIndependent=!1,this.xScale=0,this.yScale=0,this.options.width>0&&(this.xScale=t.screenWidth/this.options.width,this.xIndependent=!0),this.options.height>0&&(this.yScale=t.screenHeight/this.options.height,this.yIndependent=!0),this.xScale=this.xIndependent?this.xScale:this.yScale,this.yScale=this.yIndependent?this.yScale:this.xScale,0===this.options.time?(t.container.scale.x=this.xScale,t.container.scale.y=this.yScale,this.options.removeOnComplete&&this.parent.plugins.remove("snap-zoom")):i.forceStart&&this.createSnapping()}createSnapping(){const t=this.parent.worldScreenWidth,i=this.parent.worldScreenHeight,e=this.parent.screenWidth/this.xScale,s=this.parent.screenHeight/this.yScale;this.snapping={time:0,startX:t,startY:i,deltaX:e-t,deltaY:s-i},this.parent.emit("snap-zoom-start",this.parent)}resize(){this.snapping=null,this.options.width>0&&(this.xScale=this.parent.screenWidth/this.options.width),this.options.height>0&&(this.yScale=this.parent.screenHeight/this.options.height),this.xScale=this.xIndependent?this.xScale:this.yScale,this.yScale=this.yIndependent?this.yScale:this.xScale}wheel(){return this.options.removeOnInterrupt&&this.parent.plugins.remove("snap-zoom"),!1}down(){return this.options.removeOnInterrupt?this.parent.plugins.remove("snap-zoom"):this.options.interrupt&&(this.snapping=null),!1}update(t){if(this.paused)return;if(this.options.interrupt&&0!==this.parent.input.count())return;let i;if(this.options.center||this.options.noMove||(i=this.parent.center),this.snapping){if(this.snapping){const e=this.snapping;if(e.time+=t,e.time>=this.options.time)this.parent.scale.set(this.xScale,this.yScale),this.options.removeOnComplete&&this.parent.plugins.remove("snap-zoom"),this.parent.emit("snap-zoom-end",this.parent),this.snapping=null;else{const t=this.snapping,i=this.ease(t.time,t.startX,t.deltaX,this.options.time),e=this.ease(t.time,t.startY,t.deltaY,this.options.time);this.parent.scale.x=this.parent.screenWidth/i,this.parent.scale.y=this.parent.screenHeight/e}const s=this.parent.plugins.get("clamp-zoom",!0);s&&s.clamp(),this.options.noMove||(this.options.center?this.parent.moveCenter(this.options.center):this.parent.moveCenter(i))}}else this.parent.scale.x===this.xScale&&this.parent.scale.y===this.yScale||this.createSnapping()}resume(){this.snapping=null,super.resume()}}const Y={percent:.1,smooth:!1,interrupt:!0,reverse:!1,center:null,lineHeight:20,axis:"all"};class A extends r{constructor(t,i={}){super(t),this.options=Object.assign({},Y,i)}down(){return this.options.interrupt&&(this.smoothing=null),!1}isAxisX(){return["all","x"].includes(this.options.axis)}isAxisY(){return["all","y"].includes(this.options.axis)}update(){if(this.smoothing){const t=this.smoothingCenter,i=this.smoothing;let e;this.options.center||(e=this.parent.toLocal(t)),this.isAxisX()&&(this.parent.scale.x+=i.x),this.isAxisY()&&(this.parent.scale.y+=i.y),this.parent.emit("zoomed",{viewport:this.parent,type:"wheel"});const s=this.parent.plugins.get("clamp-zoom",!0);if(s&&s.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const i=this.parent.toGlobal(e);this.parent.x+=t.x-i.x,this.parent.y+=t.y-i.y}this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.smoothingCount++,this.smoothingCount>=this.options.smooth&&(this.smoothing=null)}}wheel(t){if(this.paused)return;const i=this.parent.input.getPointerPosition(t),e=(this.options.reverse?-1:1)*-t.deltaY*(t.deltaMode?this.options.lineHeight:1)/500,s=Math.pow(2,(1+this.options.percent)*e);if(this.options.smooth){const t={x:this.smoothing?this.smoothing.x*(this.options.smooth-this.smoothingCount):0,y:this.smoothing?this.smoothing.y*(this.options.smooth-this.smoothingCount):0};this.smoothing={x:((this.parent.scale.x+t.x)*s-this.parent.scale.x)/this.options.smooth,y:((this.parent.scale.y+t.y)*s-this.parent.scale.y)/this.options.smooth},this.smoothingCount=0,this.smoothingCenter=i}else{let t;this.options.center||(t=this.parent.toLocal(i)),this.isAxisX()&&(this.parent.scale.x*=s),this.isAxisY()&&(this.parent.scale.y*=s),this.parent.emit("zoomed",{viewport:this.parent,type:"wheel"});const e=this.parent.plugins.get("clamp-zoom",!0);if(e&&e.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const e=this.parent.toGlobal(t);this.parent.x+=i.x-e.x,this.parent.y+=i.y-e.y}}return this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.parent.emit("wheel",{wheel:{dx:t.deltaX,dy:t.deltaY,dz:t.deltaZ},event:t,viewport:this.parent}),!this.parent.options.passiveWheel||void 0}}class I{constructor(t){this.viewport=t,this.touches=[],this.addListeners()}addListeners(){this.viewport.interactive=!0,this.viewport.forceHitArea||(this.viewport.hitArea=new i.Rectangle(0,0,this.viewport.worldWidth,this.viewport.worldHeight)),this.viewport.on("pointerdown",this.down,this),this.viewport.on("pointermove",this.move,this),this.viewport.on("pointerup",this.up,this),this.viewport.on("pointerupoutside",this.up,this),this.viewport.on("pointercancel",this.up,this),this.viewport.on("pointerout",this.up,this),this.wheelFunction=t=>this.handleWheel(t),this.viewport.options.divWheel.addEventListener("wheel",this.wheelFunction,{passive:this.viewport.options.passiveWheel}),this.isMouseDown=!1}destroy(){this.viewport.options.divWheel.removeEventListener("wheel",this.wheelFunction)}down(t){if(this.viewport.pause||!this.viewport.worldVisible)return;if("mouse"===t.data.pointerType?this.isMouseDown=!0:this.get(t.data.pointerId)||this.touches.push({id:t.data.pointerId,last:null}),1===this.count()){this.last=t.data.global.clone();const i=this.viewport.plugins.get("decelerate",!0),e=this.viewport.plugins.get("bounce",!0);i&&i.isActive()||e&&e.isActive()?this.clickedAvailable=!1:this.clickedAvailable=!0}else this.clickedAvailable=!1;this.viewport.plugins.down(t)&&this.viewport.options.stopPropagation&&t.stopPropagation()}clear(){this.isMouseDown=!1,this.touches=[],this.last=null}checkThreshold(t){return Math.abs(t)>=this.viewport.threshold}move(t){if(this.viewport.pause||!this.viewport.worldVisible)return;const i=this.viewport.plugins.move(t);if(this.clickedAvailable&&this.last){const i=t.data.global.x-this.last.x,e=t.data.global.y-this.last.y;(this.checkThreshold(i)||this.checkThreshold(e))&&(this.clickedAvailable=!1)}i&&this.viewport.options.stopPropagation&&t.stopPropagation()}up(t){if(this.viewport.pause||!this.viewport.worldVisible)return;"mouse"===t.data.pointerType&&(this.isMouseDown=!1),"mouse"!==t.data.pointerType&&this.remove(t.data.pointerId);const i=this.viewport.plugins.up(t);this.clickedAvailable&&0===this.count()&&this.last&&(this.viewport.emit("clicked",{event:t,screen:this.last,world:this.viewport.toWorld(this.last),viewport:this}),this.clickedAvailable=!1),i&&this.viewport.options.stopPropagation&&t.stopPropagation()}getPointerPosition(t){const e=new i.Point;return this.viewport.options.interaction?this.viewport.options.interaction.mapPositionToPoint(e,t.clientX,t.clientY):(e.x=t.clientX,e.y=t.clientY),e}handleWheel(t){if(this.viewport.pause||!this.viewport.worldVisible)return;if(this.viewport.options.interaction&&this.viewport.options.interaction.interactionDOMElement!==t.target)return;const i=this.viewport.toLocal(this.getPointerPosition(t));if(this.viewport.left<=i.x&&i.x<=this.viewport.right&&this.viewport.top<=i.y&&i.y<=this.viewport.bottom){this.viewport.plugins.wheel(t)&&!this.viewport.options.passiveWheel&&t.preventDefault()}}pause(){this.touches=[],this.isMouseDown=!1}get(t){for(const i of this.touches)if(i.id===t)return i;return null}remove(t){for(let i=0;i<this.touches.length;i++)if(this.touches[i].id===t)return void this.touches.splice(i,1)}count(){return(this.isMouseDown?1:0)+this.touches.length}}function D(t){let i=void 0,e=t[0],s=1;for(;s<t.length;){const h=t[s],n=t[s+1];if(s+=2,("optionalAccess"===h||"optionalCall"===h)&&null==e)return;"access"===h||"optionalAccess"===h?(i=e,e=n(e)):"call"!==h&&"optionalCall"!==h||(e=n(((...t)=>e.call(i,...t))),i=void 0)}return e}const T=["drag","pinch","wheel","follow","mouse-edges","decelerate","aniamte","bounce","snap-zoom","clamp-zoom","snap","clamp"];class V{constructor(t){this.viewport=t,this.list=[],this.plugins={}}add(t,i,e=T.length){this.plugins[t]=i;const s=T.indexOf(t);-1!==s&&T.splice(s,1),T.splice(e,0,t),this.sort()}get(t,i){return i&&D([this,"access",t=>t.plugins,"access",i=>i[t],"optionalAccess",t=>t.paused])?null:this.plugins[t]}update(t){for(const i of this.list)i.update(t)}resize(){for(const t of this.list)t.resize()}reset(){for(const t of this.list)t.reset()}removeAll(){this.plugins={},this.sort()}remove(t){this.plugins[t]&&(delete this.plugins[t],this.viewport.emit(t+"-remove"),this.sort())}pause(t){D([this,"access",t=>t.plugins,"access",i=>i[t],"optionalAccess",t=>t.pause,"call",t=>t()])}resume(t){D([this,"access",t=>t.plugins,"access",i=>i[t],"optionalAccess",t=>t.resume,"call",t=>t()])}sort(){this.list=[];for(const t of T)this.plugins[t]&&this.list.push(this.plugins[t])}down(t){let i=!1;for(const e of this.list)e.down(t)&&(i=!0);return i}move(t){let i=!1;for(const e of this.viewport.plugins.list)e.move(t)&&(i=!0);return i}up(t){let i=!1;for(const e of this.list)e.up(t)&&(i=!0);return i}wheel(t){let i=!1;for(const e of this.list)e.wheel(t)&&(i=!0);return i}}const L={screenWidth:window.innerWidth,screenHeight:window.innerHeight,worldWidth:null,worldHeight:null,threshold:5,passiveWheel:!0,stopPropagation:!1,forceHitArea:null,noTicker:!1,interaction:null,disableOnContextMenu:!1,ticker:h.Ticker.shared};class j extends s.Container{constructor(t={}){super(),this.options=Object.assign({},{divWheel:document.body},L,t),this.screenWidth=this.options.screenWidth,this.screenHeight=this.options.screenHeight,this._worldWidth=this.options.worldWidth,this._worldHeight=this.options.worldHeight,this.forceHitArea=this.options.forceHitArea,this.threshold=this.options.threshold,this.options.divWheel=this.options.divWheel||document.body,this.options.disableOnContextMenu&&(this.options.divWheel.oncontextmenu=t=>t.preventDefault()),this.options.noTicker||(this.tickerFunction=()=>this.update(this.options.ticker.elapsedMS),this.options.ticker.add(this.tickerFunction)),this.input=new I(this),this.plugins=new V(this)}destroy(t){!this.options.noTicker&&this.tickerFunction&&this.options.ticker.remove(this.tickerFunction),this.input.destroy(),super.destroy(t)}update(t){this.pause||(this.plugins.update(t),this.lastViewport&&(this.lastViewport.x!==this.x||this.lastViewport.y!==this.y?this.moving=!0:this.moving&&(this.emit("moved-end",this),this.moving=!1),this.lastViewport.scaleX!==this.scale.x||this.lastViewport.scaleY!==this.scale.y?this.zooming=!0:this.zooming&&(this.emit("zoomed-end",this),this.zooming=!1)),this.forceHitArea||(this._hitAreaDefault=new i.Rectangle(this.left,this.top,this.worldScreenWidth,this.worldScreenHeight),this.hitArea=this._hitAreaDefault),this._dirty=this._dirty||!this.lastViewport||this.lastViewport.x!==this.x||this.lastViewport.y!==this.y||this.lastViewport.scaleX!==this.scale.x||this.lastViewport.scaleY!==this.scale.y,this.lastViewport={x:this.x,y:this.y,scaleX:this.scale.x,scaleY:this.scale.y},this.emit("frame-end",this))}resize(t=window.innerWidth,i=window.innerHeight,e,s){this.screenWidth=t,this.screenHeight=i,void 0!==e&&(this._worldWidth=e),void 0!==s&&(this._worldHeight=s),this.plugins.resize(),this.dirty=!0}get worldWidth(){return this._worldWidth?this._worldWidth:this.width/this.scale.x}set worldWidth(t){this._worldWidth=t,this.plugins.resize()}get worldHeight(){return this._worldHeight?this._worldHeight:this.height/this.scale.y}set worldHeight(t){this._worldHeight=t,this.plugins.resize()}getVisibleBounds(){return new i.Rectangle(this.left,this.top,this.worldScreenWidth,this.worldScreenHeight)}toWorld(t,e){return 2===arguments.length?this.toLocal(new i.Point(t,e)):this.toLocal(t)}toScreen(t,e){return 2===arguments.length?this.toGlobal(new i.Point(t,e)):this.toGlobal(t)}get worldScreenWidth(){return this.screenWidth/this.scale.x}get worldScreenHeight(){return this.screenHeight/this.scale.y}get screenWorldWidth(){return this.worldWidth*this.scale.x}get screenWorldHeight(){return this.worldHeight*this.scale.y}get center(){return new i.Point(this.worldScreenWidth/2-this.x/this.scale.x,this.worldScreenHeight/2-this.y/this.scale.y)}set center(t){this.moveCenter(t)}moveCenter(...t){let i,e;"number"==typeof t[0]?(i=t[0],e=t[1]):(i=t[0].x,e=t[0].y);const s=(this.worldScreenWidth/2-i)*this.scale.x,h=(this.worldScreenHeight/2-e)*this.scale.y;return this.x===s&&this.y===h||(this.position.set(s,h),this.plugins.reset(),this.dirty=!0),this}get corner(){return new i.Point(-this.x/this.scale.x,-this.y/this.scale.y)}set corner(t){this.moveCorner(t)}moveCorner(...t){let i,e;return 1===t.length?(i=-t[0].x*this.scale.x,e=-t[0].y*this.scale.y):(i=-t[0]*this.scale.x,e=-t[1]*this.scale.y),i===this.x&&e===this.y||(this.position.set(i,e),this.plugins.reset(),this.dirty=!0),this}get screenWidthInWorldPixels(){return this.screenWidth/this.scale.x}get screenHeightInWorldPixels(){return this.screenHeight/this.scale.y}findFitWidth(t){return this.screenWidth/t}findFitHeight(t){return this.screenHeight/t}findFit(t,i){const e=this.screenWidth/t,s=this.screenHeight/i;return Math.min(e,s)}findCover(t,i){const e=this.screenWidth/t,s=this.screenHeight/i;return Math.max(e,s)}fitWidth(t=this.worldWidth,i,e=!0,s){let h;i&&(h=this.center),this.scale.x=this.screenWidth/t,e&&(this.scale.y=this.scale.x);const n=this.plugins.get("clamp-zoom",!0);return!s&&n&&n.clamp(),i&&h&&this.moveCenter(h),this}fitHeight(t=this.worldHeight,i,e=!0,s){let h;i&&(h=this.center),this.scale.y=this.screenHeight/t,e&&(this.scale.x=this.scale.y);const n=this.plugins.get("clamp-zoom",!0);return!s&&n&&n.clamp(),i&&h&&this.moveCenter(h),this}fitWorld(t){let i;t&&(i=this.center),this.scale.x=this.screenWidth/this.worldWidth,this.scale.y=this.screenHeight/this.worldHeight,this.scale.x<this.scale.y?this.scale.y=this.scale.x:this.scale.x=this.scale.y;const e=this.plugins.get("clamp-zoom",!0);return e&&e.clamp(),t&&i&&this.moveCenter(i),this}fit(t,i=this.worldWidth,e=this.worldHeight){let s;t&&(s=this.center),this.scale.x=this.screenWidth/i,this.scale.y=this.screenHeight/e,this.scale.x<this.scale.y?this.scale.y=this.scale.x:this.scale.x=this.scale.y;const h=this.plugins.get("clamp-zoom",!0);return h&&h.clamp(),t&&s&&this.moveCenter(s),this}set visible(t){t||this.input.clear(),super.visible=t}setZoom(t,i){let e;i&&(e=this.center),this.scale.set(t);const s=this.plugins.get("clamp-zoom",!0);return s&&s.clamp(),i&&e&&this.moveCenter(e),this}zoomPercent(t,i){return this.setZoom(this.scale.x+this.scale.x*t,i)}zoom(t,i){return this.fitWidth(t+this.worldScreenWidth,i),this}get scaled(){return this.scale.x}set scaled(t){this.setZoom(t,!0)}snapZoom(t){return this.plugins.add("snap-zoom",new O(this,t)),this}OOB(){return{left:this.left<0,right:this.right>this.worldWidth,top:this.top<0,bottom:this.bottom>this.worldHeight,cornerPoint:new i.Point(this.worldWidth*this.scale.x-this.screenWidth,this.worldHeight*this.scale.y-this.screenHeight)}}get right(){return-this.x/this.scale.x+this.worldScreenWidth}set right(t){this.x=-t*this.scale.x+this.screenWidth,this.plugins.reset()}get left(){return-this.x/this.scale.x}set left(t){this.x=-t*this.scale.x,this.plugins.reset()}get top(){return-this.y/this.scale.y}set top(t){this.y=-t*this.scale.y,this.plugins.reset()}get bottom(){return-this.y/this.scale.y+this.worldScreenHeight}set bottom(t){this.y=-t*this.scale.y+this.screenHeight,this.plugins.reset()}get dirty(){return!!this._dirty}set dirty(t){this._dirty=t}get forceHitArea(){return this._forceHitArea}set forceHitArea(t){t?(this._forceHitArea=t,this.hitArea=t):(this._forceHitArea=null,this.hitArea=new i.Rectangle(0,0,this.worldWidth,this.worldHeight))}drag(t){return this.plugins.add("drag",new b(this,t)),this}clamp(t){return this.plugins.add("clamp",new m(this,t)),this}decelerate(t){return this.plugins.add("decelerate",new v(this,t)),this}bounce(t){return this.plugins.add("bounce",new u(this,t)),this}pinch(t){return this.plugins.add("pinch",new _(this,t)),this}snap(t,i,e){return this.plugins.add("snap",new k(this,t,i,e)),this}follow(t,i){return this.plugins.add("follow",new S(this,t,i)),this}wheel(t){return this.plugins.add("wheel",new A(this,t)),this}animate(t){return this.plugins.add("animate",new l(this,t)),this}clampZoom(t){return this.plugins.add("clamp-zoom",new y(this,t)),this}mouseEdges(t){return this.plugins.add("mouse-edges",new C(this,t)),this}get pause(){return!!this._pause}set pause(t){this._pause=t,this.lastViewport=null,this.moving=!1,this.zooming=!1,t&&this.input.pause()}ensureVisible(t,i,e,s,h){h&&(e>this.worldScreenWidth||s>this.worldScreenHeight)&&(this.fit(!0,e,s),this.emit("zoomed",{viewport:this,type:"ensureVisible"}));let n=!1;t<this.left?(this.left=t,n=!0):t+e>this.right&&(this.right=t+e,n=!0),i<this.top?(this.top=i,n=!0):i+s>this.bottom&&(this.bottom=i+s,n=!0),n&&this.emit("moved",{viewport:this,type:"ensureVisible"})}}t.Animate=l,t.Bounce=u,t.Clamp=m,t.ClampZoom=y,t.Decelerate=v,t.Drag=b,t.Follow=S,t.InputManager=I,t.MouseEdges=C,t.Pinch=_,t.Plugin=r,t.PluginManager=V,t.Snap=k,t.SnapZoom=O,t.Viewport=j,t.Wheel=A,Object.defineProperty(t,"__esModule",{value:!0})})),"undefined"!=typeof pixi_viewport&&Object.assign(this.PIXI,pixi_viewport);
this.PIXI=this.PIXI||{},function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports,require("@pixi/math"),require("penner"),require("@pixi/display"),require("@pixi/ticker")):"function"==typeof define&&define.amd?define(["exports","@pixi/math","penner","@pixi/display","@pixi/ticker"],i):i((t="undefined"!=typeof globalThis?globalThis:t||self).pixi_viewport={},t.PIXI,t.Penner,t.PIXI,t.PIXI)}(this,(function(t,i,e,s,h){"use strict";function n(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var o=n(e);class r{constructor(t){this.parent=t,this.paused=!1}destroy(){}down(t){return!1}move(t){return!1}up(t){return!1}wheel(t){return!1}update(t){}resize(){}reset(){}pause(){this.paused=!0}resume(){this.paused=!1}}function a(t,i){return t?"function"==typeof t?t:"string"==typeof t?o.default[t]:void 0:o.default[i]}const p={removeOnInterrupt:!1,ease:"linear",time:1e3};class l extends r{__init(){this.startWidth=null}__init2(){this.startHeight=null}__init3(){this.deltaWidth=null}__init4(){this.deltaHeight=null}__init5(){this.width=null}__init6(){this.height=null}__init7(){this.time=0}constructor(t,i={}){super(t),l.prototype.__init.call(this),l.prototype.__init2.call(this),l.prototype.__init3.call(this),l.prototype.__init4.call(this),l.prototype.__init5.call(this),l.prototype.__init6.call(this),l.prototype.__init7.call(this),this.options=Object.assign({},p,i),this.options.ease=a(this.options.ease),this.setupPosition(),this.setupZoom(),this.time=0}setupPosition(){void 0!==this.options.position?(this.startX=this.parent.center.x,this.startY=this.parent.center.y,this.deltaX=this.options.position.x-this.parent.center.x,this.deltaY=this.options.position.y-this.parent.center.y,this.keepCenter=!1):this.keepCenter=!0}setupZoom(){this.width=null,this.height=null,void 0!==this.options.scale?this.width=this.parent.screenWidth/this.options.scale:void 0!==this.options.scaleX||void 0!==this.options.scaleY?(void 0!==this.options.scaleX&&(this.width=this.parent.screenWidth/this.options.scaleX),void 0!==this.options.scaleY&&(this.height=this.parent.screenHeight/this.options.scaleY)):(void 0!==this.options.width&&(this.width=this.options.width),void 0!==this.options.height&&(this.height=this.options.height)),null!==this.width&&(this.startWidth=this.parent.screenWidthInWorldPixels,this.deltaWidth=this.width-this.startWidth),null!==this.height&&(this.startHeight=this.parent.screenHeightInWorldPixels,this.deltaHeight=this.height-this.startHeight)}down(){return this.options.removeOnInterrupt&&this.parent.plugins.remove("animate"),!1}complete(){this.parent.plugins.remove("animate"),null!==this.width&&this.parent.fitWidth(this.width,this.keepCenter,null===this.height),null!==this.height&&this.parent.fitHeight(this.height,this.keepCenter,null===this.width),this.keepCenter||this.parent.moveCenter(this.options.position),this.parent.emit("animate-end",this.parent),this.options.callbackOnComplete&&this.options.callbackOnComplete(this.parent)}update(t){if(!this.paused)if(this.time+=t,this.time>=this.options.time)this.complete();else{const t=new i.Point(this.parent.scale.x,this.parent.scale.y),e=this.options.ease(this.time,0,1,this.options.time);if(null!==this.width){const t=this.startWidth,i=this.deltaWidth;this.parent.fitWidth(t+i*e,this.keepCenter,null===this.height)}if(null!==this.height){const t=this.startHeight,i=this.deltaHeight;this.parent.fitHeight(t+i*e,this.keepCenter,null===this.width)}if(null===this.width?this.parent.scale.x=this.parent.scale.y:null===this.height&&(this.parent.scale.y=this.parent.scale.x),!this.keepCenter){const t=this.startX,s=this.startY,h=this.deltaX,n=this.deltaY,o=new i.Point(this.parent.x,this.parent.y);this.parent.moveCenter(t+h*e,s+n*e),this.parent.emit("moved",{viewport:this.parent,original:o,type:"animate"})}(this.width||this.height)&&this.parent.emit("zoomed",{viewport:this.parent,original:t,type:"animate"})}}}function c(t){let i=void 0,e=t[0],s=1;for(;s<t.length;){const h=t[s],n=t[s+1];if(s+=2,("optionalAccess"===h||"optionalCall"===h)&&null==e)return;"access"===h||"optionalAccess"===h?(i=e,e=n(e)):"call"!==h&&"optionalCall"!==h||(e=n(((...t)=>e.call(i,...t))),i=void 0)}return e}const d={sides:"all",friction:.5,time:150,ease:"easeInOutSine",underflow:"center",bounceBox:null};class u extends r{constructor(t,i={}){super(t),this.options=Object.assign({},d,i),this.ease=a(this.options.ease,"easeInOutSine"),this.options.sides?"all"===this.options.sides?this.top=this.bottom=this.left=this.right=!0:"horizontal"===this.options.sides?(this.right=this.left=!0,this.top=this.bottom=!1):"vertical"===this.options.sides?(this.left=this.right=!1,this.top=this.bottom=!0):(this.top=-1!==this.options.sides.indexOf("top"),this.bottom=-1!==this.options.sides.indexOf("bottom"),this.left=-1!==this.options.sides.indexOf("left"),this.right=-1!==this.options.sides.indexOf("right")):this.left=this.top=this.right=this.bottom=!1;const e=this.options.underflow.toLowerCase();"center"===e?(this.underflowX=0,this.underflowY=0):(this.underflowX=-1!==e.indexOf("left")?-1:-1!==e.indexOf("right")?1:0,this.underflowY=-1!==e.indexOf("top")?-1:-1!==e.indexOf("bottom")?1:0),this.reset()}isActive(){return null!==this.toX||null!==this.toY}down(){return this.toX=this.toY=null,!1}up(){return this.bounce(),!1}update(t){if(!this.paused){if(this.bounce(),this.toX){const i=this.toX;i.time+=t,this.parent.emit("moved",{viewport:this.parent,type:"bounce-x"}),i.time>=this.options.time?(this.parent.x=i.end,this.toX=null,this.parent.emit("bounce-x-end",this.parent)):this.parent.x=this.ease(i.time,i.start,i.delta,this.options.time)}if(this.toY){const i=this.toY;i.time+=t,this.parent.emit("moved",{viewport:this.parent,type:"bounce-y"}),i.time>=this.options.time?(this.parent.y=i.end,this.toY=null,this.parent.emit("bounce-y-end",this.parent)):this.parent.y=this.ease(i.time,i.start,i.delta,this.options.time)}}}calcUnderflowX(){let t;switch(this.underflowX){case-1:t=0;break;case 1:t=this.parent.screenWidth-this.parent.screenWorldWidth;break;default:t=(this.parent.screenWidth-this.parent.screenWorldWidth)/2}return t}calcUnderflowY(){let t;switch(this.underflowY){case-1:t=0;break;case 1:t=this.parent.screenHeight-this.parent.screenWorldHeight;break;default:t=(this.parent.screenHeight-this.parent.screenWorldHeight)/2}return t}oob(){const t=this.options.bounceBox;if(t){const e=void 0===t.x?0:t.x,s=void 0===t.y?0:t.y,h=void 0===t.width?this.parent.worldWidth:t.width,n=void 0===t.height?this.parent.worldHeight:t.height;return{left:this.parent.left<e,right:this.parent.right>h,top:this.parent.top<s,bottom:this.parent.bottom>n,topLeft:new i.Point(e*this.parent.scale.x,s*this.parent.scale.y),bottomRight:new i.Point(h*this.parent.scale.x-this.parent.screenWidth,n*this.parent.scale.y-this.parent.screenHeight)}}return{left:this.parent.left<0,right:this.parent.right>this.parent.worldWidth,top:this.parent.top<0,bottom:this.parent.bottom>this.parent.worldHeight,topLeft:new i.Point(0,0),bottomRight:new i.Point(this.parent.worldWidth*this.parent.scale.x-this.parent.screenWidth,this.parent.worldHeight*this.parent.scale.y-this.parent.screenHeight)}}bounce(){if(this.paused)return;let t,i=this.parent.plugins.get("decelerate",!0);i&&(i.x||i.y)&&(i.x&&i.percentChangeX===c([i,"access",t=>t.options,"optionalAccess",t=>t.friction])||i.y&&i.percentChangeY===c([i,"access",t=>t.options,"optionalAccess",t=>t.friction]))&&(t=this.oob(),(t.left&&this.left||t.right&&this.right)&&(i.percentChangeX=this.options.friction),(t.top&&this.top||t.bottom&&this.bottom)&&(i.percentChangeY=this.options.friction));const e=this.parent.plugins.get("drag",!0)||{},s=this.parent.plugins.get("pinch",!0)||{};if(i=i||{},!(c([e,"optionalAccess",t=>t.active])||c([s,"optionalAccess",t=>t.active])||this.toX&&this.toY||i.x&&i.y)){t=t||this.oob();const e=t.topLeft,s=t.bottomRight;if(!this.toX&&!i.x){let i=null;t.left&&this.left?i=this.parent.screenWorldWidth<this.parent.screenWidth?this.calcUnderflowX():-e.x:t.right&&this.right&&(i=this.parent.screenWorldWidth<this.parent.screenWidth?this.calcUnderflowX():-s.x),null!==i&&this.parent.x!==i&&(this.toX={time:0,start:this.parent.x,delta:i-this.parent.x,end:i},this.parent.emit("bounce-x-start",this.parent))}if(!this.toY&&!i.y){let i=null;t.top&&this.top?i=this.parent.screenWorldHeight<this.parent.screenHeight?this.calcUnderflowY():-e.y:t.bottom&&this.bottom&&(i=this.parent.screenWorldHeight<this.parent.screenHeight?this.calcUnderflowY():-s.y),null!==i&&this.parent.y!==i&&(this.toY={time:0,start:this.parent.y,delta:i-this.parent.y,end:i},this.parent.emit("bounce-y-start",this.parent))}}}reset(){this.toX=this.toY=null,this.bounce()}}const g={left:!1,right:!1,top:!1,bottom:!1,direction:null,underflow:"center"};class m extends r{constructor(t,i={}){super(t),this.options=Object.assign({},g,i),this.options.direction&&(this.options.left="x"===this.options.direction||"all"===this.options.direction||null,this.options.right="x"===this.options.direction||"all"===this.options.direction||null,this.options.top="y"===this.options.direction||"all"===this.options.direction||null,this.options.bottom="y"===this.options.direction||"all"===this.options.direction||null),this.parseUnderflow(),this.last={x:null,y:null,scaleX:null,scaleY:null},this.update()}parseUnderflow(){const t=this.options.underflow.toLowerCase();"none"===t?this.noUnderflow=!0:"center"===t?(this.underflowX=this.underflowY=0,this.noUnderflow=!1):(this.underflowX=-1!==t.indexOf("left")?-1:-1!==t.indexOf("right")?1:0,this.underflowY=-1!==t.indexOf("top")?-1:-1!==t.indexOf("bottom")?1:0,this.noUnderflow=!1)}move(){return this.update(),!1}update(){if(this.paused)return;if(this.parent.x===this.last.x&&this.parent.y===this.last.y&&this.parent.scale.x===this.last.scaleX&&this.parent.scale.y===this.last.scaleY)return;const t={x:this.parent.x,y:this.parent.y},i=this.parent.plugins.decelerate||{};if(null!==this.options.left||null!==this.options.right){let e=!1;if(!this.noUnderflow&&this.parent.screenWorldWidth<this.parent.screenWidth)switch(this.underflowX){case-1:0!==this.parent.x&&(this.parent.x=0,e=!0);break;case 1:this.parent.x!==this.parent.screenWidth-this.parent.screenWorldWidth&&(this.parent.x=this.parent.screenWidth-this.parent.screenWorldWidth,e=!0);break;default:this.parent.x!==(this.parent.screenWidth-this.parent.screenWorldWidth)/2&&(this.parent.x=(this.parent.screenWidth-this.parent.screenWorldWidth)/2,e=!0)}else null!==this.options.left&&this.parent.left<(!0===this.options.left?0:this.options.left)&&(this.parent.x=-(!0===this.options.left?0:this.options.left)*this.parent.scale.x,i.x=0,e=!0),null!==this.options.right&&this.parent.right>(!0===this.options.right?this.parent.worldWidth:this.options.right)&&(this.parent.x=-(!0===this.options.right?this.parent.worldWidth:this.options.right)*this.parent.scale.x+this.parent.screenWidth,i.x=0,e=!0);e&&this.parent.emit("moved",{viewport:this.parent,original:t,type:"clamp-x"})}if(null!==this.options.top||null!==this.options.bottom){let e=!1;if(!this.noUnderflow&&this.parent.screenWorldHeight<this.parent.screenHeight)switch(this.underflowY){case-1:0!==this.parent.y&&(this.parent.y=0,e=!0);break;case 1:this.parent.y!==this.parent.screenHeight-this.parent.screenWorldHeight&&(this.parent.y=this.parent.screenHeight-this.parent.screenWorldHeight,e=!0);break;default:this.parent.y!==(this.parent.screenHeight-this.parent.screenWorldHeight)/2&&(this.parent.y=(this.parent.screenHeight-this.parent.screenWorldHeight)/2,e=!0)}else null!==this.options.top&&this.parent.top<(!0===this.options.top?0:this.options.top)&&(this.parent.y=-(!0===this.options.top?0:this.options.top)*this.parent.scale.y,i.y=0,e=!0),null!==this.options.bottom&&this.parent.bottom>(!0===this.options.bottom?this.parent.worldHeight:this.options.bottom)&&(this.parent.y=-(!0===this.options.bottom?this.parent.worldHeight:this.options.bottom)*this.parent.scale.y+this.parent.screenHeight,i.y=0,e=!0);e&&this.parent.emit("moved",{viewport:this.parent,original:t,type:"clamp-y"})}this.last.x=this.parent.x,this.last.y=this.parent.y,this.last.scaleX=this.parent.scale.x,this.last.scaleY=this.parent.scale.y}reset(){this.update()}}const w={minWidth:null,minHeight:null,maxWidth:null,maxHeight:null,minScale:null,maxScale:null};class y extends r{constructor(t,i={}){super(t),this.options=Object.assign({},w,i),this.clamp()}resize(){this.clamp()}clamp(){if(!this.paused)if(this.options.minWidth||this.options.minHeight||this.options.maxWidth||this.options.maxHeight){let t=this.parent.worldScreenWidth,i=this.parent.worldScreenHeight;if(null!==this.options.minWidth&&t<this.options.minWidth){const e=this.parent.scale.x;this.parent.fitWidth(this.options.minWidth,!1,!1,!0),this.parent.scale.y*=this.parent.scale.x/e,t=this.parent.worldScreenWidth,i=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(null!==this.options.maxWidth&&t>this.options.maxWidth){const e=this.parent.scale.x;this.parent.fitWidth(this.options.maxWidth,!1,!1,!0),this.parent.scale.y*=this.parent.scale.x/e,t=this.parent.worldScreenWidth,i=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(null!==this.options.minHeight&&i<this.options.minHeight){const e=this.parent.scale.y;this.parent.fitHeight(this.options.minHeight,!1,!1,!0),this.parent.scale.x*=this.parent.scale.y/e,t=this.parent.worldScreenWidth,i=this.parent.worldScreenHeight,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}if(null!==this.options.maxHeight&&i>this.options.maxHeight){const t=this.parent.scale.y;this.parent.fitHeight(this.options.maxHeight,!1,!1,!0),this.parent.scale.x*=this.parent.scale.y/t,this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"})}}else if(this.options.minScale||this.options.maxScale){const t={x:null,y:null},i={x:null,y:null};if("number"==typeof this.options.minScale)t.x=this.options.minScale,t.y=this.options.minScale;else if(null!==this.options.minScale){const i=this.options.minScale;t.x=void 0===i.x?null:i.x,t.y=void 0===i.y?null:i.y}if("number"==typeof this.options.maxScale)i.x=this.options.maxScale,i.y=this.options.maxScale;else if(null!==this.options.maxScale){const t=this.options.maxScale;i.x=void 0===t.x?null:t.x,i.y=void 0===t.y?null:t.y}let e=this.parent.scale.x,s=this.parent.scale.y;null!==t.x&&e<t.x&&(e=t.x),null!==i.x&&e>i.x&&(e=i.x),null!==t.y&&s<t.y&&(s=t.y),null!==i.y&&s>i.y&&(s=i.y),e===this.parent.scale.x&&s===this.parent.scale.y||(this.parent.scale.set(e,s),this.parent.emit("zoomed",{viewport:this.parent,type:"clamp-zoom"}))}}reset(){this.clamp()}}const x={friction:.98,bounce:.8,minSpeed:.01},f=16;class v extends r{constructor(t,i={}){super(t),this.options=Object.assign({},x,i),this.saved=[],this.timeSinceRelease=0,this.reset(),this.parent.on("moved",(t=>this.moved(t)))}down(){return this.saved=[],this.x=this.y=null,!1}isActive(){return!(!this.x&&!this.y)}move(){if(this.paused)return!1;const t=this.parent.input.count();return(1===t||t>1&&!this.parent.plugins.get("pinch",!0))&&(this.saved.push({x:this.parent.x,y:this.parent.y,time:performance.now()}),this.saved.length>60&&this.saved.splice(0,30)),!1}moved(t){if(this.saved.length){const i=this.saved[this.saved.length-1];"clamp-x"===t.type?i.x===t.original.x&&(i.x=this.parent.x):"clamp-y"===t.type&&i.y===t.original.y&&(i.y=this.parent.y)}}up(){if(0===this.parent.input.count()&&this.saved.length){const t=performance.now();for(const i of this.saved)if(i.time>=t-100){const e=t-i.time;this.x=(this.parent.x-i.x)/e,this.y=(this.parent.y-i.y)/e,this.percentChangeX=this.percentChangeY=this.options.friction,this.timeSinceRelease=0;break}}return!1}activate(t){void 0!==(t=t||{}).x&&(this.x=t.x,this.percentChangeX=this.options.friction),void 0!==t.y&&(this.y=t.y,this.percentChangeY=this.options.friction)}update(t){if(this.paused)return;const i=this.x||this.y,e=this.timeSinceRelease,s=this.timeSinceRelease+t;if(this.x){const i=this.percentChangeX,h=Math.log(i);this.parent.x+=this.x*f/h*(Math.pow(i,s/f)-Math.pow(i,e/f)),this.x*=Math.pow(this.percentChangeX,t/f)}if(this.y){const i=this.percentChangeY,h=Math.log(i);this.parent.y+=this.y*f/h*(Math.pow(i,s/f)-Math.pow(i,e/f)),this.y*=Math.pow(this.percentChangeY,t/f)}this.timeSinceRelease+=t,Math.abs(this.x||0)<this.options.minSpeed&&(this.x=0),Math.abs(this.y||0)<this.options.minSpeed&&(this.y=0),i&&this.parent.emit("moved",{viewport:this.parent,type:"decelerate"})}reset(){this.x=this.y=null}}const W={direction:"all",pressDrag:!0,wheel:!0,wheelScroll:1,reverse:!1,clampWheel:!1,underflow:"center",factor:1,mouseButtons:"all",keyToPress:null,ignoreKeyToPressOnTouch:!1,lineHeight:20};class b extends r{constructor(t,i={}){super(t),this.options=Object.assign({},W,i),this.moved=!1,this.reverse=this.options.reverse?1:-1,this.xDirection=!this.options.direction||"all"===this.options.direction||"x"===this.options.direction,this.yDirection=!this.options.direction||"all"===this.options.direction||"y"===this.options.direction,this.keyIsPressed=!1,this.parseUnderflow(),this.mouseButtons(this.options.mouseButtons),this.options.keyToPress&&this.handleKeyPresses(this.options.keyToPress)}handleKeyPresses(t){window.addEventListener("keydown",(i=>{t.includes(i.code)&&(this.keyIsPressed=!0)})),window.addEventListener("keyup",(i=>{t.includes(i.code)&&(this.keyIsPressed=!1)}))}mouseButtons(t){this.mouse=t&&"all"!==t?[-1!==t.indexOf("left"),-1!==t.indexOf("middle"),-1!==t.indexOf("right")]:[!0,!0,!0]}parseUnderflow(){const t=this.options.underflow.toLowerCase();"center"===t?(this.underflowX=0,this.underflowY=0):(this.underflowX=-1!==t.indexOf("left")?-1:-1!==t.indexOf("right")?1:0,this.underflowY=-1!==t.indexOf("top")?-1:-1!==t.indexOf("bottom")?1:0)}checkButtons(t){const i="mouse"===t.data.pointerType,e=this.parent.input.count();return!(!(1===e||e>1&&!this.parent.plugins.get("pinch",!0))||i&&!this.mouse[t.data.button])}checkKeyPress(t){return!this.options.keyToPress||this.keyIsPressed||this.options.ignoreKeyToPressOnTouch&&"touch"===t.data.pointerType}down(t){return!(this.paused||!this.options.pressDrag)&&(this.checkButtons(t)&&this.checkKeyPress(t)?(this.last={x:t.data.global.x,y:t.data.global.y},this.current=t.data.pointerId,!0):(this.last=null,!1))}get active(){return this.moved}move(t){if(this.paused||!this.options.pressDrag)return!1;if(this.last&&this.current===t.data.pointerId){const e=t.data.global.x,s=t.data.global.y,h=this.parent.input.count();if(1===h||h>1&&!this.parent.plugins.get("pinch",!0)){const h=e-this.last.x,n=s-this.last.y;if(this.moved||this.xDirection&&this.parent.input.checkThreshold(h)||this.yDirection&&this.parent.input.checkThreshold(n)){const h={x:e,y:s};return this.xDirection&&(this.parent.x+=(h.x-this.last.x)*this.options.factor),this.yDirection&&(this.parent.y+=(h.y-this.last.y)*this.options.factor),this.last=h,this.moved||this.parent.emit("drag-start",{event:t,screen:new i.Point(this.last.x,this.last.y),world:this.parent.toWorld(new i.Point(this.last.x,this.last.y)),viewport:this.parent}),this.moved=!0,this.parent.emit("moved",{viewport:this.parent,type:"drag"}),!0}}else this.moved=!1}return!1}up(t){if(this.paused)return!1;const e=this.parent.input.touches;if(1===e.length){const t=e[0];return t.last&&(this.last={x:t.last.x,y:t.last.y},this.current=t.id),this.moved=!1,!0}if(this.last&&this.moved){const e=new i.Point(this.last.x,this.last.y);return this.parent.emit("drag-end",{event:t,screen:e,world:this.parent.toWorld(e),viewport:this.parent}),this.last=null,this.moved=!1,!0}return!1}wheel(t){if(this.paused)return!1;if(this.options.wheel){if(!this.parent.plugins.get("wheel",!0)){const i=t.deltaMode?this.options.lineHeight:1;return this.xDirection&&(this.parent.x+=t.deltaX*i*this.options.wheelScroll*this.reverse),this.yDirection&&(this.parent.y+=t.deltaY*i*this.options.wheelScroll*this.reverse),this.options.clampWheel&&this.clamp(),this.parent.emit("wheel-scroll",this.parent),this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.parent.options.passiveWheel||t.preventDefault(),!0}}return!1}resume(){this.last=null,this.paused=!1}clamp(){const t=this.parent.plugins.get("decelerate",!0)||{};if("y"!==this.options.clampWheel)if(this.parent.screenWorldWidth<this.parent.screenWidth)switch(this.underflowX){case-1:this.parent.x=0;break;case 1:this.parent.x=this.parent.screenWidth-this.parent.screenWorldWidth;break;default:this.parent.x=(this.parent.screenWidth-this.parent.screenWorldWidth)/2}else this.parent.left<0?(this.parent.x=0,t.x=0):this.parent.right>this.parent.worldWidth&&(this.parent.x=-this.parent.worldWidth*this.parent.scale.x+this.parent.screenWidth,t.x=0);if("x"!==this.options.clampWheel)if(this.parent.screenWorldHeight<this.parent.screenHeight)switch(this.underflowY){case-1:this.parent.y=0;break;case 1:this.parent.y=this.parent.screenHeight-this.parent.screenWorldHeight;break;default:this.parent.y=(this.parent.screenHeight-this.parent.screenWorldHeight)/2}else this.parent.top<0&&(this.parent.y=0,t.y=0),this.parent.bottom>this.parent.worldHeight&&(this.parent.y=-this.parent.worldHeight*this.parent.scale.y+this.parent.screenHeight,t.y=0)}}const H={speed:0,acceleration:null,radius:null};class S extends r{constructor(t,i,e={}){super(t),this.target=i,this.options=Object.assign({},H,e),this.velocity={x:0,y:0}}update(t){if(this.paused)return;const i=this.parent.center;let e=this.target.x,s=this.target.y;if(this.options.radius){if(!(Math.sqrt(Math.pow(this.target.y-i.y,2)+Math.pow(this.target.x-i.x,2))>this.options.radius))return;{const t=Math.atan2(this.target.y-i.y,this.target.x-i.x);e=this.target.x-Math.cos(t)*this.options.radius,s=this.target.y-Math.sin(t)*this.options.radius}}const h=e-i.x,n=s-i.y;if(h||n)if(this.options.speed)if(this.options.acceleration){const o=Math.atan2(s-i.y,e-i.x),r=Math.sqrt(Math.pow(h,2)+Math.pow(n,2));if(r){const a=(Math.pow(this.velocity.x,2)+Math.pow(this.velocity.y,2))/(2*this.options.acceleration);this.velocity=r>a?{x:Math.min(this.velocity.x+this.options.acceleration*t,this.options.speed),y:Math.min(this.velocity.y+this.options.acceleration*t,this.options.speed)}:{x:Math.max(this.velocity.x-this.options.acceleration*this.options.speed,0),y:Math.max(this.velocity.y-this.options.acceleration*this.options.speed,0)};const p=Math.cos(o)*this.velocity.x,l=Math.sin(o)*this.velocity.y,c=Math.abs(p)>Math.abs(h)?e:i.x+p,d=Math.abs(l)>Math.abs(n)?s:i.y+l;this.parent.moveCenter(c,d),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}}else{const t=Math.atan2(s-i.y,e-i.x),o=Math.cos(t)*this.options.speed,r=Math.sin(t)*this.options.speed,a=Math.abs(o)>Math.abs(h)?e:i.x+o,p=Math.abs(r)>Math.abs(n)?s:i.y+r;this.parent.moveCenter(a,p),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}else this.parent.moveCenter(e,s),this.parent.emit("moved",{viewport:this.parent,type:"follow"})}}const M={radius:null,distance:null,top:null,bottom:null,left:null,right:null,speed:8,reverse:!1,noDecelerate:!1,linear:!1,allowButtons:!1};class C extends r{constructor(t,i={}){super(t),this.options=Object.assign({},M,i),this.reverse=this.options.reverse?1:-1,this.radiusSquared="number"==typeof this.options.radius?Math.pow(this.options.radius,2):null,this.resize()}resize(){const t=this.options.distance;null!==t?(this.left=t,this.top=t,this.right=this.parent.worldScreenWidth-t,this.bottom=this.parent.worldScreenHeight-t):this.options.radius||(this.left=this.options.left,this.top=this.options.top,this.right=null===this.options.right?null:this.parent.worldScreenWidth-this.options.right,this.bottom=null===this.options.bottom?null:this.parent.worldScreenHeight-this.options.bottom)}down(){return this.paused||this.options.allowButtons||(this.horizontal=this.vertical=null),!1}move(t){if(this.paused)return!1;if("mouse"!==t.data.pointerType&&1!==t.data.identifier||!this.options.allowButtons&&0!==t.data.buttons)return!1;const i=t.data.global.x,e=t.data.global.y;if(this.radiusSquared){const t=this.parent.toScreen(this.parent.center);if(Math.pow(t.x-i,2)+Math.pow(t.y-e,2)>=this.radiusSquared){const s=Math.atan2(t.y-e,t.x-i);this.options.linear?(this.horizontal=Math.round(Math.cos(s))*this.options.speed*this.reverse*.06,this.vertical=Math.round(Math.sin(s))*this.options.speed*this.reverse*.06):(this.horizontal=Math.cos(s)*this.options.speed*this.reverse*.06,this.vertical=Math.sin(s)*this.options.speed*this.reverse*.06)}else this.horizontal&&this.decelerateHorizontal(),this.vertical&&this.decelerateVertical(),this.horizontal=this.vertical=0}else null!==this.left&&i<this.left?this.horizontal=Number(this.reverse)*this.options.speed*.06:null!==this.right&&i>this.right?this.horizontal=-1*this.reverse*this.options.speed*.06:(this.decelerateHorizontal(),this.horizontal=0),null!==this.top&&e<this.top?this.vertical=Number(this.reverse)*this.options.speed*.06:null!==this.bottom&&e>this.bottom?this.vertical=-1*this.reverse*this.options.speed*.06:(this.decelerateVertical(),this.vertical=0);return!1}decelerateHorizontal(){const t=this.parent.plugins.get("decelerate",!0);this.horizontal&&t&&!this.options.noDecelerate&&t.activate({x:this.horizontal*this.options.speed*this.reverse/(1e3/60)})}decelerateVertical(){const t=this.parent.plugins.get("decelerate",!0);this.vertical&&t&&!this.options.noDecelerate&&t.activate({y:this.vertical*this.options.speed*this.reverse/(1e3/60)})}up(){return this.paused||(this.horizontal&&this.decelerateHorizontal(),this.vertical&&this.decelerateVertical(),this.horizontal=this.vertical=null),!1}update(){if(!this.paused&&(this.horizontal||this.vertical)){const t=this.parent.center;this.horizontal&&(t.x+=this.horizontal*this.options.speed),this.vertical&&(t.y+=this.vertical*this.options.speed),this.parent.moveCenter(t),this.parent.emit("moved",{viewport:this.parent,type:"mouse-edges"})}}}const z={noDrag:!1,percent:1,center:null,factor:1,axis:"all"};class _ extends r{__init(){this.active=!1}__init2(){this.pinching=!1}__init3(){this.moved=!1}constructor(t,i={}){super(t),_.prototype.__init.call(this),_.prototype.__init2.call(this),_.prototype.__init3.call(this),this.options=Object.assign({},z,i)}down(){return this.parent.input.count()>=2&&(this.active=!0,!0)}isAxisX(){return["all","x"].includes(this.options.axis)}isAxisY(){return["all","y"].includes(this.options.axis)}move(t){if(this.paused||!this.active)return!1;const i=t.data.global.x,e=t.data.global.y,s=this.parent.input.touches;if(s.length>=2){const h=s[0],n=s[1],o=h.last&&n.last?Math.sqrt(Math.pow(n.last.x-h.last.x,2)+Math.pow(n.last.y-h.last.y,2)):null;if(h.id===t.data.pointerId?h.last={x:i,y:e,data:t.data}:n.id===t.data.pointerId&&(n.last={x:i,y:e,data:t.data}),o){let t;const i={x:h.last.x+(n.last.x-h.last.x)/2,y:h.last.y+(n.last.y-h.last.y)/2};this.options.center||(t=this.parent.toLocal(i));let e=Math.sqrt(Math.pow(n.last.x-h.last.x,2)+Math.pow(n.last.y-h.last.y,2));e=0===e?e=1e-10:e;const s=(1-o/e)*this.options.percent*(this.isAxisX()?this.parent.scale.x:this.parent.scale.y);this.isAxisX()&&(this.parent.scale.x+=s),this.isAxisY()&&(this.parent.scale.y+=s),this.parent.emit("zoomed",{viewport:this.parent,type:"pinch",center:i});const r=this.parent.plugins.get("clamp-zoom",!0);if(r&&r.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const e=this.parent.toGlobal(t);this.parent.x+=(i.x-e.x)*this.options.factor,this.parent.y+=(i.y-e.y)*this.options.factor,this.parent.emit("moved",{viewport:this.parent,type:"pinch"})}!this.options.noDrag&&this.lastCenter&&(this.parent.x+=(i.x-this.lastCenter.x)*this.options.factor,this.parent.y+=(i.y-this.lastCenter.y)*this.options.factor,this.parent.emit("moved",{viewport:this.parent,type:"pinch"})),this.lastCenter=i,this.moved=!0}else this.pinching||(this.parent.emit("pinch-start",this.parent),this.pinching=!0);return!0}return!1}up(){return!!(this.pinching&&this.parent.input.touches.length<=1)&&(this.active=!1,this.lastCenter=null,this.pinching=!1,this.moved=!1,this.parent.emit("pinch-end",this.parent),!0)}}const X={topLeft:!1,friction:.8,time:1e3,ease:"easeInOutSine",interrupt:!0,removeOnComplete:!1,removeOnInterrupt:!1,forceStart:!1};class k extends r{constructor(t,i,e,s={}){super(t),this.options=Object.assign({},X,s),this.ease=a(s.ease,"easeInOutSine"),this.x=i,this.y=e,this.options.forceStart&&this.snapStart()}snapStart(){this.percent=0,this.snapping={time:0};const t=this.options.topLeft?this.parent.corner:this.parent.center;this.deltaX=this.x-t.x,this.deltaY=this.y-t.y,this.startX=t.x,this.startY=t.y,this.parent.emit("snap-start",this.parent)}wheel(){return this.options.removeOnInterrupt&&this.parent.plugins.remove("snap"),!1}down(){return this.options.removeOnInterrupt?this.parent.plugins.remove("snap"):this.options.interrupt&&(this.snapping=null),!1}up(){if(0===this.parent.input.count()){const t=this.parent.plugins.get("decelerate",!0);t&&(t.x||t.y)&&(t.percentChangeX=t.percentChangeY=this.options.friction)}return!1}update(t){if(!(this.paused||this.options.interrupt&&0!==this.parent.input.count()))if(this.snapping){const i=this.snapping;let e,s,h;i.time+=t;const n=this.startX,o=this.startY,r=this.deltaX,a=this.deltaY;if(i.time>this.options.time)e=!0,s=n+r,h=o+a;else{const t=this.ease(i.time,0,1,this.options.time);s=n+r*t,h=o+a*t}this.options.topLeft?this.parent.moveCorner(s,h):this.parent.moveCenter(s,h),this.parent.emit("moved",{viewport:this.parent,type:"snap"}),e&&(this.options.removeOnComplete&&this.parent.plugins.remove("snap"),this.parent.emit("snap-end",this.parent),this.snapping=null)}else{const t=this.options.topLeft?this.parent.corner:this.parent.center;t.x===this.x&&t.y===this.y||this.snapStart()}}}const P={width:0,height:0,time:1e3,ease:"easeInOutSine",center:null,interrupt:!0,removeOnComplete:!1,removeOnInterrupt:!1,forceStart:!1,noMove:!1};class O extends r{constructor(t,i={}){super(t),this.options=Object.assign({},P,i),this.ease=a(this.options.ease),this.xIndependent=!1,this.yIndependent=!1,this.xScale=0,this.yScale=0,this.options.width>0&&(this.xScale=t.screenWidth/this.options.width,this.xIndependent=!0),this.options.height>0&&(this.yScale=t.screenHeight/this.options.height,this.yIndependent=!0),this.xScale=this.xIndependent?this.xScale:this.yScale,this.yScale=this.yIndependent?this.yScale:this.xScale,0===this.options.time?(t.container.scale.x=this.xScale,t.container.scale.y=this.yScale,this.options.removeOnComplete&&this.parent.plugins.remove("snap-zoom")):i.forceStart&&this.createSnapping()}createSnapping(){const t=this.parent.worldScreenWidth,i=this.parent.worldScreenHeight,e=this.parent.screenWidth/this.xScale,s=this.parent.screenHeight/this.yScale;this.snapping={time:0,startX:t,startY:i,deltaX:e-t,deltaY:s-i},this.parent.emit("snap-zoom-start",this.parent)}resize(){this.snapping=null,this.options.width>0&&(this.xScale=this.parent.screenWidth/this.options.width),this.options.height>0&&(this.yScale=this.parent.screenHeight/this.options.height),this.xScale=this.xIndependent?this.xScale:this.yScale,this.yScale=this.yIndependent?this.yScale:this.xScale}wheel(){return this.options.removeOnInterrupt&&this.parent.plugins.remove("snap-zoom"),!1}down(){return this.options.removeOnInterrupt?this.parent.plugins.remove("snap-zoom"):this.options.interrupt&&(this.snapping=null),!1}update(t){if(this.paused)return;if(this.options.interrupt&&0!==this.parent.input.count())return;let i;if(this.options.center||this.options.noMove||(i=this.parent.center),this.snapping){if(this.snapping){const e=this.snapping;if(e.time+=t,e.time>=this.options.time)this.parent.scale.set(this.xScale,this.yScale),this.options.removeOnComplete&&this.parent.plugins.remove("snap-zoom"),this.parent.emit("snap-zoom-end",this.parent),this.snapping=null;else{const t=this.snapping,i=this.ease(t.time,t.startX,t.deltaX,this.options.time),e=this.ease(t.time,t.startY,t.deltaY,this.options.time);this.parent.scale.x=this.parent.screenWidth/i,this.parent.scale.y=this.parent.screenHeight/e}const s=this.parent.plugins.get("clamp-zoom",!0);s&&s.clamp(),this.options.noMove||(this.options.center?this.parent.moveCenter(this.options.center):this.parent.moveCenter(i))}}else this.parent.scale.x===this.xScale&&this.parent.scale.y===this.yScale||this.createSnapping()}resume(){this.snapping=null,super.resume()}}const Y={percent:.1,smooth:!1,interrupt:!0,reverse:!1,center:null,lineHeight:20,axis:"all"};class A extends r{constructor(t,i={}){super(t),this.options=Object.assign({},Y,i)}down(){return this.options.interrupt&&(this.smoothing=null),!1}isAxisX(){return["all","x"].includes(this.options.axis)}isAxisY(){return["all","y"].includes(this.options.axis)}update(){if(this.smoothing){const t=this.smoothingCenter,i=this.smoothing;let e;this.options.center||(e=this.parent.toLocal(t)),this.isAxisX()&&(this.parent.scale.x+=i.x),this.isAxisY()&&(this.parent.scale.y+=i.y),this.parent.emit("zoomed",{viewport:this.parent,type:"wheel"});const s=this.parent.plugins.get("clamp-zoom",!0);if(s&&s.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const i=this.parent.toGlobal(e);this.parent.x+=t.x-i.x,this.parent.y+=t.y-i.y}this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.smoothingCount++,this.smoothingCount>=this.options.smooth&&(this.smoothing=null)}}wheel(t){if(this.paused)return;const i=this.parent.input.getPointerPosition(t),e=(this.options.reverse?-1:1)*-t.deltaY*(t.deltaMode?this.options.lineHeight:1)/500,s=Math.pow(2,(1+this.options.percent)*e);if(this.options.smooth){const t={x:this.smoothing?this.smoothing.x*(this.options.smooth-this.smoothingCount):0,y:this.smoothing?this.smoothing.y*(this.options.smooth-this.smoothingCount):0};this.smoothing={x:((this.parent.scale.x+t.x)*s-this.parent.scale.x)/this.options.smooth,y:((this.parent.scale.y+t.y)*s-this.parent.scale.y)/this.options.smooth},this.smoothingCount=0,this.smoothingCenter=i}else{let t;this.options.center||(t=this.parent.toLocal(i)),this.isAxisX()&&(this.parent.scale.x*=s),this.isAxisY()&&(this.parent.scale.y*=s),this.parent.emit("zoomed",{viewport:this.parent,type:"wheel"});const e=this.parent.plugins.get("clamp-zoom",!0);if(e&&e.clamp(),this.options.center)this.parent.moveCenter(this.options.center);else{const e=this.parent.toGlobal(t);this.parent.x+=i.x-e.x,this.parent.y+=i.y-e.y}}return this.parent.emit("moved",{viewport:this.parent,type:"wheel"}),this.parent.emit("wheel",{wheel:{dx:t.deltaX,dy:t.deltaY,dz:t.deltaZ},event:t,viewport:this.parent}),!this.parent.options.passiveWheel||void 0}}class I{constructor(t){this.viewport=t,this.touches=[],this.addListeners()}addListeners(){this.viewport.interactive=!0,this.viewport.forceHitArea||(this.viewport.hitArea=new i.Rectangle(0,0,this.viewport.worldWidth,this.viewport.worldHeight)),this.viewport.on("pointerdown",this.down,this),this.viewport.on("pointermove",this.move,this),this.viewport.on("pointerup",this.up,this),this.viewport.on("pointerupoutside",this.up,this),this.viewport.on("pointercancel",this.up,this),this.viewport.on("pointerout",this.up,this),this.wheelFunction=t=>this.handleWheel(t),this.viewport.options.divWheel.addEventListener("wheel",this.wheelFunction,{passive:this.viewport.options.passiveWheel}),this.isMouseDown=!1}destroy(){this.viewport.options.divWheel.removeEventListener("wheel",this.wheelFunction)}down(t){if(this.viewport.pause||!this.viewport.worldVisible)return;if("mouse"===t.data.pointerType?this.isMouseDown=!0:this.get(t.data.pointerId)||this.touches.push({id:t.data.pointerId,last:null}),1===this.count()){this.last=t.data.global.clone();const i=this.viewport.plugins.get("decelerate",!0),e=this.viewport.plugins.get("bounce",!0);i&&i.isActive()||e&&e.isActive()?this.clickedAvailable=!1:this.clickedAvailable=!0}else this.clickedAvailable=!1;this.viewport.plugins.down(t)&&this.viewport.options.stopPropagation&&t.stopPropagation()}clear(){this.isMouseDown=!1,this.touches=[],this.last=null}checkThreshold(t){return Math.abs(t)>=this.viewport.threshold}move(t){if(this.viewport.pause||!this.viewport.worldVisible)return;const i=this.viewport.plugins.move(t);if(this.clickedAvailable&&this.last){const i=t.data.global.x-this.last.x,e=t.data.global.y-this.last.y;(this.checkThreshold(i)||this.checkThreshold(e))&&(this.clickedAvailable=!1)}i&&this.viewport.options.stopPropagation&&t.stopPropagation()}up(t){if(this.viewport.pause||!this.viewport.worldVisible)return;"mouse"===t.data.pointerType&&(this.isMouseDown=!1),"mouse"!==t.data.pointerType&&this.remove(t.data.pointerId);const i=this.viewport.plugins.up(t);this.clickedAvailable&&0===this.count()&&this.last&&(this.viewport.emit("clicked",{event:t,screen:this.last,world:this.viewport.toWorld(this.last),viewport:this}),this.clickedAvailable=!1),i&&this.viewport.options.stopPropagation&&t.stopPropagation()}getPointerPosition(t){const e=new i.Point;return this.viewport.options.interaction?this.viewport.options.interaction.mapPositionToPoint(e,t.clientX,t.clientY):(e.x=t.clientX,e.y=t.clientY),e}handleWheel(t){if(this.viewport.pause||!this.viewport.worldVisible)return;if(this.viewport.options.interaction&&this.viewport.options.interaction.interactionDOMElement!==t.target)return;const i=this.viewport.toLocal(this.getPointerPosition(t));if(this.viewport.left<=i.x&&i.x<=this.viewport.right&&this.viewport.top<=i.y&&i.y<=this.viewport.bottom){this.viewport.plugins.wheel(t)&&!this.viewport.options.passiveWheel&&t.preventDefault()}}pause(){this.touches=[],this.isMouseDown=!1}get(t){for(const i of this.touches)if(i.id===t)return i;return null}remove(t){for(let i=0;i<this.touches.length;i++)if(this.touches[i].id===t)return void this.touches.splice(i,1)}count(){return(this.isMouseDown?1:0)+this.touches.length}}function D(t){let i=void 0,e=t[0],s=1;for(;s<t.length;){const h=t[s],n=t[s+1];if(s+=2,("optionalAccess"===h||"optionalCall"===h)&&null==e)return;"access"===h||"optionalAccess"===h?(i=e,e=n(e)):"call"!==h&&"optionalCall"!==h||(e=n(((...t)=>e.call(i,...t))),i=void 0)}return e}const T=["drag","pinch","wheel","follow","mouse-edges","decelerate","aniamte","bounce","snap-zoom","clamp-zoom","snap","clamp"];class V{constructor(t){this.viewport=t,this.list=[],this.plugins={}}add(t,i,e=T.length){this.plugins[t]=i;const s=T.indexOf(t);-1!==s&&T.splice(s,1),T.splice(e,0,t),this.sort()}get(t,i){return i&&D([this,"access",t=>t.plugins,"access",i=>i[t],"optionalAccess",t=>t.paused])?null:this.plugins[t]}update(t){for(const i of this.list)i.update(t)}resize(){for(const t of this.list)t.resize()}reset(){for(const t of this.list)t.reset()}removeAll(){this.plugins={},this.sort()}remove(t){this.plugins[t]&&(delete this.plugins[t],this.viewport.emit(t+"-remove"),this.sort())}pause(t){D([this,"access",t=>t.plugins,"access",i=>i[t],"optionalAccess",t=>t.pause,"call",t=>t()])}resume(t){D([this,"access",t=>t.plugins,"access",i=>i[t],"optionalAccess",t=>t.resume,"call",t=>t()])}sort(){this.list=[];for(const t of T)this.plugins[t]&&this.list.push(this.plugins[t])}down(t){let i=!1;for(const e of this.list)e.down(t)&&(i=!0);return i}move(t){let i=!1;for(const e of this.viewport.plugins.list)e.move(t)&&(i=!0);return i}up(t){let i=!1;for(const e of this.list)e.up(t)&&(i=!0);return i}wheel(t){let i=!1;for(const e of this.list)e.wheel(t)&&(i=!0);return i}}const L={screenWidth:window.innerWidth,screenHeight:window.innerHeight,worldWidth:null,worldHeight:null,threshold:5,passiveWheel:!0,stopPropagation:!1,forceHitArea:null,noTicker:!1,interaction:null,disableOnContextMenu:!1,ticker:h.Ticker.shared};class j extends s.Container{constructor(t={}){super(),this.options=Object.assign({},{divWheel:document.body},L,t),this.screenWidth=this.options.screenWidth,this.screenHeight=this.options.screenHeight,this._worldWidth=this.options.worldWidth,this._worldHeight=this.options.worldHeight,this.forceHitArea=this.options.forceHitArea,this.threshold=this.options.threshold,this.options.divWheel=this.options.divWheel||document.body,this.options.disableOnContextMenu&&(this.options.divWheel.oncontextmenu=t=>t.preventDefault()),this.options.noTicker||(this.tickerFunction=()=>this.update(this.options.ticker.elapsedMS),this.options.ticker.add(this.tickerFunction)),this.input=new I(this),this.plugins=new V(this)}destroy(t){!this.options.noTicker&&this.tickerFunction&&this.options.ticker.remove(this.tickerFunction),this.input.destroy(),super.destroy(t)}update(t){this.pause||(this.plugins.update(t),this.lastViewport&&(this.lastViewport.x!==this.x||this.lastViewport.y!==this.y?this.moving=!0:this.moving&&(this.emit("moved-end",this),this.moving=!1),this.lastViewport.scaleX!==this.scale.x||this.lastViewport.scaleY!==this.scale.y?this.zooming=!0:this.zooming&&(this.emit("zoomed-end",this),this.zooming=!1)),this.forceHitArea||(this._hitAreaDefault=new i.Rectangle(this.left,this.top,this.worldScreenWidth,this.worldScreenHeight),this.hitArea=this._hitAreaDefault),this._dirty=this._dirty||!this.lastViewport||this.lastViewport.x!==this.x||this.lastViewport.y!==this.y||this.lastViewport.scaleX!==this.scale.x||this.lastViewport.scaleY!==this.scale.y,this.lastViewport={x:this.x,y:this.y,scaleX:this.scale.x,scaleY:this.scale.y},this.emit("frame-end",this))}resize(t=window.innerWidth,i=window.innerHeight,e,s){this.screenWidth=t,this.screenHeight=i,void 0!==e&&(this._worldWidth=e),void 0!==s&&(this._worldHeight=s),this.plugins.resize(),this.dirty=!0}get worldWidth(){return this._worldWidth?this._worldWidth:this.width/this.scale.x}set worldWidth(t){this._worldWidth=t,this.plugins.resize()}get worldHeight(){return this._worldHeight?this._worldHeight:this.height/this.scale.y}set worldHeight(t){this._worldHeight=t,this.plugins.resize()}getVisibleBounds(){return new i.Rectangle(this.left,this.top,this.worldScreenWidth,this.worldScreenHeight)}toWorld(t,e){return 2===arguments.length?this.toLocal(new i.Point(t,e)):this.toLocal(t)}toScreen(t,e){return 2===arguments.length?this.toGlobal(new i.Point(t,e)):this.toGlobal(t)}get worldScreenWidth(){return this.screenWidth/this.scale.x}get worldScreenHeight(){return this.screenHeight/this.scale.y}get screenWorldWidth(){return this.worldWidth*this.scale.x}get screenWorldHeight(){return this.worldHeight*this.scale.y}get center(){return new i.Point(this.worldScreenWidth/2-this.x/this.scale.x,this.worldScreenHeight/2-this.y/this.scale.y)}set center(t){this.moveCenter(t)}moveCenter(...t){let i,e;"number"==typeof t[0]?(i=t[0],e=t[1]):(i=t[0].x,e=t[0].y);const s=(this.worldScreenWidth/2-i)*this.scale.x,h=(this.worldScreenHeight/2-e)*this.scale.y;return this.x===s&&this.y===h||(this.position.set(s,h),this.plugins.reset(),this.dirty=!0),this}get corner(){return new i.Point(-this.x/this.scale.x,-this.y/this.scale.y)}set corner(t){this.moveCorner(t)}moveCorner(...t){let i,e;return 1===t.length?(i=-t[0].x*this.scale.x,e=-t[0].y*this.scale.y):(i=-t[0]*this.scale.x,e=-t[1]*this.scale.y),i===this.x&&e===this.y||(this.position.set(i,e),this.plugins.reset(),this.dirty=!0),this}get screenWidthInWorldPixels(){return this.screenWidth/this.scale.x}get screenHeightInWorldPixels(){return this.screenHeight/this.scale.y}findFitWidth(t){return this.screenWidth/t}findFitHeight(t){return this.screenHeight/t}findFit(t,i){const e=this.screenWidth/t,s=this.screenHeight/i;return Math.min(e,s)}findCover(t,i){const e=this.screenWidth/t,s=this.screenHeight/i;return Math.max(e,s)}fitWidth(t=this.worldWidth,i,e=!0,s){let h;i&&(h=this.center),this.scale.x=this.screenWidth/t,e&&(this.scale.y=this.scale.x);const n=this.plugins.get("clamp-zoom",!0);return!s&&n&&n.clamp(),i&&h&&this.moveCenter(h),this}fitHeight(t=this.worldHeight,i,e=!0,s){let h;i&&(h=this.center),this.scale.y=this.screenHeight/t,e&&(this.scale.x=this.scale.y);const n=this.plugins.get("clamp-zoom",!0);return!s&&n&&n.clamp(),i&&h&&this.moveCenter(h),this}fitWorld(t){let i;t&&(i=this.center),this.scale.x=this.screenWidth/this.worldWidth,this.scale.y=this.screenHeight/this.worldHeight,this.scale.x<this.scale.y?this.scale.y=this.scale.x:this.scale.x=this.scale.y;const e=this.plugins.get("clamp-zoom",!0);return e&&e.clamp(),t&&i&&this.moveCenter(i),this}fit(t,i=this.worldWidth,e=this.worldHeight){let s;t&&(s=this.center),this.scale.x=this.screenWidth/i,this.scale.y=this.screenHeight/e,this.scale.x<this.scale.y?this.scale.y=this.scale.x:this.scale.x=this.scale.y;const h=this.plugins.get("clamp-zoom",!0);return h&&h.clamp(),t&&s&&this.moveCenter(s),this}set visible(t){t||this.input.clear(),super.visible=t}setZoom(t,i){let e;i&&(e=this.center),this.scale.set(t);const s=this.plugins.get("clamp-zoom",!0);return s&&s.clamp(),i&&e&&this.moveCenter(e),this}zoomPercent(t,i){return this.setZoom(this.scale.x+this.scale.x*t,i)}zoom(t,i){return this.fitWidth(t+this.worldScreenWidth,i),this}get scaled(){return this.scale.x}set scaled(t){this.setZoom(t,!0)}snapZoom(t){return this.plugins.add("snap-zoom",new O(this,t)),this}OOB(){return{left:this.left<0,right:this.right>this.worldWidth,top:this.top<0,bottom:this.bottom>this.worldHeight,cornerPoint:new i.Point(this.worldWidth*this.scale.x-this.screenWidth,this.worldHeight*this.scale.y-this.screenHeight)}}get right(){return-this.x/this.scale.x+this.worldScreenWidth}set right(t){this.x=-t*this.scale.x+this.screenWidth,this.plugins.reset()}get left(){return-this.x/this.scale.x}set left(t){this.x=-t*this.scale.x,this.plugins.reset()}get top(){return-this.y/this.scale.y}set top(t){this.y=-t*this.scale.y,this.plugins.reset()}get bottom(){return-this.y/this.scale.y+this.worldScreenHeight}set bottom(t){this.y=-t*this.scale.y+this.screenHeight,this.plugins.reset()}get dirty(){return!!this._dirty}set dirty(t){this._dirty=t}get forceHitArea(){return this._forceHitArea}set forceHitArea(t){t?(this._forceHitArea=t,this.hitArea=t):(this._forceHitArea=null,this.hitArea=new i.Rectangle(0,0,this.worldWidth,this.worldHeight))}drag(t){return this.plugins.add("drag",new b(this,t)),this}clamp(t){return this.plugins.add("clamp",new m(this,t)),this}decelerate(t){return this.plugins.add("decelerate",new v(this,t)),this}bounce(t){return this.plugins.add("bounce",new u(this,t)),this}pinch(t){return this.plugins.add("pinch",new _(this,t)),this}snap(t,i,e){return this.plugins.add("snap",new k(this,t,i,e)),this}follow(t,i){return this.plugins.add("follow",new S(this,t,i)),this}wheel(t){return this.plugins.add("wheel",new A(this,t)),this}animate(t){return this.plugins.add("animate",new l(this,t)),this}clampZoom(t){return this.plugins.add("clamp-zoom",new y(this,t)),this}mouseEdges(t){return this.plugins.add("mouse-edges",new C(this,t)),this}get pause(){return!!this._pause}set pause(t){this._pause=t,this.lastViewport=null,this.moving=!1,this.zooming=!1,t&&this.input.pause()}ensureVisible(t,i,e,s,h){h&&(e>this.worldScreenWidth||s>this.worldScreenHeight)&&(this.fit(!0,e,s),this.emit("zoomed",{viewport:this,type:"ensureVisible"}));let n=!1;t<this.left?(this.left=t,n=!0):t+e>this.right&&(this.right=t+e,n=!0),i<this.top?(this.top=i,n=!0):i+s>this.bottom&&(this.bottom=i+s,n=!0),n&&this.emit("moved",{viewport:this,type:"ensureVisible"})}}t.Animate=l,t.Bounce=u,t.Clamp=m,t.ClampZoom=y,t.Decelerate=v,t.Drag=b,t.Follow=S,t.InputManager=I,t.MouseEdges=C,t.Pinch=_,t.Plugin=r,t.PluginManager=V,t.Snap=k,t.SnapZoom=O,t.Viewport=j,t.Wheel=A,Object.defineProperty(t,"__esModule",{value:!0})})),"undefined"!=typeof pixi_viewport&&Object.assign(this.PIXI,pixi_viewport);
//# sourceMappingURL=viewport.min.min.js.map

@@ -189,4 +189,4 @@ import { Container } from '@pixi/display';

maxHeight?: number | null;
minScale?: number | null;
maxScale?: number | null;
minScale?: number | null | IScale;
maxScale?: number | null | IScale;
}

@@ -285,2 +285,7 @@

export declare interface IScale {
x: null | number;
y: null | number;
}
export declare interface ISnapOptions {

@@ -514,8 +519,8 @@ topLeft?: boolean;

set center(value: Point);
moveCenter(x: number, y: number): this;
moveCenter(center: Point): this;
moveCenter(x: number, y: number): Viewport;
moveCenter(center: Point): Viewport;
get corner(): Point;
set corner(value: Point);
moveCorner(x: number, y: number): this;
moveCorner(center: Point): this;
moveCorner(x: number, y: number): Viewport;
moveCorner(center: Point): Viewport;
get screenWidthInWorldPixels(): number;

@@ -527,13 +532,13 @@ get screenHeightInWorldPixels(): number;

findCover(width: number, height: number): number;
fitWidth(width?: number, center?: boolean, scaleY?: boolean, noClamp?: boolean): this;
fitHeight(height?: number, center?: boolean, scaleX?: boolean, noClamp?: boolean): this;
fitWorld(center?: boolean): this;
fit(center?: boolean, width?: number, height?: number): this;
fitWidth(width?: number, center?: boolean, scaleY?: boolean, noClamp?: boolean): Viewport;
fitHeight(height?: number, center?: boolean, scaleX?: boolean, noClamp?: boolean): Viewport;
fitWorld(center?: boolean): Viewport;
fit(center?: boolean, width?: number, height?: number): Viewport;
set visible(value: boolean);
setZoom(scale: number, center?: boolean): this;
zoomPercent(percent: number, center?: boolean): this;
zoom(change: number, center?: boolean): this;
setZoom(scale: number, center?: boolean): Viewport;
zoomPercent(percent: number, center?: boolean): Viewport;
zoom(change: number, center?: boolean): Viewport;
get scaled(): number;
set scaled(scale: number);
snapZoom(options: any): this;
snapZoom(options: ISnapZoomOptions): Viewport;
OOB(): {

@@ -558,13 +563,13 @@ left: boolean;

set forceHitArea(value: IHitArea | null | undefined);
drag(options: any): this;
clamp(options: any): this;
decelerate(options: any): this;
bounce(options: any): this;
pinch(options: any): this;
snap(x: number, y: number, options: any): this;
follow(target: DisplayObject, options: any): this;
wheel(options: any): this;
animate(options: any): this;
clampZoom(options: any): this;
mouseEdges(options: any): this;
drag(options: IDragOptions): Viewport;
clamp(options: IClampOptions): Viewport;
decelerate(options: IDecelerateOptions): Viewport;
bounce(options: IBounceOptions): Viewport;
pinch(options: IPinchOptions): Viewport;
snap(x: number, y: number, options: ISnapOptions): Viewport;
follow(target: DisplayObject, options: IFollowOptions): Viewport;
wheel(options: IWheelOptions): Viewport;
animate(options: IAnimateOptions): Viewport;
clampZoom(options: IClampZoomOptions): Viewport;
mouseEdges(options: IMouseEdgesOptions): Viewport;
get pause(): boolean;

@@ -571,0 +576,0 @@ set pause(value: boolean);

{
"name": "pixi-viewport",
"version": "4.30.0",
"version": "4.30.1",
"description": "A highly configurable viewport/2D camera designed to work with pixi.js. Features include dragging, pinch-to-zoom, mouse wheel zooming, decelerated dragging, follow target, snap to point, snap to zoom, clamping, bouncing on edges, and move on mouse edges.",

@@ -29,3 +29,3 @@ "main": "dist/cjs/viewport.js",

"builds-browserify": "browserify docs/builds/browserify/code.js -o docs/builds/browserify/index.js",
"builds-standalone": "cp dist/viewport.* docs/",
"builds-standalone": "node scripts/copy",
"builds-typescript": "rollup -c docs/builds/ts/rollup.config.js",

@@ -90,2 +90,3 @@ "builds-original": "rollup -c docs/original/rollup.config.js",

"fork-me-github": "^1.2.0",
"fs-extra": "^9.1.0",
"jsdoc": "^3.6.3",

@@ -108,2 +109,2 @@ "pixi-ease": "^3.0.7",

}
}
}

@@ -25,6 +25,6 @@ import { Plugin } from './Plugin';

/** Minimum scale */
minScale?: number | null;
minScale?: number | null | IScale;
/** Maximum scale */
maxScale?: number | null;
maxScale?: number | null | IScale;
}

@@ -66,3 +66,3 @@

/** Clamp the viewport's zoom immediately. */
/** Clamp the viewport scale zoom) */
public clamp(): void

@@ -120,16 +120,55 @@ {

else
if (this.options.minScale || this.options.maxScale)
{
let scale = this.parent.scale.x;
const minScale: IScale = { x: null, y: null };
const maxScale: IScale = { x: null, y: null };
if (this.options.minScale !== null && scale < this.options.minScale)
if (typeof this.options.minScale === 'number')
{
scale = this.options.minScale;
minScale.x = this.options.minScale;
minScale.y = this.options.minScale;
}
if (this.options.maxScale !== null && scale > this.options.maxScale)
else if (this.options.minScale !== null)
{
scale = this.options.maxScale;
const optsMinScale = this.options.minScale as IScale;
minScale.x = typeof optsMinScale.x === 'undefined' ? null : optsMinScale.x;
minScale.y = typeof optsMinScale.y === 'undefined' ? null : optsMinScale.y;
}
if (scale !== this.parent.scale.x)
if (typeof this.options.maxScale === 'number')
{
this.parent.scale.set(scale);
maxScale.x = this.options.maxScale;
maxScale.y = this.options.maxScale;
}
else if (this.options.maxScale !== null)
{
const optsMaxScale = this.options.maxScale as IScale;
maxScale.x = typeof optsMaxScale.x === 'undefined' ? null : optsMaxScale.x;
maxScale.y = typeof optsMaxScale.y === 'undefined' ? null : optsMaxScale.y;
}
let scaleX = this.parent.scale.x;
let scaleY = this.parent.scale.y;
if (minScale.x !== null && scaleX < minScale.x)
{
scaleX = minScale.x;
}
if (maxScale.x !== null && scaleX > maxScale.x)
{
scaleX = maxScale.x;
}
if (minScale.y !== null && scaleY < minScale.y)
{
scaleY = minScale.y;
}
if (maxScale.y !== null && scaleY > maxScale.y)
{
scaleY = maxScale.y;
}
if (scaleX !== this.parent.scale.x || scaleY !== this.parent.scale.y)
{
this.parent.scale.set(scaleX, scaleY);
this.parent.emit('zoomed', { viewport: this.parent, type: 'clamp-zoom' });

@@ -145,1 +184,7 @@ }

}
/** This allows independent x and y values for min/maxScale */
export interface IScale {
x: null | number
y: null | number
}

@@ -8,14 +8,14 @@ import { Container } from '@pixi/display';

import {
Animate,
Bounce,
Clamp,
ClampZoom,
Decelerate,
Drag,
Follow,
MouseEdges,
Pinch,
Snap,
SnapZoom,
Wheel
Animate, IAnimateOptions,
Bounce, IBounceOptions,
Clamp, IClampOptions,
ClampZoom, IClampZoomOptions,
Decelerate, IDecelerateOptions,
Drag, IDragOptions,
Follow, IFollowOptions,
MouseEdges, IMouseEdgesOptions,
Pinch, IPinchOptions,
Snap, ISnapOptions,
SnapZoom, ISnapZoomOptions,
Wheel, IWheelOptions,
} from './plugins';

@@ -48,3 +48,4 @@

/**
* Whether the 'wheel' event is set to passive (note: if false, e.preventDefault() will be called when wheel is used over the viewport)
* Whether the 'wheel' event is set to passive (note: if false, e.preventDefault() will be called when wheel
* is used over the viewport)
*

@@ -236,3 +237,3 @@ * @default true

/** Overrides PIXI.Container's destroy to also remove the 'wheel' and PIXI.Ticker listeners */
destroy(options: IDestroyOptions)
destroy(options: IDestroyOptions): void
{

@@ -279,3 +280,3 @@ if (!this.options.noTicker && this.tickerFunction)

}
else if (this.zooming)
else if (this.zooming)
{

@@ -341,3 +342,3 @@ this.emit('zoomed-end', this);

}
set worldWidth(value)
set worldWidth(value: number)
{

@@ -358,3 +359,3 @@ this._worldWidth = value;

}
set worldHeight(value)
set worldHeight(value: number)
{

@@ -420,3 +421,3 @@ this._worldHeight = value;

/** World height in screen coordinates */
get screenWorldHeight()
get screenWorldHeight(): number
{

@@ -430,4 +431,4 @@ return this.worldHeight * this.scale.y;

return new Point(
this.worldScreenWidth / 2 - this.x / this.scale.x,
this.worldScreenHeight / 2 - this.y / this.scale.y,
(this.worldScreenWidth / 2) - (this.x / this.scale.x),
(this.worldScreenHeight / 2) - (this.y / this.scale.y),
);

@@ -441,8 +442,8 @@ }

/** Move center of viewport to (x, y) */
public moveCenter(x: number, y: number): this;
public moveCenter(x: number, y: number): Viewport;
/** Move center of viewport to {@code center}. */
public moveCenter(center: Point): this;
public moveCenter(center: Point): Viewport;
public moveCenter(...args: [number, number] | [Point]): this
public moveCenter(...args: [number, number] | [Point]): Viewport
{

@@ -463,4 +464,4 @@ let x: number;

const newX = (this.worldScreenWidth / 2 - x) * this.scale.x;
const newY = (this.worldScreenHeight / 2 - y) * this.scale.y;
const newX = ((this.worldScreenWidth / 2) - x) * this.scale.x;
const newY = ((this.worldScreenHeight / 2) - y) * this.scale.y;

@@ -487,9 +488,9 @@ if (this.x !== newX || this.y !== newY)

/** Move viewport's top-left corner; also clamps and resets decelerate and bounce (as needed) */
public moveCorner(x: number, y: number): this;
/** Move Viewport's top-left corner; also clamps and resets decelerate and bounce (as needed) */
public moveCorner(x: number, y: number): Viewport;
/** move viewport's top-left corner; also clamps and resets decelerate and bounce (as needed) */
public moveCorner(center: Point): this;
/** move Viewport's top-left corner; also clamps and resets decelerate and bounce (as needed) */
public moveCorner(center: Point): Viewport;
public moveCorner(...args: [number, number] | [Point])
public moveCorner(...args: [number, number] | [Point]): Viewport
{

@@ -521,3 +522,3 @@ let x;

/** Get how many world pixels fit in screen's width */
get screenWidthInWorldPixels()
get screenWidthInWorldPixels(): number
{

@@ -528,3 +529,3 @@ return this.screenWidth / this.scale.x;

/** Get how many world pixels fit on screen's height */
get screenHeightInWorldPixels()
get screenHeightInWorldPixels(): number
{

@@ -599,3 +600,3 @@ return this.screenHeight / this.scale.y;

*/
fitWidth(width = this.worldWidth, center?: boolean, scaleY = true, noClamp?: boolean): this
fitWidth(width = this.worldWidth, center?: boolean, scaleY = true, noClamp?: boolean): Viewport
{

@@ -639,3 +640,3 @@ let save: Point | undefined;

*/
fitHeight(height = this.worldHeight, center?: boolean, scaleX = true, noClamp?: boolean)
fitHeight(height = this.worldHeight, center?: boolean, scaleX = true, noClamp?: boolean): Viewport
{

@@ -676,3 +677,3 @@ let save: Point | undefined;

*/
fitWorld(center?: boolean): this
fitWorld(center?: boolean): Viewport
{

@@ -721,3 +722,3 @@ let save: Point | undefined;

*/
fit(center?: boolean, width = this.worldWidth, height = this.worldHeight): this
fit(center?: boolean, width = this.worldWidth, height = this.worldHeight): Viewport
{

@@ -775,3 +776,3 @@ let save: Point | undefined;

*/
setZoom(scale: number, center?: boolean): this
setZoom(scale: number, center?: boolean): Viewport
{

@@ -806,5 +807,5 @@ let save;

*/
zoomPercent(percent: number, center?: boolean): this
zoomPercent(percent: number, center?: boolean): Viewport
{
return this.setZoom(this.scale.x + this.scale.x * percent, center);
return this.setZoom(this.scale.x + (this.scale.x * percent), center);
}

@@ -819,3 +820,3 @@

*/
zoom(change: number, center?: boolean)
zoom(change: number, center?: boolean): Viewport
{

@@ -838,5 +839,19 @@ this.fitWidth(change + this.worldScreenWidth, center);

/**
* @param {SnapZoomOptions} options
* Returns zoom to the desired scale
*
* @param {ISnapZoomOptions} options
* @param {number} [options.width=0] - the desired width to snap (to maintain aspect ratio, choose width or height)
* @param {number} [options.height=0] - the desired height to snap (to maintain aspect ratio, choose width or height)
* @param {number} [options.time=1000] - time for snapping in ms
* @param {(string|function)} [options.ease=easeInOutSine] ease function or name (see http://easings.net/
* for supported names)
* @param {PIXI.Point} [options.center] - place this point at center during zoom instead of center of the viewport
* @param {boolean} [options.interrupt=true] - pause snapping with any user input on the viewport
* @param {boolean} [options.removeOnComplete] - removes this plugin after snapping is complete
* @param {boolean} [options.removeOnInterrupt] - removes this plugin if interrupted by any user input
* @param {boolean} [options.forceStart] - starts the snap immediately regardless of whether the viewport is at the
* desired zoom
* @param {boolean} [options.noMove] - zoom but do not move
*/
snapZoom(options: any): this
snapZoom(options: ISnapZoomOptions): Viewport
{

@@ -855,3 +870,3 @@ this.plugins.add('snap-zoom', new SnapZoom(this, options));

cornerPoint: Point;
}
}
{

@@ -864,4 +879,4 @@ return {

cornerPoint: new Point(
this.worldWidth * this.scale.x - this.screenWidth,
this.worldHeight * this.scale.y - this.screenHeight
(this.worldWidth * this.scale.x) - this.screenWidth,
(this.worldHeight * this.scale.y) - this.screenHeight
)

@@ -874,7 +889,7 @@ };

{
return -this.x / this.scale.x + this.worldScreenWidth;
return (-this.x / this.scale.x) + this.worldScreenWidth;
}
set right(value: number)
{
this.x = -value * this.scale.x + this.screenWidth;
this.x = (-value * this.scale.x) + this.screenWidth;
this.plugins.reset();

@@ -908,7 +923,7 @@ }

{
return -this.y / this.scale.y + this.worldScreenHeight;
return (-this.y / this.scale.y) + this.worldScreenHeight;
}
set bottom(value: number)
{
this.y = -value * this.scale.y + this.screenHeight;
this.y = (-value * this.scale.y) + this.screenHeight;
this.plugins.reset();

@@ -918,3 +933,3 @@ }

/**
* Determines whether the viewport is dirty (i.e., needs to be renderered to the screen because of a change)
* Determines whether the viewport is dirty (i.e., needs to be rendered to the screen because of a change)
*/

@@ -933,3 +948,4 @@ get dirty(): boolean

*
* NOTE: if not set then hitArea = PIXI.Rectangle(Viewport.left, Viewport.top, Viewport.worldScreenWidth, Viewport.worldScreenHeight)
* NOTE: if not set then hitArea = PIXI.Rectangle(Viewport.left, Viewport.top, Viewport.worldScreenWidth,
* Viewport.worldScreenHeight)
*/

@@ -960,6 +976,22 @@ get forceHitArea(): IHitArea | null | undefined

*
* @param {DragOptions} [options]
* @param {IDragOptions} [options]
* @param {string} [options.direction=all] direction to drag
* @param {boolean} [options.pressDrag=true] whether click to drag is active
* @param {boolean} [options.wheel=true] use wheel to scroll in direction (unless wheel plugin is active)
* @param {number} [options.wheelScroll=1] number of pixels to scroll with each wheel spin
* @param {boolean} [options.reverse] reverse the direction of the wheel scroll
* @param {(boolean|string)} [options.clampWheel=false] clamp wheel(to avoid weird bounce with mouse wheel)
* @param {string} [options.underflow=center] where to place world if too small for screen
* @param {number} [options.factor=1] factor to multiply drag to increase the speed of movement
* @param {string} [options.mouseButtons=all] changes which mouse buttons trigger drag, use: 'all', 'left',
* 'right' 'middle', or some combination, like, 'middle-right'; you may want to set
* viewport.options.disableOnContextMenu if you want to use right-click dragging
* @param {string[]} [options.keyToPress=null] - array containing
* {@link key|https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code} codes of keys that can be
* pressed for the drag to be triggered, e.g.: ['ShiftLeft', 'ShiftRight'}.
* @param {boolean} [options.ignoreKeyToPressOnTouch=false] - ignore keyToPress for touch events
* @param {number} [options.lineHeight=20] - scaling factor for non-DOM_DELTA_PIXEL scrolling events
* @returns {Viewport} this
*/
public drag(options: any): this
public drag(options: IDragOptions): Viewport
{

@@ -973,3 +1005,16 @@ this.plugins.add('drag', new Drag(this, options));

* Clamp to world boundaries or other provided boundaries
* There are three ways to clamp:
* 1. direction: 'all' = the world is clamped to its world boundaries, ie, you cannot drag any part of offscreen
* direction: 'x' | 'y' = only the x or y direction is clamped to its world boundary
* 2. left, right, top, bottom = true | number = the world is clamped to the world's pixel location for each side;
* if any of these are set to true, then the location is set to the boundary
* [0, viewport.worldWidth/viewport.worldHeight], eg: to allow the world to be completely dragged offscreen,
* set [-viewport.worldWidth, -viewport.worldHeight, viewport.worldWidth * 2, viewport.worldHeight * 2]
*
* Underflow determines what happens when the world is smaller than the viewport
* 1. none = the world is clamped but there is no special behavior
* 2. center = the world is centered on the viewport
* 3. combination of top/bottom/center and left/right/center (case insensitive) = the world is stuck to the
* appropriate boundaries
*
* NOTES:

@@ -979,6 +1024,13 @@ * clamp is disabled if called with no options; use { direction: 'all' } for all edge clamping

*
* @param {ClampOptions} [options]
* @returns {Viewport} this
* @param {object} [options]
* @param {(number|boolean)} [options.left=false] - clamp left; true = 0
* @param {(number|boolean)} [options.right=false] - clamp right; true = viewport.worldWidth
* @param {(number|boolean)} [options.top=false] - clamp top; true = 0
* @param {(number|boolean)} [options.bottom=false] - clamp bottom; true = viewport.worldHeight
* @param {string} [direction] - (all, x, or y) using clamps of [0, viewport.worldWidth/viewport.worldHeight];
* replaces left/right/top/bottom if set
* @param {string} [underflow=center] - where to place world if too small for screen (e.g., top-right, center,
* none, bottomLeft) * @returns {Viewport} this
*/
public clamp(options: any): this
public clamp(options: IClampOptions): Viewport
{

@@ -995,6 +1047,10 @@ this.plugins.add('clamp', new Clamp(this, options));

*
* @param {DecelerateOptions} [options]
* @param {IDecelerateOptions} [options]
* @param {number} [options.friction=0.95] - percent to decelerate after movement
* @param {number} [options.bounce=0.8] - percent to decelerate when past boundaries (only applicable when
* viewport.bounce() is active)
* @param {number} [options.minSpeed=0.01] - minimum velocity before stopping/reversing acceleration
* @return {Viewport} this
*/
public decelerate(options: any): this
public decelerate(options: IDecelerateOptions): Viewport
{

@@ -1012,6 +1068,7 @@ this.plugins.add('decelerate', new Decelerate(this, options));

* @param {object} [options]
* @param {string} [options.sides=all] all, horizontal, vertical, or combination of top, bottom, right, left (e.g., 'top-bottom-right')
* @param {number} [options.friction=0.5] friction to apply to decelerate if active
* @param {number} [options.time=150] time in ms to finish bounce
* @param {object} [options.bounceBox] use this bounceBox instead of (0, 0, viewport.worldWidth, viewport.worldHeight)
* @param {string} [options.sides=all] - all, horizontal, vertical, or combination of top, bottom, right, left
* (e.g., 'top-bottom-right')
* @param {number} [options.friction=0.5] - friction to apply to decelerate if active
* @param {number} [options.time=150] - time in ms to finish bounce
* @param {object} [options.bounceBox] - use this bounceBox instead of (0, 0, viewport.worldWidth, viewport.worldHeight)
* @param {number} [options.bounceBox.x=0]

@@ -1021,7 +1078,9 @@ * @param {number} [options.bounceBox.y=0]

* @param {number} [options.bounceBox.height=viewport.worldHeight]
* @param {string|function} [options.ease=easeInOutSine] ease function or name (see http://easings.net/ for supported names)
* @param {string} [options.underflow=center] (top/bottom/center and left/right/center, or center) where to place world if too small for screen
* @param {string|function} [options.ease=easeInOutSine] - ease function or name
* (see http://easings.net/ for supported names)
* @param {string} [options.underflow=center] - (top/bottom/center and left/right/center, or center)
* where to place world if too small for screen
* @return {Viewport} this
*/
public bounce(options: any): this
public bounce(options: IBounceOptions): Viewport
{

@@ -1037,5 +1096,10 @@ this.plugins.add('bounce', new Bounce(this, options));

* @param {PinchOptions} [options]
* @param {boolean} [options.noDrag] - disable two-finger dragging
* @param {number} [options.percent=1] - percent to modify pinch speed
* @param {number} [options.factor=1] - factor to multiply two-finger drag to increase the speed of movement
* @param {PIXI.Point} [options.center] - place this point at center during zoom instead of center of two fingers
* @param {('all'|'x'|'y')} [options.axis=all] - axis to zoom
* @return {Viewport} this
*/
public pinch(options: any): this
public pinch(options: IPinchOptions): Viewport
{

@@ -1052,6 +1116,16 @@ this.plugins.add('pinch', new Pinch(this, options));

* @param {number} y
* @param {SnapOptions} [options]
* @param {ISnapOptions} [options]
* @param {boolean} [options.topLeft] - snap to the top-left of viewport instead of center
* @param {number} [options.friction=0.8] - friction/frame to apply if decelerate is active
* @param {number} [options.time=1000] - time in ms to snap
* @param {string|function} [options.ease=easeInOutSine] - ease function or name (see http://easings.net/
* for supported names)
* @param {boolean} [options.interrupt=true] - pause snapping with any user input on the viewport
* @param {boolean} [options.removeOnComplete] - removes this plugin after snapping is complete
* @param {boolean} [options.removeOnInterrupt] - removes this plugin if interrupted by any user input
* @param {boolean} [options.forceStart] - starts the snap immediately regardless of whether the viewport is at
* the desired location
* @return {Viewport} this
*/
public snap(x: number, y: number, options: any): this
public snap(x: number, y: number, options: ISnapOptions): Viewport
{

@@ -1071,7 +1145,13 @@ this.plugins.add('snap', new Snap(this, x, y, options));

* fires 'moved' event
*
* @param {PIXI.DisplayObject} target to follow
* @param {FollowOptions} [options]
* @param {IFollowOptions} [options]
* @param {number} [options.speed=0] - to follow in pixels/frame (0=teleport to location)
* @param {number} [options.acceleration] - set acceleration to accelerate and decelerate at this rate; speed
* cannot be 0 to use acceleration
* @param {number} [options.radius] - radius (in world coordinates) of center circle where movement is allowed
* without moving the viewport * @returns {Viewport} this
* @returns {Viewport} this
*/
public follow(target: DisplayObject, options: any): this
public follow(target: DisplayObject, options: IFollowOptions): Viewport
{

@@ -1086,6 +1166,16 @@ this.plugins.add('follow', new Follow(this, target, options));

*
* @param {WheelOptions} [options]
* NOTE: the default event listener for 'wheel' event is document.body. Use `Viewport.options.divWheel` to
* change this default
*
* @param {IWheelOptions} [options]
* @param {number} [options.percent=0.1] - percent to scroll with each spin
* @param {number} [options.smooth] - smooth the zooming by providing the number of frames to zoom between wheel spins
* @param {boolean} [options.interrupt=true] - stop smoothing with any user input on the viewport
* @param {boolean} [options.reverse] - reverse the direction of the scroll
* @param {PIXI.Point} [options.center] - place this point at center during zoom instead of current mouse position
* @param {number} [options.lineHeight=20] - scaling factor for non-DOM_DELTA_PIXEL scrolling events
* @param {('all'|'x'|'y')} [options.axis=all] - axis to zoom
* @return {Viewport} this
*/
public wheel(options: any): this
public wheel(options: IWheelOptions): Viewport
{

@@ -1099,7 +1189,19 @@ this.plugins.add('wheel', new Wheel(this, options));

* Animate the position and/or scale of the viewport
*
* @param {AnimateOptions} options
* To set the zoom level, use: (1) scale, (2) scaleX and scaleY, or (3) width and/or height
* @params {object} options
* @params {number} [options.time=1000] - time to animate
* @params {PIXI.Point} [options.position=viewport.center] - position to move viewport
* @params {number} [options.width] - desired viewport width in world pixels (use instead of scale;
* aspect ratio is maintained if height is not provided)
* @params {number} [options.height] - desired viewport height in world pixels (use instead of scale;
* aspect ratio is maintained if width is not provided)
* @params {number} [options.scale] - scale to change zoom (scale.x = scale.y)
* @params {number} [options.scaleX] - independently change zoom in x-direction
* @params {number} [options.scaleY] - independently change zoom in y-direction
* @params {(function|string)} [options.ease=linear] - easing function to use
* @params {function} [options.callbackOnComplete]
* @params {boolean} [options.removeOnInterrupt] removes this plugin if interrupted by any user input
* @returns {Viewport} this
*/
public animate(options: any): this
public animate(options: IAnimateOptions): Viewport
{

@@ -1124,6 +1226,12 @@ this.plugins.add('animate', new Animate(this, options));

*
* @param {ClampZoomOptions} [options]
* @param {object} [options]
* @param {number} [options.minWidth] - minimum width
* @param {number} [options.minHeight] - minimum height
* @param {number} [options.maxWidth] - maximum width
* @param {number} [options.maxHeight] - maximum height
* @param {number} [options.minScale] - minimum scale
* @param {number} [options.maxScale] - minimum scale
* @return {Viewport} this
*/
public clampZoom(options: any): this
public clampZoom(options: IClampZoomOptions): Viewport
{

@@ -1138,7 +1246,19 @@ this.plugins.add('clamp-zoom', new ClampZoom(this, options));

*
* NOTE: fires 'moved' event
* NOTES: fires 'moved' event; there's a known bug where the mouseEdges does not work properly with "windowed" viewports
*
* @param {MouseEdgesOptions} [options]
* @param {IMouseEdgesOptions} [options]
* @param {number} [options.radius] - distance from center of screen in screen pixels
* @param {number} [options.distance] - distance from all sides in screen pixels
* @param {number} [options.top] - alternatively, set top distance (leave unset for no top scroll)
* @param {number} [options.bottom] - alternatively, set bottom distance (leave unset for no top scroll)
* @param {number} [options.left] - alternatively, set left distance (leave unset for no top scroll)
* @param {number} [options.right] - alternatively, set right distance (leave unset for no top scroll)
* @param {number} [options.speed=8] - speed in pixels/frame to scroll viewport
* @param {boolean} [options.reverse] - reverse direction of scroll
* @param {boolean} [options.noDecelerate] - don't use decelerate plugin even if it's installed
* @param {boolean} [options.linear] - if using radius, use linear movement (+/- 1, +/- 1) instead of angled
* movement (Math.cos(angle from center), Math.sin(angle from center))
* @param {boolean} [options.allowButtons] allows plugin to continue working even when there's a mousedown event
*/
public mouseEdges(options: any): this
public mouseEdges(options: IMouseEdgesOptions): Viewport
{

@@ -1178,3 +1298,3 @@ this.plugins.add('mouse-edges', new MouseEdges(this, options));

*/
public ensureVisible(x: number, y: number, width: number, height: number, resizeToFit?: boolean)
public ensureVisible(x: number, y: number, width: number, height: number, resizeToFit?: boolean): void
{

@@ -1181,0 +1301,0 @@ if (resizeToFit && (width > this.worldScreenWidth || height > this.worldScreenHeight))

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc