pixi-watchface-engine 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/EventBus.d.ts +7 -0
- package/dist/EventBus.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1569 -0
- package/dist/plugins/ViewportPlugin.d.ts +39 -0
- package/dist/plugins/ViewportPlugin.d.ts.map +1 -0
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/index.d.ts.map +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -33036,12 +33036,15 @@ class Text extends AbstractText {
|
|
|
33036
33036
|
}
|
|
33037
33037
|
}
|
|
33038
33038
|
// node_modules/pixi.js/lib/index.mjs
|
|
33039
|
+
init_Point();
|
|
33040
|
+
init_Rectangle();
|
|
33039
33041
|
init_Texture();
|
|
33040
33042
|
init_textureFrom();
|
|
33041
33043
|
init_Container();
|
|
33042
33044
|
init_Graphics();
|
|
33043
33045
|
init_Sprite();
|
|
33044
33046
|
init_TextStyle();
|
|
33047
|
+
init_Ticker();
|
|
33045
33048
|
init_eventemitter3();
|
|
33046
33049
|
extensions.add(browserExt, webworkerExt);
|
|
33047
33050
|
|
|
@@ -34984,9 +34987,1575 @@ class KeyboardShortcutsPlugin {
|
|
|
34984
34987
|
}
|
|
34985
34988
|
}
|
|
34986
34989
|
}
|
|
34990
|
+
// node_modules/pixi-viewport/dist/pixi_viewport.js
|
|
34991
|
+
var S2 = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
34992
|
+
function M2(l2) {
|
|
34993
|
+
return l2 && l2.__esModule && Object.prototype.hasOwnProperty.call(l2, "default") ? l2.default : l2;
|
|
34994
|
+
}
|
|
34995
|
+
var W = { exports: {} };
|
|
34996
|
+
(function(l2, t2) {
|
|
34997
|
+
(function() {
|
|
34998
|
+
var e2, n2;
|
|
34999
|
+
n2 = function(i2) {
|
|
35000
|
+
return l2.exports = i2;
|
|
35001
|
+
}, e2 = {
|
|
35002
|
+
linear: function(i2, s2, h2, o2) {
|
|
35003
|
+
return h2 * i2 / o2 + s2;
|
|
35004
|
+
},
|
|
35005
|
+
easeInQuad: function(i2, s2, h2, o2) {
|
|
35006
|
+
return h2 * (i2 /= o2) * i2 + s2;
|
|
35007
|
+
},
|
|
35008
|
+
easeOutQuad: function(i2, s2, h2, o2) {
|
|
35009
|
+
return -h2 * (i2 /= o2) * (i2 - 2) + s2;
|
|
35010
|
+
},
|
|
35011
|
+
easeInOutQuad: function(i2, s2, h2, o2) {
|
|
35012
|
+
return (i2 /= o2 / 2) < 1 ? h2 / 2 * i2 * i2 + s2 : -h2 / 2 * (--i2 * (i2 - 2) - 1) + s2;
|
|
35013
|
+
},
|
|
35014
|
+
easeInCubic: function(i2, s2, h2, o2) {
|
|
35015
|
+
return h2 * (i2 /= o2) * i2 * i2 + s2;
|
|
35016
|
+
},
|
|
35017
|
+
easeOutCubic: function(i2, s2, h2, o2) {
|
|
35018
|
+
return h2 * ((i2 = i2 / o2 - 1) * i2 * i2 + 1) + s2;
|
|
35019
|
+
},
|
|
35020
|
+
easeInOutCubic: function(i2, s2, h2, o2) {
|
|
35021
|
+
return (i2 /= o2 / 2) < 1 ? h2 / 2 * i2 * i2 * i2 + s2 : h2 / 2 * ((i2 -= 2) * i2 * i2 + 2) + s2;
|
|
35022
|
+
},
|
|
35023
|
+
easeInQuart: function(i2, s2, h2, o2) {
|
|
35024
|
+
return h2 * (i2 /= o2) * i2 * i2 * i2 + s2;
|
|
35025
|
+
},
|
|
35026
|
+
easeOutQuart: function(i2, s2, h2, o2) {
|
|
35027
|
+
return -h2 * ((i2 = i2 / o2 - 1) * i2 * i2 * i2 - 1) + s2;
|
|
35028
|
+
},
|
|
35029
|
+
easeInOutQuart: function(i2, s2, h2, o2) {
|
|
35030
|
+
return (i2 /= o2 / 2) < 1 ? h2 / 2 * i2 * i2 * i2 * i2 + s2 : -h2 / 2 * ((i2 -= 2) * i2 * i2 * i2 - 2) + s2;
|
|
35031
|
+
},
|
|
35032
|
+
easeInQuint: function(i2, s2, h2, o2) {
|
|
35033
|
+
return h2 * (i2 /= o2) * i2 * i2 * i2 * i2 + s2;
|
|
35034
|
+
},
|
|
35035
|
+
easeOutQuint: function(i2, s2, h2, o2) {
|
|
35036
|
+
return h2 * ((i2 = i2 / o2 - 1) * i2 * i2 * i2 * i2 + 1) + s2;
|
|
35037
|
+
},
|
|
35038
|
+
easeInOutQuint: function(i2, s2, h2, o2) {
|
|
35039
|
+
return (i2 /= o2 / 2) < 1 ? h2 / 2 * i2 * i2 * i2 * i2 * i2 + s2 : h2 / 2 * ((i2 -= 2) * i2 * i2 * i2 * i2 + 2) + s2;
|
|
35040
|
+
},
|
|
35041
|
+
easeInSine: function(i2, s2, h2, o2) {
|
|
35042
|
+
return -h2 * Math.cos(i2 / o2 * (Math.PI / 2)) + h2 + s2;
|
|
35043
|
+
},
|
|
35044
|
+
easeOutSine: function(i2, s2, h2, o2) {
|
|
35045
|
+
return h2 * Math.sin(i2 / o2 * (Math.PI / 2)) + s2;
|
|
35046
|
+
},
|
|
35047
|
+
easeInOutSine: function(i2, s2, h2, o2) {
|
|
35048
|
+
return -h2 / 2 * (Math.cos(Math.PI * i2 / o2) - 1) + s2;
|
|
35049
|
+
},
|
|
35050
|
+
easeInExpo: function(i2, s2, h2, o2) {
|
|
35051
|
+
return i2 === 0 ? s2 : h2 * Math.pow(2, 10 * (i2 / o2 - 1)) + s2;
|
|
35052
|
+
},
|
|
35053
|
+
easeOutExpo: function(i2, s2, h2, o2) {
|
|
35054
|
+
return i2 === o2 ? s2 + h2 : h2 * (-Math.pow(2, -10 * i2 / o2) + 1) + s2;
|
|
35055
|
+
},
|
|
35056
|
+
easeInOutExpo: function(i2, s2, h2, o2) {
|
|
35057
|
+
return (i2 /= o2 / 2) < 1 ? h2 / 2 * Math.pow(2, 10 * (i2 - 1)) + s2 : h2 / 2 * (-Math.pow(2, -10 * --i2) + 2) + s2;
|
|
35058
|
+
},
|
|
35059
|
+
easeInCirc: function(i2, s2, h2, o2) {
|
|
35060
|
+
return -h2 * (Math.sqrt(1 - (i2 /= o2) * i2) - 1) + s2;
|
|
35061
|
+
},
|
|
35062
|
+
easeOutCirc: function(i2, s2, h2, o2) {
|
|
35063
|
+
return h2 * Math.sqrt(1 - (i2 = i2 / o2 - 1) * i2) + s2;
|
|
35064
|
+
},
|
|
35065
|
+
easeInOutCirc: function(i2, s2, h2, o2) {
|
|
35066
|
+
return (i2 /= o2 / 2) < 1 ? -h2 / 2 * (Math.sqrt(1 - i2 * i2) - 1) + s2 : h2 / 2 * (Math.sqrt(1 - (i2 -= 2) * i2) + 1) + s2;
|
|
35067
|
+
},
|
|
35068
|
+
easeInElastic: function(i2, s2, h2, o2) {
|
|
35069
|
+
var r2, a2, p2;
|
|
35070
|
+
return p2 = 1.70158, a2 = 0, r2 = h2, i2 === 0 || (i2 /= o2), a2 || (a2 = o2 * 0.3), r2 < Math.abs(h2) ? (r2 = h2, p2 = a2 / 4) : p2 = a2 / (2 * Math.PI) * Math.asin(h2 / r2), -(r2 * Math.pow(2, 10 * (i2 -= 1)) * Math.sin((i2 * o2 - p2) * (2 * Math.PI) / a2)) + s2;
|
|
35071
|
+
},
|
|
35072
|
+
easeOutElastic: function(i2, s2, h2, o2) {
|
|
35073
|
+
var r2, a2, p2;
|
|
35074
|
+
return p2 = 1.70158, a2 = 0, r2 = h2, i2 === 0 || (i2 /= o2), a2 || (a2 = o2 * 0.3), r2 < Math.abs(h2) ? (r2 = h2, p2 = a2 / 4) : p2 = a2 / (2 * Math.PI) * Math.asin(h2 / r2), r2 * Math.pow(2, -10 * i2) * Math.sin((i2 * o2 - p2) * (2 * Math.PI) / a2) + h2 + s2;
|
|
35075
|
+
},
|
|
35076
|
+
easeInOutElastic: function(i2, s2, h2, o2) {
|
|
35077
|
+
var r2, a2, p2;
|
|
35078
|
+
return p2 = 1.70158, a2 = 0, r2 = h2, i2 === 0 || (i2 /= o2 / 2), a2 || (a2 = o2 * (0.3 * 1.5)), r2 < Math.abs(h2) ? (r2 = h2, p2 = a2 / 4) : p2 = a2 / (2 * Math.PI) * Math.asin(h2 / r2), i2 < 1 ? -0.5 * (r2 * Math.pow(2, 10 * (i2 -= 1)) * Math.sin((i2 * o2 - p2) * (2 * Math.PI) / a2)) + s2 : r2 * Math.pow(2, -10 * (i2 -= 1)) * Math.sin((i2 * o2 - p2) * (2 * Math.PI) / a2) * 0.5 + h2 + s2;
|
|
35079
|
+
},
|
|
35080
|
+
easeInBack: function(i2, s2, h2, o2, r2) {
|
|
35081
|
+
return r2 === undefined && (r2 = 1.70158), h2 * (i2 /= o2) * i2 * ((r2 + 1) * i2 - r2) + s2;
|
|
35082
|
+
},
|
|
35083
|
+
easeOutBack: function(i2, s2, h2, o2, r2) {
|
|
35084
|
+
return r2 === undefined && (r2 = 1.70158), h2 * ((i2 = i2 / o2 - 1) * i2 * ((r2 + 1) * i2 + r2) + 1) + s2;
|
|
35085
|
+
},
|
|
35086
|
+
easeInOutBack: function(i2, s2, h2, o2, r2) {
|
|
35087
|
+
return r2 === undefined && (r2 = 1.70158), (i2 /= o2 / 2) < 1 ? h2 / 2 * (i2 * i2 * (((r2 *= 1.525) + 1) * i2 - r2)) + s2 : h2 / 2 * ((i2 -= 2) * i2 * (((r2 *= 1.525) + 1) * i2 + r2) + 2) + s2;
|
|
35088
|
+
},
|
|
35089
|
+
easeInBounce: function(i2, s2, h2, o2) {
|
|
35090
|
+
var r2;
|
|
35091
|
+
return r2 = e2.easeOutBounce(o2 - i2, 0, h2, o2), h2 - r2 + s2;
|
|
35092
|
+
},
|
|
35093
|
+
easeOutBounce: function(i2, s2, h2, o2) {
|
|
35094
|
+
return (i2 /= o2) < 1 / 2.75 ? h2 * (7.5625 * i2 * i2) + s2 : i2 < 2 / 2.75 ? h2 * (7.5625 * (i2 -= 1.5 / 2.75) * i2 + 0.75) + s2 : i2 < 2.5 / 2.75 ? h2 * (7.5625 * (i2 -= 2.25 / 2.75) * i2 + 0.9375) + s2 : h2 * (7.5625 * (i2 -= 2.625 / 2.75) * i2 + 0.984375) + s2;
|
|
35095
|
+
},
|
|
35096
|
+
easeInOutBounce: function(i2, s2, h2, o2) {
|
|
35097
|
+
var r2;
|
|
35098
|
+
return i2 < o2 / 2 ? (r2 = e2.easeInBounce(i2 * 2, 0, h2, o2), r2 * 0.5 + s2) : (r2 = e2.easeOutBounce(i2 * 2 - o2, 0, h2, o2), r2 * 0.5 + h2 * 0.5 + s2);
|
|
35099
|
+
}
|
|
35100
|
+
}, n2(e2);
|
|
35101
|
+
}).call(S2);
|
|
35102
|
+
})(W);
|
|
35103
|
+
var O = W.exports;
|
|
35104
|
+
var v2 = /* @__PURE__ */ M2(O);
|
|
35105
|
+
function x2(l2, t2) {
|
|
35106
|
+
if (l2) {
|
|
35107
|
+
if (typeof l2 == "function")
|
|
35108
|
+
return l2;
|
|
35109
|
+
if (typeof l2 == "string")
|
|
35110
|
+
return v2[l2];
|
|
35111
|
+
} else
|
|
35112
|
+
return v2[t2];
|
|
35113
|
+
}
|
|
35114
|
+
|
|
35115
|
+
class P {
|
|
35116
|
+
constructor(t2) {
|
|
35117
|
+
this.viewport = t2, this.touches = [], this.addListeners();
|
|
35118
|
+
}
|
|
35119
|
+
addListeners() {
|
|
35120
|
+
this.viewport.eventMode = "static", this.viewport.forceHitArea || (this.viewport.hitArea = new Rectangle(0, 0, this.viewport.worldWidth, this.viewport.worldHeight)), this.viewport.on("pointerdown", this.down, this), this.viewport.options.allowPreserveDragOutside ? this.viewport.on("globalpointermove", this.move, 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.options.allowPreserveDragOutside || this.viewport.on("pointerleave", this.up, this), this.wheelFunction = (t2) => this.handleWheel(t2), this.viewport.options.events.domElement.addEventListener("wheel", this.wheelFunction, { passive: this.viewport.options.passiveWheel }), this.isMouseDown = false;
|
|
35121
|
+
}
|
|
35122
|
+
destroy() {
|
|
35123
|
+
var t2;
|
|
35124
|
+
(t2 = this.viewport.options.events.domElement) == null || t2.removeEventListener("wheel", this.wheelFunction);
|
|
35125
|
+
}
|
|
35126
|
+
down(t2) {
|
|
35127
|
+
if (this.viewport.pause || !this.viewport.visible)
|
|
35128
|
+
return;
|
|
35129
|
+
if (t2.pointerType === "mouse" ? this.isMouseDown = true : this.get(t2.pointerId) || this.touches.push({ id: t2.pointerId, last: null }), this.count() === 1) {
|
|
35130
|
+
this.last = t2.global.clone();
|
|
35131
|
+
const n2 = this.viewport.plugins.get("decelerate", true), i2 = this.viewport.plugins.get("bounce", true);
|
|
35132
|
+
(!n2 || !n2.isActive()) && (!i2 || !i2.isActive()) ? this.clickedAvailable = true : this.clickedAvailable = false;
|
|
35133
|
+
} else
|
|
35134
|
+
this.clickedAvailable = false;
|
|
35135
|
+
this.viewport.plugins.down(t2) && this.viewport.options.stopPropagation && t2.stopPropagation();
|
|
35136
|
+
}
|
|
35137
|
+
clear() {
|
|
35138
|
+
this.isMouseDown = false, this.touches = [], this.last = null;
|
|
35139
|
+
}
|
|
35140
|
+
checkThreshold(t2) {
|
|
35141
|
+
return Math.abs(t2) >= this.viewport.threshold;
|
|
35142
|
+
}
|
|
35143
|
+
move(t2) {
|
|
35144
|
+
if (this.viewport.pause || !this.viewport.visible)
|
|
35145
|
+
return;
|
|
35146
|
+
const e2 = this.viewport.plugins.move(t2);
|
|
35147
|
+
if (this.clickedAvailable && this.last) {
|
|
35148
|
+
const n2 = t2.global.x - this.last.x, i2 = t2.global.y - this.last.y;
|
|
35149
|
+
(this.checkThreshold(n2) || this.checkThreshold(i2)) && (this.clickedAvailable = false);
|
|
35150
|
+
}
|
|
35151
|
+
e2 && this.viewport.options.stopPropagation && t2.stopPropagation();
|
|
35152
|
+
}
|
|
35153
|
+
up(t2) {
|
|
35154
|
+
if (this.viewport.pause || !this.viewport.visible)
|
|
35155
|
+
return;
|
|
35156
|
+
t2.pointerType === "mouse" && (this.isMouseDown = false), t2.pointerType !== "mouse" && this.remove(t2.pointerId);
|
|
35157
|
+
const e2 = this.viewport.plugins.up(t2);
|
|
35158
|
+
this.clickedAvailable && this.count() === 0 && this.last && (this.viewport.emit("clicked", {
|
|
35159
|
+
event: t2,
|
|
35160
|
+
screen: this.last,
|
|
35161
|
+
world: this.viewport.toWorld(this.last),
|
|
35162
|
+
viewport: this.viewport
|
|
35163
|
+
}), this.clickedAvailable = false), e2 && this.viewport.options.stopPropagation && t2.stopPropagation();
|
|
35164
|
+
}
|
|
35165
|
+
getPointerPosition(t2) {
|
|
35166
|
+
const e2 = new Point;
|
|
35167
|
+
return this.viewport.options.events.mapPositionToPoint(e2, t2.clientX, t2.clientY), e2;
|
|
35168
|
+
}
|
|
35169
|
+
handleWheel(t2) {
|
|
35170
|
+
if (this.viewport.pause || !this.viewport.visible)
|
|
35171
|
+
return;
|
|
35172
|
+
const e2 = this.viewport.toLocal(this.getPointerPosition(t2));
|
|
35173
|
+
this.viewport.left <= e2.x && e2.x <= this.viewport.right && this.viewport.top <= e2.y && e2.y <= this.viewport.bottom && this.viewport.plugins.wheel(t2) && !this.viewport.options.passiveWheel && t2.preventDefault();
|
|
35174
|
+
}
|
|
35175
|
+
pause() {
|
|
35176
|
+
this.touches = [], this.isMouseDown = false;
|
|
35177
|
+
}
|
|
35178
|
+
get(t2) {
|
|
35179
|
+
for (const e2 of this.touches)
|
|
35180
|
+
if (e2.id === t2)
|
|
35181
|
+
return e2;
|
|
35182
|
+
return null;
|
|
35183
|
+
}
|
|
35184
|
+
remove(t2) {
|
|
35185
|
+
for (let e2 = 0;e2 < this.touches.length; e2++)
|
|
35186
|
+
if (this.touches[e2].id === t2) {
|
|
35187
|
+
this.touches.splice(e2, 1);
|
|
35188
|
+
return;
|
|
35189
|
+
}
|
|
35190
|
+
}
|
|
35191
|
+
count() {
|
|
35192
|
+
return (this.isMouseDown ? 1 : 0) + this.touches.length;
|
|
35193
|
+
}
|
|
35194
|
+
}
|
|
35195
|
+
var m2 = [
|
|
35196
|
+
"drag",
|
|
35197
|
+
"pinch",
|
|
35198
|
+
"wheel",
|
|
35199
|
+
"follow",
|
|
35200
|
+
"mouse-edges",
|
|
35201
|
+
"decelerate",
|
|
35202
|
+
"animate",
|
|
35203
|
+
"bounce",
|
|
35204
|
+
"snap-zoom",
|
|
35205
|
+
"clamp-zoom",
|
|
35206
|
+
"snap",
|
|
35207
|
+
"clamp"
|
|
35208
|
+
];
|
|
35209
|
+
|
|
35210
|
+
class C {
|
|
35211
|
+
constructor(t2) {
|
|
35212
|
+
this.viewport = t2, this.list = [], this.plugins = {};
|
|
35213
|
+
}
|
|
35214
|
+
add(t2, e2, n2 = m2.length) {
|
|
35215
|
+
const i2 = this.plugins[t2];
|
|
35216
|
+
i2 && i2.destroy(), this.plugins[t2] = e2;
|
|
35217
|
+
const s2 = m2.indexOf(t2);
|
|
35218
|
+
s2 !== -1 && m2.splice(s2, 1), m2.splice(n2, 0, t2), this.sort();
|
|
35219
|
+
}
|
|
35220
|
+
get(t2, e2) {
|
|
35221
|
+
var n2;
|
|
35222
|
+
return e2 && (n2 = this.plugins[t2]) != null && n2.paused ? null : this.plugins[t2];
|
|
35223
|
+
}
|
|
35224
|
+
update(t2) {
|
|
35225
|
+
for (const e2 of this.list)
|
|
35226
|
+
e2.update(t2);
|
|
35227
|
+
}
|
|
35228
|
+
resize() {
|
|
35229
|
+
for (const t2 of this.list)
|
|
35230
|
+
t2.resize();
|
|
35231
|
+
}
|
|
35232
|
+
reset() {
|
|
35233
|
+
for (const t2 of this.list)
|
|
35234
|
+
t2.reset();
|
|
35235
|
+
}
|
|
35236
|
+
removeAll() {
|
|
35237
|
+
this.list.forEach((t2) => {
|
|
35238
|
+
t2.destroy();
|
|
35239
|
+
}), this.plugins = {}, this.sort();
|
|
35240
|
+
}
|
|
35241
|
+
remove(t2) {
|
|
35242
|
+
var e2;
|
|
35243
|
+
this.plugins[t2] && ((e2 = this.plugins[t2]) == null || e2.destroy(), delete this.plugins[t2], this.viewport.emit("plugin-remove", t2), this.sort());
|
|
35244
|
+
}
|
|
35245
|
+
pause(t2) {
|
|
35246
|
+
var e2;
|
|
35247
|
+
(e2 = this.plugins[t2]) == null || e2.pause();
|
|
35248
|
+
}
|
|
35249
|
+
resume(t2) {
|
|
35250
|
+
var e2;
|
|
35251
|
+
(e2 = this.plugins[t2]) == null || e2.resume();
|
|
35252
|
+
}
|
|
35253
|
+
sort() {
|
|
35254
|
+
this.list = [];
|
|
35255
|
+
for (const t2 of m2)
|
|
35256
|
+
this.plugins[t2] && this.list.push(this.plugins[t2]);
|
|
35257
|
+
}
|
|
35258
|
+
down(t2) {
|
|
35259
|
+
let e2 = false;
|
|
35260
|
+
for (const n2 of this.list)
|
|
35261
|
+
n2.down(t2) && (e2 = true);
|
|
35262
|
+
return e2;
|
|
35263
|
+
}
|
|
35264
|
+
move(t2) {
|
|
35265
|
+
let e2 = false;
|
|
35266
|
+
for (const n2 of this.viewport.plugins.list)
|
|
35267
|
+
n2.move(t2) && (e2 = true);
|
|
35268
|
+
return e2;
|
|
35269
|
+
}
|
|
35270
|
+
up(t2) {
|
|
35271
|
+
let e2 = false;
|
|
35272
|
+
for (const n2 of this.list)
|
|
35273
|
+
n2.up(t2) && (e2 = true);
|
|
35274
|
+
return e2;
|
|
35275
|
+
}
|
|
35276
|
+
wheel(t2) {
|
|
35277
|
+
let e2 = false;
|
|
35278
|
+
for (const n2 of this.list)
|
|
35279
|
+
n2.wheel(t2) && (e2 = true);
|
|
35280
|
+
return e2;
|
|
35281
|
+
}
|
|
35282
|
+
}
|
|
35283
|
+
|
|
35284
|
+
class u2 {
|
|
35285
|
+
constructor(t2) {
|
|
35286
|
+
this.parent = t2, this.paused = false;
|
|
35287
|
+
}
|
|
35288
|
+
destroy() {}
|
|
35289
|
+
down(t2) {
|
|
35290
|
+
return false;
|
|
35291
|
+
}
|
|
35292
|
+
move(t2) {
|
|
35293
|
+
return false;
|
|
35294
|
+
}
|
|
35295
|
+
up(t2) {
|
|
35296
|
+
return false;
|
|
35297
|
+
}
|
|
35298
|
+
wheel(t2) {
|
|
35299
|
+
return false;
|
|
35300
|
+
}
|
|
35301
|
+
update(t2) {}
|
|
35302
|
+
resize() {}
|
|
35303
|
+
reset() {}
|
|
35304
|
+
pause() {
|
|
35305
|
+
this.paused = true;
|
|
35306
|
+
}
|
|
35307
|
+
resume() {
|
|
35308
|
+
this.paused = false;
|
|
35309
|
+
}
|
|
35310
|
+
}
|
|
35311
|
+
var I = {
|
|
35312
|
+
removeOnInterrupt: false,
|
|
35313
|
+
ease: "linear",
|
|
35314
|
+
time: 1000
|
|
35315
|
+
};
|
|
35316
|
+
|
|
35317
|
+
class k2 extends u2 {
|
|
35318
|
+
constructor(t2, e2 = {}) {
|
|
35319
|
+
super(t2), this.startWidth = null, this.startHeight = null, this.deltaWidth = null, this.deltaHeight = null, this.width = null, this.height = null, this.time = 0, this.options = Object.assign({}, I, e2), this.options.ease = x2(this.options.ease), this.setupPosition(), this.setupZoom(), this.time = 0;
|
|
35320
|
+
}
|
|
35321
|
+
setupPosition() {
|
|
35322
|
+
typeof this.options.position < "u" ? (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 = false) : this.keepCenter = true;
|
|
35323
|
+
}
|
|
35324
|
+
setupZoom() {
|
|
35325
|
+
this.width = null, this.height = null, typeof this.options.scale < "u" ? this.width = this.parent.screenWidth / this.options.scale : typeof this.options.scaleX < "u" || typeof this.options.scaleY < "u" ? (typeof this.options.scaleX < "u" && (this.width = this.parent.screenWidth / this.options.scaleX), typeof this.options.scaleY < "u" && (this.height = this.parent.screenHeight / this.options.scaleY)) : (typeof this.options.width < "u" && (this.width = this.options.width), typeof this.options.height < "u" && (this.height = this.options.height)), this.width !== null && (this.startWidth = this.parent.screenWidthInWorldPixels, this.deltaWidth = this.width - this.startWidth), this.height !== null && (this.startHeight = this.parent.screenHeightInWorldPixels, this.deltaHeight = this.height - this.startHeight);
|
|
35326
|
+
}
|
|
35327
|
+
down() {
|
|
35328
|
+
return this.options.removeOnInterrupt && this.parent.plugins.remove("animate"), false;
|
|
35329
|
+
}
|
|
35330
|
+
complete() {
|
|
35331
|
+
this.parent.plugins.remove("animate"), this.width !== null && this.parent.fitWidth(this.width, this.keepCenter, this.height === null), this.height !== null && this.parent.fitHeight(this.height, this.keepCenter, this.width === null), !this.keepCenter && this.options.position && this.parent.moveCenter(this.options.position), this.parent.emit("animate-end", this.parent), this.options.callbackOnComplete && this.options.callbackOnComplete(this.parent);
|
|
35332
|
+
}
|
|
35333
|
+
update(t2) {
|
|
35334
|
+
if (this.paused)
|
|
35335
|
+
return;
|
|
35336
|
+
this.time += t2;
|
|
35337
|
+
const e2 = new Point(this.parent.scale.x, this.parent.scale.y);
|
|
35338
|
+
if (this.time >= this.options.time) {
|
|
35339
|
+
const n2 = this.parent.width, i2 = this.parent.height;
|
|
35340
|
+
this.complete(), (n2 !== this.parent.width || i2 !== this.parent.height) && this.parent.emit("zoomed", { viewport: this.parent, original: e2, type: "animate" });
|
|
35341
|
+
} else {
|
|
35342
|
+
const n2 = this.options.ease(this.time, 0, 1, this.options.time);
|
|
35343
|
+
if (this.width !== null) {
|
|
35344
|
+
const i2 = this.startWidth, s2 = this.deltaWidth;
|
|
35345
|
+
this.parent.fitWidth(i2 + s2 * n2, this.keepCenter, this.height === null);
|
|
35346
|
+
}
|
|
35347
|
+
if (this.height !== null) {
|
|
35348
|
+
const i2 = this.startHeight, s2 = this.deltaHeight;
|
|
35349
|
+
this.parent.fitHeight(i2 + s2 * n2, this.keepCenter, this.width === null);
|
|
35350
|
+
}
|
|
35351
|
+
if (this.width === null ? this.parent.scale.x = this.parent.scale.y : this.height === null && (this.parent.scale.y = this.parent.scale.x), !this.keepCenter) {
|
|
35352
|
+
const i2 = this.startX, s2 = this.startY, h2 = this.deltaX, o2 = this.deltaY, r2 = new Point(this.parent.x, this.parent.y);
|
|
35353
|
+
this.parent.moveCenter(i2 + h2 * n2, s2 + o2 * n2), this.parent.emit("moved", { viewport: this.parent, original: r2, type: "animate" });
|
|
35354
|
+
}
|
|
35355
|
+
(this.width || this.height) && this.parent.emit("zoomed", { viewport: this.parent, original: e2, type: "animate" });
|
|
35356
|
+
}
|
|
35357
|
+
}
|
|
35358
|
+
}
|
|
35359
|
+
var Y = {
|
|
35360
|
+
sides: "all",
|
|
35361
|
+
friction: 0.5,
|
|
35362
|
+
time: 150,
|
|
35363
|
+
ease: "easeInOutSine",
|
|
35364
|
+
underflow: "center",
|
|
35365
|
+
bounceBox: null
|
|
35366
|
+
};
|
|
35367
|
+
|
|
35368
|
+
class X extends u2 {
|
|
35369
|
+
constructor(t2, e2 = {}) {
|
|
35370
|
+
super(t2), this.options = Object.assign({}, Y, e2), this.ease = x2(this.options.ease, "easeInOutSine"), this.options.sides ? this.options.sides === "all" ? this.top = this.bottom = this.left = this.right = true : this.options.sides === "horizontal" ? (this.right = this.left = true, this.top = this.bottom = false) : this.options.sides === "vertical" ? (this.left = this.right = false, this.top = this.bottom = true) : (this.top = this.options.sides.indexOf("top") !== -1, this.bottom = this.options.sides.indexOf("bottom") !== -1, this.left = this.options.sides.indexOf("left") !== -1, this.right = this.options.sides.indexOf("right") !== -1) : this.left = this.top = this.right = this.bottom = false;
|
|
35371
|
+
const n2 = this.options.underflow.toLowerCase();
|
|
35372
|
+
n2 === "center" ? (this.underflowX = 0, this.underflowY = 0) : (this.underflowX = n2.indexOf("left") !== -1 ? -1 : n2.indexOf("right") !== -1 ? 1 : 0, this.underflowY = n2.indexOf("top") !== -1 ? -1 : n2.indexOf("bottom") !== -1 ? 1 : 0), this.reset();
|
|
35373
|
+
}
|
|
35374
|
+
isActive() {
|
|
35375
|
+
return this.toX !== null || this.toY !== null;
|
|
35376
|
+
}
|
|
35377
|
+
down() {
|
|
35378
|
+
return this.toX = this.toY = null, false;
|
|
35379
|
+
}
|
|
35380
|
+
up() {
|
|
35381
|
+
return this.bounce(), false;
|
|
35382
|
+
}
|
|
35383
|
+
update(t2) {
|
|
35384
|
+
if (!this.paused) {
|
|
35385
|
+
if (this.bounce(), this.toX) {
|
|
35386
|
+
const e2 = this.toX;
|
|
35387
|
+
e2.time += t2, this.parent.emit("moved", { viewport: this.parent, type: "bounce-x" }), e2.time >= this.options.time ? (this.parent.x = e2.end, this.toX = null, this.parent.emit("bounce-x-end", this.parent)) : this.parent.x = this.ease(e2.time, e2.start, e2.delta, this.options.time);
|
|
35388
|
+
}
|
|
35389
|
+
if (this.toY) {
|
|
35390
|
+
const e2 = this.toY;
|
|
35391
|
+
e2.time += t2, this.parent.emit("moved", { viewport: this.parent, type: "bounce-y" }), e2.time >= this.options.time ? (this.parent.y = e2.end, this.toY = null, this.parent.emit("bounce-y-end", this.parent)) : this.parent.y = this.ease(e2.time, e2.start, e2.delta, this.options.time);
|
|
35392
|
+
}
|
|
35393
|
+
}
|
|
35394
|
+
}
|
|
35395
|
+
calcUnderflowX() {
|
|
35396
|
+
let t2;
|
|
35397
|
+
switch (this.underflowX) {
|
|
35398
|
+
case -1:
|
|
35399
|
+
t2 = 0;
|
|
35400
|
+
break;
|
|
35401
|
+
case 1:
|
|
35402
|
+
t2 = this.parent.screenWidth - this.parent.screenWorldWidth;
|
|
35403
|
+
break;
|
|
35404
|
+
default:
|
|
35405
|
+
t2 = (this.parent.screenWidth - this.parent.screenWorldWidth) / 2;
|
|
35406
|
+
}
|
|
35407
|
+
return t2;
|
|
35408
|
+
}
|
|
35409
|
+
calcUnderflowY() {
|
|
35410
|
+
let t2;
|
|
35411
|
+
switch (this.underflowY) {
|
|
35412
|
+
case -1:
|
|
35413
|
+
t2 = 0;
|
|
35414
|
+
break;
|
|
35415
|
+
case 1:
|
|
35416
|
+
t2 = this.parent.screenHeight - this.parent.screenWorldHeight;
|
|
35417
|
+
break;
|
|
35418
|
+
default:
|
|
35419
|
+
t2 = (this.parent.screenHeight - this.parent.screenWorldHeight) / 2;
|
|
35420
|
+
}
|
|
35421
|
+
return t2;
|
|
35422
|
+
}
|
|
35423
|
+
oob() {
|
|
35424
|
+
const t2 = this.options.bounceBox;
|
|
35425
|
+
if (t2) {
|
|
35426
|
+
const e2 = typeof t2.x > "u" ? 0 : t2.x, n2 = typeof t2.y > "u" ? 0 : t2.y, i2 = typeof t2.width > "u" ? this.parent.worldWidth : t2.width, s2 = typeof t2.height > "u" ? this.parent.worldHeight : t2.height;
|
|
35427
|
+
return {
|
|
35428
|
+
left: this.parent.left < e2,
|
|
35429
|
+
right: this.parent.right > i2,
|
|
35430
|
+
top: this.parent.top < n2,
|
|
35431
|
+
bottom: this.parent.bottom > s2,
|
|
35432
|
+
topLeft: new Point(e2 * this.parent.scale.x, n2 * this.parent.scale.y),
|
|
35433
|
+
bottomRight: new Point(i2 * this.parent.scale.x - this.parent.screenWidth, s2 * this.parent.scale.y - this.parent.screenHeight)
|
|
35434
|
+
};
|
|
35435
|
+
}
|
|
35436
|
+
return {
|
|
35437
|
+
left: this.parent.left < 0,
|
|
35438
|
+
right: this.parent.right > this.parent.worldWidth,
|
|
35439
|
+
top: this.parent.top < 0,
|
|
35440
|
+
bottom: this.parent.bottom > this.parent.worldHeight,
|
|
35441
|
+
topLeft: new Point(0, 0),
|
|
35442
|
+
bottomRight: new Point(this.parent.worldWidth * this.parent.scale.x - this.parent.screenWidth, this.parent.worldHeight * this.parent.scale.y - this.parent.screenHeight)
|
|
35443
|
+
};
|
|
35444
|
+
}
|
|
35445
|
+
bounce() {
|
|
35446
|
+
var s2, h2;
|
|
35447
|
+
if (this.paused)
|
|
35448
|
+
return;
|
|
35449
|
+
let t2, e2 = this.parent.plugins.get("decelerate", true);
|
|
35450
|
+
e2 && (e2.x || e2.y) && (e2.x && e2.percentChangeX === ((s2 = e2.options) == null ? undefined : s2.friction) || e2.y && e2.percentChangeY === ((h2 = e2.options) == null ? undefined : h2.friction)) && (t2 = this.oob(), (t2.left && this.left || t2.right && this.right) && (e2.percentChangeX = this.options.friction), (t2.top && this.top || t2.bottom && this.bottom) && (e2.percentChangeY = this.options.friction));
|
|
35451
|
+
const n2 = this.parent.plugins.get("drag", true) || {}, i2 = this.parent.plugins.get("pinch", true) || {};
|
|
35452
|
+
if (e2 = e2 || {}, !(n2 != null && n2.active) && !(i2 != null && i2.active) && (!this.toX || !this.toY) && (!e2.x || !e2.y)) {
|
|
35453
|
+
t2 = t2 || this.oob();
|
|
35454
|
+
const { topLeft: o2, bottomRight: r2 } = t2;
|
|
35455
|
+
if (!this.toX && !e2.x) {
|
|
35456
|
+
let a2 = null;
|
|
35457
|
+
t2.left && this.left ? a2 = this.parent.screenWorldWidth < this.parent.screenWidth ? this.calcUnderflowX() : -o2.x : t2.right && this.right && (a2 = this.parent.screenWorldWidth < this.parent.screenWidth ? this.calcUnderflowX() : -r2.x), a2 !== null && this.parent.x !== a2 && (this.toX = { time: 0, start: this.parent.x, delta: a2 - this.parent.x, end: a2 }, this.parent.emit("bounce-x-start", this.parent));
|
|
35458
|
+
}
|
|
35459
|
+
if (!this.toY && !e2.y) {
|
|
35460
|
+
let a2 = null;
|
|
35461
|
+
t2.top && this.top ? a2 = this.parent.screenWorldHeight < this.parent.screenHeight ? this.calcUnderflowY() : -o2.y : t2.bottom && this.bottom && (a2 = this.parent.screenWorldHeight < this.parent.screenHeight ? this.calcUnderflowY() : -r2.y), a2 !== null && this.parent.y !== a2 && (this.toY = { time: 0, start: this.parent.y, delta: a2 - this.parent.y, end: a2 }, this.parent.emit("bounce-y-start", this.parent));
|
|
35462
|
+
}
|
|
35463
|
+
}
|
|
35464
|
+
}
|
|
35465
|
+
reset() {
|
|
35466
|
+
this.toX = this.toY = null, this.bounce();
|
|
35467
|
+
}
|
|
35468
|
+
}
|
|
35469
|
+
var z = {
|
|
35470
|
+
left: false,
|
|
35471
|
+
right: false,
|
|
35472
|
+
top: false,
|
|
35473
|
+
bottom: false,
|
|
35474
|
+
direction: null,
|
|
35475
|
+
underflow: "center"
|
|
35476
|
+
};
|
|
35477
|
+
|
|
35478
|
+
class A extends u2 {
|
|
35479
|
+
constructor(t2, e2 = {}) {
|
|
35480
|
+
super(t2), this.options = Object.assign({}, z, e2), this.options.direction && (this.options.left = this.options.direction === "x" || this.options.direction === "all" ? true : null, this.options.right = this.options.direction === "x" || this.options.direction === "all" ? true : null, this.options.top = this.options.direction === "y" || this.options.direction === "all" ? true : null, this.options.bottom = this.options.direction === "y" || this.options.direction === "all" ? true : null), this.parseUnderflow(), this.last = { x: null, y: null, scaleX: null, scaleY: null }, this.update();
|
|
35481
|
+
}
|
|
35482
|
+
parseUnderflow() {
|
|
35483
|
+
const t2 = this.options.underflow.toLowerCase();
|
|
35484
|
+
t2 === "none" ? this.noUnderflow = true : t2 === "center" ? (this.underflowX = this.underflowY = 0, this.noUnderflow = false) : (this.underflowX = t2.indexOf("left") !== -1 ? -1 : t2.indexOf("right") !== -1 ? 1 : 0, this.underflowY = t2.indexOf("top") !== -1 ? -1 : t2.indexOf("bottom") !== -1 ? 1 : 0, this.noUnderflow = false);
|
|
35485
|
+
}
|
|
35486
|
+
move() {
|
|
35487
|
+
return this.update(), false;
|
|
35488
|
+
}
|
|
35489
|
+
update() {
|
|
35490
|
+
if (this.paused || 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)
|
|
35491
|
+
return;
|
|
35492
|
+
const t2 = new Point(this.parent.x, this.parent.y), e2 = this.parent.plugins.decelerate || {};
|
|
35493
|
+
if (this.options.left !== null || this.options.right !== null) {
|
|
35494
|
+
let n2 = false;
|
|
35495
|
+
if (!this.noUnderflow && this.parent.screenWorldWidth < this.parent.screenWidth)
|
|
35496
|
+
switch (this.underflowX) {
|
|
35497
|
+
case -1:
|
|
35498
|
+
this.parent.x !== 0 && (this.parent.x = 0, n2 = true);
|
|
35499
|
+
break;
|
|
35500
|
+
case 1:
|
|
35501
|
+
this.parent.x !== this.parent.screenWidth - this.parent.screenWorldWidth && (this.parent.x = this.parent.screenWidth - this.parent.screenWorldWidth, n2 = true);
|
|
35502
|
+
break;
|
|
35503
|
+
default:
|
|
35504
|
+
this.parent.x !== (this.parent.screenWidth - this.parent.screenWorldWidth) / 2 && (this.parent.x = (this.parent.screenWidth - this.parent.screenWorldWidth) / 2, n2 = true);
|
|
35505
|
+
}
|
|
35506
|
+
else
|
|
35507
|
+
this.options.left !== null && this.parent.left < (this.options.left === true ? 0 : this.options.left) && (this.parent.x = -(this.options.left === true ? 0 : this.options.left) * this.parent.scale.x, e2.x = 0, n2 = true), this.options.right !== null && this.parent.right > (this.options.right === true ? this.parent.worldWidth : this.options.right) && (this.parent.x = -(this.options.right === true ? this.parent.worldWidth : this.options.right) * this.parent.scale.x + this.parent.screenWidth, e2.x = 0, n2 = true);
|
|
35508
|
+
n2 && this.parent.emit("moved", {
|
|
35509
|
+
viewport: this.parent,
|
|
35510
|
+
original: t2,
|
|
35511
|
+
type: "clamp-x"
|
|
35512
|
+
});
|
|
35513
|
+
}
|
|
35514
|
+
if (this.options.top !== null || this.options.bottom !== null) {
|
|
35515
|
+
let n2 = false;
|
|
35516
|
+
if (!this.noUnderflow && this.parent.screenWorldHeight < this.parent.screenHeight)
|
|
35517
|
+
switch (this.underflowY) {
|
|
35518
|
+
case -1:
|
|
35519
|
+
this.parent.y !== 0 && (this.parent.y = 0, n2 = true);
|
|
35520
|
+
break;
|
|
35521
|
+
case 1:
|
|
35522
|
+
this.parent.y !== this.parent.screenHeight - this.parent.screenWorldHeight && (this.parent.y = this.parent.screenHeight - this.parent.screenWorldHeight, n2 = true);
|
|
35523
|
+
break;
|
|
35524
|
+
default:
|
|
35525
|
+
this.parent.y !== (this.parent.screenHeight - this.parent.screenWorldHeight) / 2 && (this.parent.y = (this.parent.screenHeight - this.parent.screenWorldHeight) / 2, n2 = true);
|
|
35526
|
+
}
|
|
35527
|
+
else
|
|
35528
|
+
this.options.top !== null && this.parent.top < (this.options.top === true ? 0 : this.options.top) && (this.parent.y = -(this.options.top === true ? 0 : this.options.top) * this.parent.scale.y, e2.y = 0, n2 = true), this.options.bottom !== null && this.parent.bottom > (this.options.bottom === true ? this.parent.worldHeight : this.options.bottom) && (this.parent.y = -(this.options.bottom === true ? this.parent.worldHeight : this.options.bottom) * this.parent.scale.y + this.parent.screenHeight, e2.y = 0, n2 = true);
|
|
35529
|
+
n2 && this.parent.emit("moved", {
|
|
35530
|
+
viewport: this.parent,
|
|
35531
|
+
original: t2,
|
|
35532
|
+
type: "clamp-y"
|
|
35533
|
+
});
|
|
35534
|
+
}
|
|
35535
|
+
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;
|
|
35536
|
+
}
|
|
35537
|
+
reset() {
|
|
35538
|
+
this.update();
|
|
35539
|
+
}
|
|
35540
|
+
}
|
|
35541
|
+
var T = {
|
|
35542
|
+
minWidth: null,
|
|
35543
|
+
minHeight: null,
|
|
35544
|
+
maxWidth: null,
|
|
35545
|
+
maxHeight: null,
|
|
35546
|
+
minScale: null,
|
|
35547
|
+
maxScale: null
|
|
35548
|
+
};
|
|
35549
|
+
|
|
35550
|
+
class _ extends u2 {
|
|
35551
|
+
constructor(t2, e2 = {}) {
|
|
35552
|
+
super(t2), this.options = Object.assign({}, T, e2), this.clamp();
|
|
35553
|
+
}
|
|
35554
|
+
resize() {
|
|
35555
|
+
this.clamp();
|
|
35556
|
+
}
|
|
35557
|
+
clamp() {
|
|
35558
|
+
if (!this.paused) {
|
|
35559
|
+
if (this.options.minWidth || this.options.minHeight || this.options.maxWidth || this.options.maxHeight) {
|
|
35560
|
+
let t2 = this.parent.worldScreenWidth, e2 = this.parent.worldScreenHeight;
|
|
35561
|
+
if (this.options.minWidth !== null && t2 < this.options.minWidth) {
|
|
35562
|
+
const n2 = this.parent.scale.x;
|
|
35563
|
+
this.parent.fitWidth(this.options.minWidth, false, false, true), this.parent.scale.y *= this.parent.scale.x / n2, t2 = this.parent.worldScreenWidth, e2 = this.parent.worldScreenHeight, this.parent.emit("zoomed", { viewport: this.parent, type: "clamp-zoom" });
|
|
35564
|
+
}
|
|
35565
|
+
if (this.options.maxWidth !== null && t2 > this.options.maxWidth) {
|
|
35566
|
+
const n2 = this.parent.scale.x;
|
|
35567
|
+
this.parent.fitWidth(this.options.maxWidth, false, false, true), this.parent.scale.y *= this.parent.scale.x / n2, t2 = this.parent.worldScreenWidth, e2 = this.parent.worldScreenHeight, this.parent.emit("zoomed", { viewport: this.parent, type: "clamp-zoom" });
|
|
35568
|
+
}
|
|
35569
|
+
if (this.options.minHeight !== null && e2 < this.options.minHeight) {
|
|
35570
|
+
const n2 = this.parent.scale.y;
|
|
35571
|
+
this.parent.fitHeight(this.options.minHeight, false, false, true), this.parent.scale.x *= this.parent.scale.y / n2, t2 = this.parent.worldScreenWidth, e2 = this.parent.worldScreenHeight, this.parent.emit("zoomed", { viewport: this.parent, type: "clamp-zoom" });
|
|
35572
|
+
}
|
|
35573
|
+
if (this.options.maxHeight !== null && e2 > this.options.maxHeight) {
|
|
35574
|
+
const n2 = this.parent.scale.y;
|
|
35575
|
+
this.parent.fitHeight(this.options.maxHeight, false, false, true), this.parent.scale.x *= this.parent.scale.y / n2, this.parent.emit("zoomed", { viewport: this.parent, type: "clamp-zoom" });
|
|
35576
|
+
}
|
|
35577
|
+
} else if (this.options.minScale || this.options.maxScale) {
|
|
35578
|
+
const t2 = { x: null, y: null }, e2 = { x: null, y: null };
|
|
35579
|
+
if (typeof this.options.minScale == "number")
|
|
35580
|
+
t2.x = this.options.minScale, t2.y = this.options.minScale;
|
|
35581
|
+
else if (this.options.minScale !== null) {
|
|
35582
|
+
const s2 = this.options.minScale;
|
|
35583
|
+
t2.x = typeof s2.x > "u" ? null : s2.x, t2.y = typeof s2.y > "u" ? null : s2.y;
|
|
35584
|
+
}
|
|
35585
|
+
if (typeof this.options.maxScale == "number")
|
|
35586
|
+
e2.x = this.options.maxScale, e2.y = this.options.maxScale;
|
|
35587
|
+
else if (this.options.maxScale !== null) {
|
|
35588
|
+
const s2 = this.options.maxScale;
|
|
35589
|
+
e2.x = typeof s2.x > "u" ? null : s2.x, e2.y = typeof s2.y > "u" ? null : s2.y;
|
|
35590
|
+
}
|
|
35591
|
+
let n2 = this.parent.scale.x, i2 = this.parent.scale.y;
|
|
35592
|
+
t2.x !== null && n2 < t2.x && (n2 = t2.x), e2.x !== null && n2 > e2.x && (n2 = e2.x), t2.y !== null && i2 < t2.y && (i2 = t2.y), e2.y !== null && i2 > e2.y && (i2 = e2.y), (n2 !== this.parent.scale.x || i2 !== this.parent.scale.y) && (this.parent.scale.set(n2, i2), this.parent.emit("zoomed", { viewport: this.parent, type: "clamp-zoom" }));
|
|
35593
|
+
}
|
|
35594
|
+
}
|
|
35595
|
+
}
|
|
35596
|
+
reset() {
|
|
35597
|
+
this.clamp();
|
|
35598
|
+
}
|
|
35599
|
+
}
|
|
35600
|
+
var L = {
|
|
35601
|
+
friction: 0.98,
|
|
35602
|
+
bounce: 0.8,
|
|
35603
|
+
minSpeed: 0.01
|
|
35604
|
+
};
|
|
35605
|
+
var d2 = 16;
|
|
35606
|
+
|
|
35607
|
+
class E extends u2 {
|
|
35608
|
+
constructor(t2, e2 = {}) {
|
|
35609
|
+
super(t2), this.options = Object.assign({}, L, e2), this.saved = [], this.timeSinceRelease = 0, this.reset(), this.parent.on("moved", (n2) => this.handleMoved(n2));
|
|
35610
|
+
}
|
|
35611
|
+
down() {
|
|
35612
|
+
return this.saved = [], this.x = this.y = null, false;
|
|
35613
|
+
}
|
|
35614
|
+
isActive() {
|
|
35615
|
+
return !!(this.x || this.y);
|
|
35616
|
+
}
|
|
35617
|
+
move() {
|
|
35618
|
+
if (this.paused)
|
|
35619
|
+
return false;
|
|
35620
|
+
const t2 = this.parent.input.count();
|
|
35621
|
+
return (t2 === 1 || t2 > 1 && !this.parent.plugins.get("pinch", true)) && (this.saved.push({ x: this.parent.x, y: this.parent.y, time: performance.now() }), this.saved.length > 60 && this.saved.splice(0, 30)), false;
|
|
35622
|
+
}
|
|
35623
|
+
handleMoved(t2) {
|
|
35624
|
+
if (this.saved.length) {
|
|
35625
|
+
const e2 = this.saved[this.saved.length - 1];
|
|
35626
|
+
t2.type === "clamp-x" && t2.original ? e2.x === t2.original.x && (e2.x = this.parent.x) : t2.type === "clamp-y" && t2.original && e2.y === t2.original.y && (e2.y = this.parent.y);
|
|
35627
|
+
}
|
|
35628
|
+
}
|
|
35629
|
+
up() {
|
|
35630
|
+
if (this.parent.input.count() === 0 && this.saved.length) {
|
|
35631
|
+
const t2 = performance.now();
|
|
35632
|
+
for (const e2 of this.saved)
|
|
35633
|
+
if (e2.time >= t2 - 100) {
|
|
35634
|
+
const n2 = t2 - e2.time;
|
|
35635
|
+
this.x = (this.parent.x - e2.x) / n2, this.y = (this.parent.y - e2.y) / n2, this.percentChangeX = this.percentChangeY = this.options.friction, this.timeSinceRelease = 0;
|
|
35636
|
+
break;
|
|
35637
|
+
}
|
|
35638
|
+
}
|
|
35639
|
+
return false;
|
|
35640
|
+
}
|
|
35641
|
+
activate(t2) {
|
|
35642
|
+
t2 = t2 || {}, typeof t2.x < "u" && (this.x = t2.x, this.percentChangeX = this.options.friction), typeof t2.y < "u" && (this.y = t2.y, this.percentChangeY = this.options.friction);
|
|
35643
|
+
}
|
|
35644
|
+
update(t2) {
|
|
35645
|
+
if (this.paused)
|
|
35646
|
+
return;
|
|
35647
|
+
const e2 = this.x || this.y, n2 = this.timeSinceRelease, i2 = this.timeSinceRelease + t2;
|
|
35648
|
+
if (this.x) {
|
|
35649
|
+
const s2 = this.percentChangeX, h2 = Math.log(s2);
|
|
35650
|
+
this.parent.x += this.x * d2 / h2 * (Math.pow(s2, i2 / d2) - Math.pow(s2, n2 / d2)), this.x *= Math.pow(this.percentChangeX, t2 / d2);
|
|
35651
|
+
}
|
|
35652
|
+
if (this.y) {
|
|
35653
|
+
const s2 = this.percentChangeY, h2 = Math.log(s2);
|
|
35654
|
+
this.parent.y += this.y * d2 / h2 * (Math.pow(s2, i2 / d2) - Math.pow(s2, n2 / d2)), this.y *= Math.pow(this.percentChangeY, t2 / d2);
|
|
35655
|
+
}
|
|
35656
|
+
this.timeSinceRelease += t2, this.x && this.y ? Math.abs(this.x) < this.options.minSpeed && Math.abs(this.y) < this.options.minSpeed && (this.x = 0, this.y = 0) : (Math.abs(this.x || 0) < this.options.minSpeed && (this.x = 0), Math.abs(this.y || 0) < this.options.minSpeed && (this.y = 0)), e2 && this.parent.emit("moved", { viewport: this.parent, type: "decelerate" });
|
|
35657
|
+
}
|
|
35658
|
+
reset() {
|
|
35659
|
+
this.x = this.y = null;
|
|
35660
|
+
}
|
|
35661
|
+
}
|
|
35662
|
+
var D = {
|
|
35663
|
+
direction: "all",
|
|
35664
|
+
pressDrag: true,
|
|
35665
|
+
wheel: true,
|
|
35666
|
+
wheelScroll: 1,
|
|
35667
|
+
reverse: false,
|
|
35668
|
+
clampWheel: false,
|
|
35669
|
+
underflow: "center",
|
|
35670
|
+
factor: 1,
|
|
35671
|
+
mouseButtons: "all",
|
|
35672
|
+
keyToPress: null,
|
|
35673
|
+
ignoreKeyToPressOnTouch: false,
|
|
35674
|
+
lineHeight: 20,
|
|
35675
|
+
wheelSwapAxes: false
|
|
35676
|
+
};
|
|
35677
|
+
|
|
35678
|
+
class U extends u2 {
|
|
35679
|
+
constructor(t2, e2 = {}) {
|
|
35680
|
+
super(t2), this.windowEventHandlers = [], this.options = Object.assign({}, D, e2), this.moved = false, this.reverse = this.options.reverse ? 1 : -1, this.xDirection = !this.options.direction || this.options.direction === "all" || this.options.direction === "x", this.yDirection = !this.options.direction || this.options.direction === "all" || this.options.direction === "y", this.keyIsPressed = false, this.parseUnderflow(), this.mouseButtons(this.options.mouseButtons), this.options.keyToPress && this.handleKeyPresses(this.options.keyToPress);
|
|
35681
|
+
}
|
|
35682
|
+
handleKeyPresses(t2) {
|
|
35683
|
+
const e2 = (i2) => {
|
|
35684
|
+
t2.includes(i2.code) && (this.keyIsPressed = true);
|
|
35685
|
+
}, n2 = (i2) => {
|
|
35686
|
+
t2.includes(i2.code) && (this.keyIsPressed = false);
|
|
35687
|
+
};
|
|
35688
|
+
this.addWindowEventHandler("keyup", n2), this.addWindowEventHandler("keydown", e2);
|
|
35689
|
+
}
|
|
35690
|
+
addWindowEventHandler(t2, e2) {
|
|
35691
|
+
typeof window > "u" || (window.addEventListener(t2, e2), this.windowEventHandlers.push({ event: t2, handler: e2 }));
|
|
35692
|
+
}
|
|
35693
|
+
destroy() {
|
|
35694
|
+
typeof window > "u" || this.windowEventHandlers.forEach(({ event: t2, handler: e2 }) => {
|
|
35695
|
+
window.removeEventListener(t2, e2);
|
|
35696
|
+
});
|
|
35697
|
+
}
|
|
35698
|
+
mouseButtons(t2) {
|
|
35699
|
+
!t2 || t2 === "all" ? this.mouse = [true, true, true] : this.mouse = [
|
|
35700
|
+
t2.indexOf("left") !== -1,
|
|
35701
|
+
t2.indexOf("middle") !== -1,
|
|
35702
|
+
t2.indexOf("right") !== -1
|
|
35703
|
+
];
|
|
35704
|
+
}
|
|
35705
|
+
parseUnderflow() {
|
|
35706
|
+
const t2 = this.options.underflow.toLowerCase();
|
|
35707
|
+
t2 === "center" ? (this.underflowX = 0, this.underflowY = 0) : (t2.includes("left") ? this.underflowX = -1 : t2.includes("right") ? this.underflowX = 1 : this.underflowX = 0, t2.includes("top") ? this.underflowY = -1 : t2.includes("bottom") ? this.underflowY = 1 : this.underflowY = 0);
|
|
35708
|
+
}
|
|
35709
|
+
checkButtons(t2) {
|
|
35710
|
+
const e2 = t2.pointerType === "mouse", n2 = this.parent.input.count();
|
|
35711
|
+
return !!((n2 === 1 || n2 > 1 && !this.parent.plugins.get("pinch", true)) && (!e2 || this.mouse[t2.button]));
|
|
35712
|
+
}
|
|
35713
|
+
checkKeyPress(t2) {
|
|
35714
|
+
return !this.options.keyToPress || this.keyIsPressed || this.options.ignoreKeyToPressOnTouch && t2.data.pointerType === "touch";
|
|
35715
|
+
}
|
|
35716
|
+
down(t2) {
|
|
35717
|
+
return this.paused || !this.options.pressDrag ? false : this.checkButtons(t2) && this.checkKeyPress(t2) ? (this.last = { x: t2.global.x, y: t2.global.y }, (this.parent.parent || this.parent).toLocal(this.last, undefined, this.last), this.current = t2.pointerId, true) : (this.last = null, false);
|
|
35718
|
+
}
|
|
35719
|
+
get active() {
|
|
35720
|
+
return this.moved;
|
|
35721
|
+
}
|
|
35722
|
+
move(t2) {
|
|
35723
|
+
if (this.paused || !this.options.pressDrag)
|
|
35724
|
+
return false;
|
|
35725
|
+
if (this.last && this.current === t2.data.pointerId) {
|
|
35726
|
+
const e2 = t2.global.x, n2 = t2.global.y, i2 = this.parent.input.count();
|
|
35727
|
+
if (i2 === 1 || i2 > 1 && !this.parent.plugins.get("pinch", true)) {
|
|
35728
|
+
const s2 = { x: e2, y: n2 };
|
|
35729
|
+
(this.parent.parent || this.parent).toLocal(s2, undefined, s2);
|
|
35730
|
+
const h2 = s2.x - this.last.x, o2 = s2.y - this.last.y;
|
|
35731
|
+
if (this.moved || this.xDirection && this.parent.input.checkThreshold(h2) || this.yDirection && this.parent.input.checkThreshold(o2))
|
|
35732
|
+
return this.xDirection && (this.parent.x += (s2.x - this.last.x) * this.options.factor), this.yDirection && (this.parent.y += (s2.y - this.last.y) * this.options.factor), this.last = s2, this.moved || this.parent.emit("drag-start", {
|
|
35733
|
+
event: t2,
|
|
35734
|
+
screen: new Point(this.last.x, this.last.y),
|
|
35735
|
+
world: this.parent.toWorld(new Point(this.last.x, this.last.y)),
|
|
35736
|
+
viewport: this.parent
|
|
35737
|
+
}), this.moved = true, this.parent.emit("moved", { viewport: this.parent, type: "drag" }), true;
|
|
35738
|
+
} else
|
|
35739
|
+
this.moved = false;
|
|
35740
|
+
}
|
|
35741
|
+
return false;
|
|
35742
|
+
}
|
|
35743
|
+
up(t2) {
|
|
35744
|
+
if (this.paused)
|
|
35745
|
+
return false;
|
|
35746
|
+
const e2 = this.parent.input.touches;
|
|
35747
|
+
if (e2.length === 1) {
|
|
35748
|
+
const n2 = e2[0];
|
|
35749
|
+
return n2.last && (this.last = { x: n2.last.x, y: n2.last.y }, this.current = n2.id), this.moved = false, true;
|
|
35750
|
+
} else if (this.last && this.moved) {
|
|
35751
|
+
const n2 = new Point(this.last.x, this.last.y);
|
|
35752
|
+
return (this.parent.parent || this.parent).toGlobal(n2, n2, true), this.parent.emit("drag-end", {
|
|
35753
|
+
event: t2,
|
|
35754
|
+
screen: n2,
|
|
35755
|
+
world: this.parent.toWorld(n2),
|
|
35756
|
+
viewport: this.parent
|
|
35757
|
+
}), this.last = null, this.moved = false, true;
|
|
35758
|
+
}
|
|
35759
|
+
return false;
|
|
35760
|
+
}
|
|
35761
|
+
wheel(t2) {
|
|
35762
|
+
if (this.paused)
|
|
35763
|
+
return false;
|
|
35764
|
+
if (this.options.wheel) {
|
|
35765
|
+
const e2 = this.parent.plugins.get("wheel", true);
|
|
35766
|
+
if (!e2 || !e2.options.wheelZoom && !t2.ctrlKey) {
|
|
35767
|
+
const n2 = t2.deltaMode ? this.options.lineHeight : 1, i2 = [t2.deltaX, t2.deltaY], [s2, h2] = this.options.wheelSwapAxes ? i2.reverse() : i2;
|
|
35768
|
+
return this.xDirection && (this.parent.x += s2 * n2 * this.options.wheelScroll * this.reverse), this.yDirection && (this.parent.y += h2 * n2 * 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 || t2.preventDefault(), this.parent.options.stopPropagation && t2.stopPropagation(), true;
|
|
35769
|
+
}
|
|
35770
|
+
}
|
|
35771
|
+
return false;
|
|
35772
|
+
}
|
|
35773
|
+
resume() {
|
|
35774
|
+
this.last = null, this.paused = false;
|
|
35775
|
+
}
|
|
35776
|
+
clamp() {
|
|
35777
|
+
const t2 = this.parent.plugins.get("decelerate", true) || {};
|
|
35778
|
+
if (this.options.clampWheel !== "y")
|
|
35779
|
+
if (this.parent.screenWorldWidth < this.parent.screenWidth)
|
|
35780
|
+
switch (this.underflowX) {
|
|
35781
|
+
case -1:
|
|
35782
|
+
this.parent.x = 0;
|
|
35783
|
+
break;
|
|
35784
|
+
case 1:
|
|
35785
|
+
this.parent.x = this.parent.screenWidth - this.parent.screenWorldWidth;
|
|
35786
|
+
break;
|
|
35787
|
+
default:
|
|
35788
|
+
this.parent.x = (this.parent.screenWidth - this.parent.screenWorldWidth) / 2;
|
|
35789
|
+
}
|
|
35790
|
+
else
|
|
35791
|
+
this.parent.left < 0 ? (this.parent.x = 0, t2.x = 0) : this.parent.right > this.parent.worldWidth && (this.parent.x = -this.parent.worldWidth * this.parent.scale.x + this.parent.screenWidth, t2.x = 0);
|
|
35792
|
+
if (this.options.clampWheel !== "x")
|
|
35793
|
+
if (this.parent.screenWorldHeight < this.parent.screenHeight)
|
|
35794
|
+
switch (this.underflowY) {
|
|
35795
|
+
case -1:
|
|
35796
|
+
this.parent.y = 0;
|
|
35797
|
+
break;
|
|
35798
|
+
case 1:
|
|
35799
|
+
this.parent.y = this.parent.screenHeight - this.parent.screenWorldHeight;
|
|
35800
|
+
break;
|
|
35801
|
+
default:
|
|
35802
|
+
this.parent.y = (this.parent.screenHeight - this.parent.screenWorldHeight) / 2;
|
|
35803
|
+
}
|
|
35804
|
+
else
|
|
35805
|
+
this.parent.top < 0 && (this.parent.y = 0, t2.y = 0), this.parent.bottom > this.parent.worldHeight && (this.parent.y = -this.parent.worldHeight * this.parent.scale.y + this.parent.screenHeight, t2.y = 0);
|
|
35806
|
+
}
|
|
35807
|
+
}
|
|
35808
|
+
var F = {
|
|
35809
|
+
speed: 0,
|
|
35810
|
+
acceleration: null,
|
|
35811
|
+
radius: null
|
|
35812
|
+
};
|
|
35813
|
+
|
|
35814
|
+
class B extends u2 {
|
|
35815
|
+
constructor(t2, e2, n2 = {}) {
|
|
35816
|
+
super(t2), this.target = e2, this.options = Object.assign({}, F, n2), this.velocity = { x: 0, y: 0 };
|
|
35817
|
+
}
|
|
35818
|
+
update(t2) {
|
|
35819
|
+
if (this.paused)
|
|
35820
|
+
return;
|
|
35821
|
+
const e2 = this.parent.center;
|
|
35822
|
+
let n2 = this.target.x, i2 = this.target.y;
|
|
35823
|
+
if (this.options.radius)
|
|
35824
|
+
if (Math.sqrt(Math.pow(this.target.y - e2.y, 2) + Math.pow(this.target.x - e2.x, 2)) > this.options.radius) {
|
|
35825
|
+
const r2 = Math.atan2(this.target.y - e2.y, this.target.x - e2.x);
|
|
35826
|
+
n2 = this.target.x - Math.cos(r2) * this.options.radius, i2 = this.target.y - Math.sin(r2) * this.options.radius;
|
|
35827
|
+
} else
|
|
35828
|
+
return;
|
|
35829
|
+
const s2 = n2 - e2.x, h2 = i2 - e2.y;
|
|
35830
|
+
if (s2 || h2)
|
|
35831
|
+
if (this.options.speed)
|
|
35832
|
+
if (this.options.acceleration) {
|
|
35833
|
+
const o2 = Math.atan2(i2 - e2.y, n2 - e2.x), r2 = Math.sqrt(Math.pow(s2, 2) + Math.pow(h2, 2));
|
|
35834
|
+
if (r2) {
|
|
35835
|
+
const a2 = (Math.pow(this.velocity.x, 2) + Math.pow(this.velocity.y, 2)) / (2 * this.options.acceleration);
|
|
35836
|
+
r2 > a2 ? this.velocity = {
|
|
35837
|
+
x: Math.min(this.velocity.x + (this.options.acceleration * t2, this.options.speed)),
|
|
35838
|
+
y: Math.min(this.velocity.y + (this.options.acceleration * t2, this.options.speed))
|
|
35839
|
+
} : this.velocity = {
|
|
35840
|
+
x: Math.max(this.velocity.x - this.options.acceleration * this.options.speed, 0),
|
|
35841
|
+
y: Math.max(this.velocity.y - this.options.acceleration * this.options.speed, 0)
|
|
35842
|
+
};
|
|
35843
|
+
const p2 = Math.cos(o2) * this.velocity.x, f2 = Math.sin(o2) * this.velocity.y, g2 = Math.abs(p2) > Math.abs(s2) ? n2 : e2.x + p2, w2 = Math.abs(f2) > Math.abs(h2) ? i2 : e2.y + f2;
|
|
35844
|
+
this.parent.moveCenter(g2, w2), this.parent.emit("moved", { viewport: this.parent, type: "follow" });
|
|
35845
|
+
}
|
|
35846
|
+
} else {
|
|
35847
|
+
const o2 = Math.atan2(i2 - e2.y, n2 - e2.x), r2 = Math.cos(o2) * this.options.speed, a2 = Math.sin(o2) * this.options.speed, p2 = Math.abs(r2) > Math.abs(s2) ? n2 : e2.x + r2, f2 = Math.abs(a2) > Math.abs(h2) ? i2 : e2.y + a2;
|
|
35848
|
+
this.parent.moveCenter(p2, f2), this.parent.emit("moved", { viewport: this.parent, type: "follow" });
|
|
35849
|
+
}
|
|
35850
|
+
else
|
|
35851
|
+
this.parent.moveCenter(n2, i2), this.parent.emit("moved", { viewport: this.parent, type: "follow" });
|
|
35852
|
+
}
|
|
35853
|
+
}
|
|
35854
|
+
var N2 = {
|
|
35855
|
+
radius: null,
|
|
35856
|
+
distance: null,
|
|
35857
|
+
top: null,
|
|
35858
|
+
bottom: null,
|
|
35859
|
+
left: null,
|
|
35860
|
+
right: null,
|
|
35861
|
+
speed: 8,
|
|
35862
|
+
reverse: false,
|
|
35863
|
+
noDecelerate: false,
|
|
35864
|
+
linear: false,
|
|
35865
|
+
allowButtons: false
|
|
35866
|
+
};
|
|
35867
|
+
|
|
35868
|
+
class V extends u2 {
|
|
35869
|
+
constructor(t2, e2 = {}) {
|
|
35870
|
+
super(t2), this.options = Object.assign({}, N2, e2), this.reverse = this.options.reverse ? 1 : -1, this.radiusSquared = typeof this.options.radius == "number" ? Math.pow(this.options.radius, 2) : null, this.resize();
|
|
35871
|
+
}
|
|
35872
|
+
resize() {
|
|
35873
|
+
const t2 = this.options.distance;
|
|
35874
|
+
t2 !== null ? (this.left = t2, this.top = t2, this.right = this.parent.screenWidth - t2, this.bottom = this.parent.screenHeight - t2) : this.options.radius || (this.left = this.options.left, this.top = this.options.top, this.right = this.options.right === null ? null : this.parent.screenWidth - this.options.right, this.bottom = this.options.bottom === null ? null : this.parent.screenHeight - this.options.bottom);
|
|
35875
|
+
}
|
|
35876
|
+
down() {
|
|
35877
|
+
return this.paused || this.options.allowButtons || (this.horizontal = this.vertical = null), false;
|
|
35878
|
+
}
|
|
35879
|
+
move(t2) {
|
|
35880
|
+
if (this.paused || t2.pointerType !== "mouse" && t2.pointerId !== 1 || !this.options.allowButtons && t2.buttons !== 0)
|
|
35881
|
+
return false;
|
|
35882
|
+
const e2 = t2.global.x, n2 = t2.global.y;
|
|
35883
|
+
if (this.radiusSquared) {
|
|
35884
|
+
const i2 = this.parent.toScreen(this.parent.center);
|
|
35885
|
+
if (Math.pow(i2.x - e2, 2) + Math.pow(i2.y - n2, 2) >= this.radiusSquared) {
|
|
35886
|
+
const h2 = Math.atan2(i2.y - n2, i2.x - e2);
|
|
35887
|
+
this.options.linear ? (this.horizontal = Math.round(Math.cos(h2)) * this.options.speed * this.reverse * (60 / 1000), this.vertical = Math.round(Math.sin(h2)) * this.options.speed * this.reverse * (60 / 1000)) : (this.horizontal = Math.cos(h2) * this.options.speed * this.reverse * (60 / 1000), this.vertical = Math.sin(h2) * this.options.speed * this.reverse * (60 / 1000));
|
|
35888
|
+
} else
|
|
35889
|
+
this.horizontal && this.decelerateHorizontal(), this.vertical && this.decelerateVertical(), this.horizontal = this.vertical = 0;
|
|
35890
|
+
} else
|
|
35891
|
+
this.left !== null && e2 < this.left ? this.horizontal = Number(this.reverse) * this.options.speed * (60 / 1000) : this.right !== null && e2 > this.right ? this.horizontal = -1 * this.reverse * this.options.speed * (60 / 1000) : (this.decelerateHorizontal(), this.horizontal = 0), this.top !== null && n2 < this.top ? this.vertical = Number(this.reverse) * this.options.speed * (60 / 1000) : this.bottom !== null && n2 > this.bottom ? this.vertical = -1 * this.reverse * this.options.speed * (60 / 1000) : (this.decelerateVertical(), this.vertical = 0);
|
|
35892
|
+
return false;
|
|
35893
|
+
}
|
|
35894
|
+
decelerateHorizontal() {
|
|
35895
|
+
const t2 = this.parent.plugins.get("decelerate", true);
|
|
35896
|
+
this.horizontal && t2 && !this.options.noDecelerate && t2.activate({ x: this.horizontal * this.options.speed * this.reverse / (1000 / 60) });
|
|
35897
|
+
}
|
|
35898
|
+
decelerateVertical() {
|
|
35899
|
+
const t2 = this.parent.plugins.get("decelerate", true);
|
|
35900
|
+
this.vertical && t2 && !this.options.noDecelerate && t2.activate({ y: this.vertical * this.options.speed * this.reverse / (1000 / 60) });
|
|
35901
|
+
}
|
|
35902
|
+
up() {
|
|
35903
|
+
return this.paused || (this.horizontal && this.decelerateHorizontal(), this.vertical && this.decelerateVertical(), this.horizontal = this.vertical = null), false;
|
|
35904
|
+
}
|
|
35905
|
+
update() {
|
|
35906
|
+
if (!this.paused && (this.horizontal || this.vertical)) {
|
|
35907
|
+
const t2 = this.parent.center;
|
|
35908
|
+
this.horizontal && (t2.x += this.horizontal * this.options.speed), this.vertical && (t2.y += this.vertical * this.options.speed), this.parent.moveCenter(t2), this.parent.emit("moved", { viewport: this.parent, type: "mouse-edges" });
|
|
35909
|
+
}
|
|
35910
|
+
}
|
|
35911
|
+
}
|
|
35912
|
+
var Z = {
|
|
35913
|
+
noDrag: false,
|
|
35914
|
+
percent: 1,
|
|
35915
|
+
center: null,
|
|
35916
|
+
factor: 1,
|
|
35917
|
+
axis: "all"
|
|
35918
|
+
};
|
|
35919
|
+
var R = new Point;
|
|
35920
|
+
|
|
35921
|
+
class j2 extends u2 {
|
|
35922
|
+
constructor(t2, e2 = {}) {
|
|
35923
|
+
super(t2), this.active = false, this.pinching = false, this.moved = false, this.options = Object.assign({}, Z, e2);
|
|
35924
|
+
}
|
|
35925
|
+
down() {
|
|
35926
|
+
return this.parent.input.count() >= 2 ? (this.active = true, true) : false;
|
|
35927
|
+
}
|
|
35928
|
+
isAxisX() {
|
|
35929
|
+
return ["all", "x"].includes(this.options.axis);
|
|
35930
|
+
}
|
|
35931
|
+
isAxisY() {
|
|
35932
|
+
return ["all", "y"].includes(this.options.axis);
|
|
35933
|
+
}
|
|
35934
|
+
move(t2) {
|
|
35935
|
+
if (this.paused || !this.active)
|
|
35936
|
+
return false;
|
|
35937
|
+
const { x: e2, y: n2 } = (this.parent.parent || this.parent).toLocal(t2.global, undefined, R), i2 = this.parent.input.touches;
|
|
35938
|
+
if (i2.length >= 2) {
|
|
35939
|
+
const s2 = i2[0], h2 = i2[1], o2 = s2.last && h2.last ? Math.sqrt(Math.pow(h2.last.x - s2.last.x, 2) + Math.pow(h2.last.y - s2.last.y, 2)) : null;
|
|
35940
|
+
if (s2.id === t2.pointerId ? s2.last = { x: e2, y: n2, data: t2 } : h2.id === t2.pointerId && (h2.last = { x: e2, y: n2, data: t2 }), o2) {
|
|
35941
|
+
let r2;
|
|
35942
|
+
const a2 = new Point(s2.last.x + (h2.last.x - s2.last.x) / 2, s2.last.y + (h2.last.y - s2.last.y) / 2);
|
|
35943
|
+
this.options.center || (r2 = this.parent.toLocal(a2, this.parent.parent || this.parent));
|
|
35944
|
+
let p2 = Math.sqrt(Math.pow(h2.last.x - s2.last.x, 2) + Math.pow(h2.last.y - s2.last.y, 2));
|
|
35945
|
+
p2 = p2 === 0 ? p2 = 0.0000000001 : p2;
|
|
35946
|
+
const f2 = (1 - o2 / p2) * this.options.percent * (this.isAxisX() ? this.parent.scale.x : this.parent.scale.y);
|
|
35947
|
+
this.isAxisX() && (this.parent.scale.x += f2), this.isAxisY() && (this.parent.scale.y += f2), this.parent.emit("zoomed", {
|
|
35948
|
+
viewport: this.parent,
|
|
35949
|
+
type: "pinch",
|
|
35950
|
+
center: a2
|
|
35951
|
+
});
|
|
35952
|
+
const g2 = this.parent.plugins.get("clamp-zoom", true);
|
|
35953
|
+
if (g2 && g2.clamp(), this.options.center)
|
|
35954
|
+
this.parent.moveCenter(this.options.center);
|
|
35955
|
+
else {
|
|
35956
|
+
const w2 = (this.parent.parent || this.parent).toLocal(r2, this.parent);
|
|
35957
|
+
this.parent.x += (a2.x - w2.x) * this.options.factor, this.parent.y += (a2.y - w2.y) * this.options.factor, this.parent.emit("moved", { viewport: this.parent, type: "pinch" });
|
|
35958
|
+
}
|
|
35959
|
+
!this.options.noDrag && this.lastCenter && (this.parent.x += (a2.x - this.lastCenter.x) * this.options.factor, this.parent.y += (a2.y - this.lastCenter.y) * this.options.factor, this.parent.emit("moved", { viewport: this.parent, type: "pinch" })), this.lastCenter = a2, this.moved = true;
|
|
35960
|
+
} else
|
|
35961
|
+
this.pinching || (this.parent.emit("pinch-start", this.parent), this.pinching = true);
|
|
35962
|
+
return true;
|
|
35963
|
+
}
|
|
35964
|
+
return false;
|
|
35965
|
+
}
|
|
35966
|
+
up() {
|
|
35967
|
+
return this.pinching && this.parent.input.touches.length <= 1 ? (this.active = false, this.lastCenter = null, this.pinching = false, this.moved = false, this.parent.emit("pinch-end", this.parent), true) : false;
|
|
35968
|
+
}
|
|
35969
|
+
}
|
|
35970
|
+
var K = {
|
|
35971
|
+
topLeft: false,
|
|
35972
|
+
friction: 0.8,
|
|
35973
|
+
time: 1000,
|
|
35974
|
+
ease: "easeInOutSine",
|
|
35975
|
+
interrupt: true,
|
|
35976
|
+
removeOnComplete: false,
|
|
35977
|
+
removeOnInterrupt: false,
|
|
35978
|
+
forceStart: false
|
|
35979
|
+
};
|
|
35980
|
+
|
|
35981
|
+
class q extends u2 {
|
|
35982
|
+
constructor(t2, e2, n2, i2 = {}) {
|
|
35983
|
+
super(t2), this.options = Object.assign({}, K, i2), this.ease = x2(i2.ease, "easeInOutSine"), this.x = e2, this.y = n2, this.options.forceStart && this.snapStart();
|
|
35984
|
+
}
|
|
35985
|
+
snapStart() {
|
|
35986
|
+
this.percent = 0, this.snapping = { time: 0 };
|
|
35987
|
+
const t2 = this.options.topLeft ? this.parent.corner : this.parent.center;
|
|
35988
|
+
this.deltaX = this.x - t2.x, this.deltaY = this.y - t2.y, this.startX = t2.x, this.startY = t2.y, this.parent.emit("snap-start", this.parent);
|
|
35989
|
+
}
|
|
35990
|
+
wheel() {
|
|
35991
|
+
return this.options.removeOnInterrupt && this.parent.plugins.remove("snap"), false;
|
|
35992
|
+
}
|
|
35993
|
+
down() {
|
|
35994
|
+
return this.options.removeOnInterrupt ? this.parent.plugins.remove("snap") : this.options.interrupt && (this.snapping = null), false;
|
|
35995
|
+
}
|
|
35996
|
+
up() {
|
|
35997
|
+
if (this.parent.input.count() === 0) {
|
|
35998
|
+
const t2 = this.parent.plugins.get("decelerate", true);
|
|
35999
|
+
t2 && (t2.x || t2.y) && (t2.percentChangeX = t2.percentChangeY = this.options.friction);
|
|
36000
|
+
}
|
|
36001
|
+
return false;
|
|
36002
|
+
}
|
|
36003
|
+
update(t2) {
|
|
36004
|
+
if (!this.paused && !(this.options.interrupt && this.parent.input.count() !== 0))
|
|
36005
|
+
if (this.snapping) {
|
|
36006
|
+
const e2 = this.snapping;
|
|
36007
|
+
e2.time += t2;
|
|
36008
|
+
let n2, i2, s2;
|
|
36009
|
+
const h2 = this.startX, o2 = this.startY, r2 = this.deltaX, a2 = this.deltaY;
|
|
36010
|
+
if (e2.time > this.options.time)
|
|
36011
|
+
n2 = true, i2 = h2 + r2, s2 = o2 + a2;
|
|
36012
|
+
else {
|
|
36013
|
+
const p2 = this.ease(e2.time, 0, 1, this.options.time);
|
|
36014
|
+
i2 = h2 + r2 * p2, s2 = o2 + a2 * p2;
|
|
36015
|
+
}
|
|
36016
|
+
this.options.topLeft ? this.parent.moveCorner(i2, s2) : this.parent.moveCenter(i2, s2), this.parent.emit("moved", { viewport: this.parent, type: "snap" }), n2 && (this.options.removeOnComplete && this.parent.plugins.remove("snap"), this.parent.emit("snap-end", this.parent), this.snapping = null);
|
|
36017
|
+
} else {
|
|
36018
|
+
const e2 = this.options.topLeft ? this.parent.corner : this.parent.center;
|
|
36019
|
+
(e2.x !== this.x || e2.y !== this.y) && this.snapStart();
|
|
36020
|
+
}
|
|
36021
|
+
}
|
|
36022
|
+
}
|
|
36023
|
+
var Q = {
|
|
36024
|
+
width: 0,
|
|
36025
|
+
height: 0,
|
|
36026
|
+
time: 1000,
|
|
36027
|
+
ease: "easeInOutSine",
|
|
36028
|
+
center: null,
|
|
36029
|
+
interrupt: true,
|
|
36030
|
+
removeOnComplete: false,
|
|
36031
|
+
removeOnInterrupt: false,
|
|
36032
|
+
forceStart: false,
|
|
36033
|
+
noMove: false
|
|
36034
|
+
};
|
|
36035
|
+
|
|
36036
|
+
class G extends u2 {
|
|
36037
|
+
constructor(t2, e2 = {}) {
|
|
36038
|
+
super(t2), this.options = Object.assign({}, Q, e2), this.ease = x2(this.options.ease), this.xIndependent = false, this.yIndependent = false, this.xScale = 0, this.yScale = 0, this.options.width > 0 && (this.xScale = t2.screenWidth / this.options.width, this.xIndependent = true), this.options.height > 0 && (this.yScale = t2.screenHeight / this.options.height, this.yIndependent = true), this.xScale = this.xIndependent ? this.xScale : this.yScale, this.yScale = this.yIndependent ? this.yScale : this.xScale, this.options.time === 0 ? (t2.container.scale.x = this.xScale, t2.container.scale.y = this.yScale, this.options.removeOnComplete && this.parent.plugins.remove("snap-zoom")) : e2.forceStart && this.createSnapping();
|
|
36039
|
+
}
|
|
36040
|
+
createSnapping() {
|
|
36041
|
+
const t2 = this.parent.worldScreenWidth, e2 = this.parent.worldScreenHeight, n2 = this.parent.screenWidth / this.xScale, i2 = this.parent.screenHeight / this.yScale;
|
|
36042
|
+
this.snapping = {
|
|
36043
|
+
time: 0,
|
|
36044
|
+
startX: t2,
|
|
36045
|
+
startY: e2,
|
|
36046
|
+
deltaX: n2 - t2,
|
|
36047
|
+
deltaY: i2 - e2
|
|
36048
|
+
}, this.parent.emit("snap-zoom-start", this.parent);
|
|
36049
|
+
}
|
|
36050
|
+
resize() {
|
|
36051
|
+
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;
|
|
36052
|
+
}
|
|
36053
|
+
wheel() {
|
|
36054
|
+
return this.options.removeOnInterrupt && this.parent.plugins.remove("snap-zoom"), false;
|
|
36055
|
+
}
|
|
36056
|
+
down() {
|
|
36057
|
+
return this.options.removeOnInterrupt ? this.parent.plugins.remove("snap-zoom") : this.options.interrupt && (this.snapping = null), false;
|
|
36058
|
+
}
|
|
36059
|
+
update(t2) {
|
|
36060
|
+
if (this.paused || this.options.interrupt && this.parent.input.count() !== 0)
|
|
36061
|
+
return;
|
|
36062
|
+
let e2;
|
|
36063
|
+
if (!this.options.center && !this.options.noMove && (e2 = this.parent.center), !this.snapping)
|
|
36064
|
+
(this.parent.scale.x !== this.xScale || this.parent.scale.y !== this.yScale) && this.createSnapping();
|
|
36065
|
+
else if (this.snapping) {
|
|
36066
|
+
const n2 = this.snapping;
|
|
36067
|
+
if (n2.time += t2, n2.time >= this.options.time)
|
|
36068
|
+
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;
|
|
36069
|
+
else {
|
|
36070
|
+
const s2 = this.snapping, h2 = this.ease(s2.time, s2.startX, s2.deltaX, this.options.time), o2 = this.ease(s2.time, s2.startY, s2.deltaY, this.options.time);
|
|
36071
|
+
this.parent.scale.x = this.parent.screenWidth / h2, this.parent.scale.y = this.parent.screenHeight / o2;
|
|
36072
|
+
}
|
|
36073
|
+
const i2 = this.parent.plugins.get("clamp-zoom", true);
|
|
36074
|
+
i2 && i2.clamp(), this.options.noMove || (this.options.center ? this.parent.moveCenter(this.options.center) : this.parent.moveCenter(e2));
|
|
36075
|
+
}
|
|
36076
|
+
}
|
|
36077
|
+
resume() {
|
|
36078
|
+
this.snapping = null, super.resume();
|
|
36079
|
+
}
|
|
36080
|
+
}
|
|
36081
|
+
var J = {
|
|
36082
|
+
percent: 0.1,
|
|
36083
|
+
smooth: false,
|
|
36084
|
+
interrupt: true,
|
|
36085
|
+
reverse: false,
|
|
36086
|
+
center: null,
|
|
36087
|
+
lineHeight: 20,
|
|
36088
|
+
axis: "all",
|
|
36089
|
+
keyToPress: null,
|
|
36090
|
+
trackpadPinch: false,
|
|
36091
|
+
wheelZoom: true
|
|
36092
|
+
};
|
|
36093
|
+
|
|
36094
|
+
class $2 extends u2 {
|
|
36095
|
+
constructor(t2, e2 = {}) {
|
|
36096
|
+
super(t2), this.options = Object.assign({}, J, e2), this.keyIsPressed = false, this.options.keyToPress && this.handleKeyPresses(this.options.keyToPress);
|
|
36097
|
+
}
|
|
36098
|
+
handleKeyPresses(t2) {
|
|
36099
|
+
typeof window > "u" || (window.addEventListener("keydown", (e2) => {
|
|
36100
|
+
t2.includes(e2.code) && (this.keyIsPressed = true);
|
|
36101
|
+
}), window.addEventListener("keyup", (e2) => {
|
|
36102
|
+
t2.includes(e2.code) && (this.keyIsPressed = false);
|
|
36103
|
+
}));
|
|
36104
|
+
}
|
|
36105
|
+
checkKeyPress() {
|
|
36106
|
+
return !this.options.keyToPress || this.keyIsPressed;
|
|
36107
|
+
}
|
|
36108
|
+
down() {
|
|
36109
|
+
return this.options.interrupt && (this.smoothing = null), false;
|
|
36110
|
+
}
|
|
36111
|
+
isAxisX() {
|
|
36112
|
+
return ["all", "x"].includes(this.options.axis);
|
|
36113
|
+
}
|
|
36114
|
+
isAxisY() {
|
|
36115
|
+
return ["all", "y"].includes(this.options.axis);
|
|
36116
|
+
}
|
|
36117
|
+
update() {
|
|
36118
|
+
if (this.smoothing) {
|
|
36119
|
+
const t2 = this.smoothingCenter, e2 = this.smoothing;
|
|
36120
|
+
let n2;
|
|
36121
|
+
this.options.center || (n2 = this.parent.toLocal(t2)), this.isAxisX() && (this.parent.scale.x += e2.x), this.isAxisY() && (this.parent.scale.y += e2.y), this.parent.emit("zoomed", { viewport: this.parent, type: "wheel" });
|
|
36122
|
+
const i2 = this.parent.plugins.get("clamp-zoom", true);
|
|
36123
|
+
if (i2 && i2.clamp(), this.options.center)
|
|
36124
|
+
this.parent.moveCenter(this.options.center);
|
|
36125
|
+
else {
|
|
36126
|
+
const s2 = this.parent.parent || this.parent;
|
|
36127
|
+
s2.toLocal(n2, this.parent, n2);
|
|
36128
|
+
const h2 = s2.toLocal(t2);
|
|
36129
|
+
this.parent.x += h2.x - n2.x, this.parent.y += h2.y - n2.y;
|
|
36130
|
+
}
|
|
36131
|
+
this.parent.emit("moved", { viewport: this.parent, type: "wheel" }), this.smoothingCount++, typeof this.options.smooth == "number" && this.smoothingCount >= this.options.smooth && (this.smoothing = null);
|
|
36132
|
+
}
|
|
36133
|
+
}
|
|
36134
|
+
pinch(t2) {
|
|
36135
|
+
if (this.paused)
|
|
36136
|
+
return;
|
|
36137
|
+
const e2 = this.parent.input.getPointerPosition(t2), n2 = -t2.deltaY * (t2.deltaMode ? this.options.lineHeight : 1) / 200, i2 = Math.pow(2, (1 + this.options.percent) * n2);
|
|
36138
|
+
let s2;
|
|
36139
|
+
this.options.center || (s2 = this.parent.toLocal(e2)), this.isAxisX() && (this.parent.scale.x *= i2), this.isAxisY() && (this.parent.scale.y *= i2), this.parent.emit("zoomed", { viewport: this.parent, type: "wheel" });
|
|
36140
|
+
const h2 = this.parent.plugins.get("clamp-zoom", true);
|
|
36141
|
+
if (h2 && h2.clamp(), this.options.center)
|
|
36142
|
+
this.parent.moveCenter(this.options.center);
|
|
36143
|
+
else {
|
|
36144
|
+
const o2 = this.parent.parent || this.parent;
|
|
36145
|
+
o2.toLocal(s2, this.parent, s2);
|
|
36146
|
+
const r2 = o2.toLocal(e2);
|
|
36147
|
+
this.parent.x += r2.x - s2.x, this.parent.y += r2.y - s2.y;
|
|
36148
|
+
}
|
|
36149
|
+
this.parent.emit("moved", { viewport: this.parent, type: "wheel" }), this.parent.emit("wheel-start", { event: t2, viewport: this.parent });
|
|
36150
|
+
}
|
|
36151
|
+
wheel(t2) {
|
|
36152
|
+
if (this.paused || !this.checkKeyPress())
|
|
36153
|
+
return false;
|
|
36154
|
+
if (t2.ctrlKey && this.options.trackpadPinch)
|
|
36155
|
+
this.pinch(t2);
|
|
36156
|
+
else if (this.options.wheelZoom) {
|
|
36157
|
+
const e2 = this.parent.input.getPointerPosition(t2), i2 = (this.options.reverse ? -1 : 1) * -t2.deltaY * (t2.deltaMode ? this.options.lineHeight : 1) / 500, s2 = Math.pow(2, (1 + this.options.percent) * i2);
|
|
36158
|
+
if (this.options.smooth) {
|
|
36159
|
+
const h2 = {
|
|
36160
|
+
x: this.smoothing ? this.smoothing.x * (this.options.smooth - this.smoothingCount) : 0,
|
|
36161
|
+
y: this.smoothing ? this.smoothing.y * (this.options.smooth - this.smoothingCount) : 0
|
|
36162
|
+
};
|
|
36163
|
+
this.smoothing = {
|
|
36164
|
+
x: ((this.parent.scale.x + h2.x) * s2 - this.parent.scale.x) / this.options.smooth,
|
|
36165
|
+
y: ((this.parent.scale.y + h2.y) * s2 - this.parent.scale.y) / this.options.smooth
|
|
36166
|
+
}, this.smoothingCount = 0, this.smoothingCenter = e2;
|
|
36167
|
+
} else {
|
|
36168
|
+
let h2;
|
|
36169
|
+
this.options.center || (h2 = this.parent.toLocal(e2)), this.isAxisX() && (this.parent.scale.x *= s2), this.isAxisY() && (this.parent.scale.y *= s2), this.parent.emit("zoomed", { viewport: this.parent, type: "wheel" });
|
|
36170
|
+
const o2 = this.parent.plugins.get("clamp-zoom", true);
|
|
36171
|
+
if (o2 && o2.clamp(), this.options.center)
|
|
36172
|
+
this.parent.moveCenter(this.options.center);
|
|
36173
|
+
else {
|
|
36174
|
+
const r2 = this.parent.parent || this.parent;
|
|
36175
|
+
r2.toLocal(h2, this.parent, h2);
|
|
36176
|
+
const a2 = r2.toLocal(e2);
|
|
36177
|
+
this.parent.x += a2.x - h2.x, this.parent.y += a2.y - h2.y;
|
|
36178
|
+
}
|
|
36179
|
+
}
|
|
36180
|
+
this.parent.emit("moved", { viewport: this.parent, type: "wheel" }), this.parent.emit("wheel-start", { event: t2, viewport: this.parent });
|
|
36181
|
+
}
|
|
36182
|
+
return !this.parent.options.passiveWheel;
|
|
36183
|
+
}
|
|
36184
|
+
}
|
|
36185
|
+
var tt = {
|
|
36186
|
+
screenWidth: typeof window > "u" ? 0 : window.innerWidth,
|
|
36187
|
+
screenHeight: typeof window > "u" ? 0 : window.innerHeight,
|
|
36188
|
+
worldWidth: null,
|
|
36189
|
+
worldHeight: null,
|
|
36190
|
+
threshold: 5,
|
|
36191
|
+
passiveWheel: true,
|
|
36192
|
+
stopPropagation: false,
|
|
36193
|
+
forceHitArea: null,
|
|
36194
|
+
noTicker: false,
|
|
36195
|
+
disableOnContextMenu: false,
|
|
36196
|
+
ticker: Ticker.shared,
|
|
36197
|
+
allowPreserveDragOutside: false
|
|
36198
|
+
};
|
|
36199
|
+
|
|
36200
|
+
class it extends Container {
|
|
36201
|
+
constructor(t2) {
|
|
36202
|
+
super(), this._disableOnContextMenu = (e2) => e2.preventDefault(), this.options = {
|
|
36203
|
+
...tt,
|
|
36204
|
+
...t2
|
|
36205
|
+
}, 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.disableOnContextMenu && this.options.events.domElement.addEventListener("contextmenu", this._disableOnContextMenu), this.options.noTicker || (this.tickerFunction = () => this.update(this.options.ticker.elapsedMS), this.options.ticker.add(this.tickerFunction)), this.input = new P(this), this.plugins = new C(this);
|
|
36206
|
+
}
|
|
36207
|
+
destroy(t2) {
|
|
36208
|
+
var e2;
|
|
36209
|
+
!this.options.noTicker && this.tickerFunction && this.options.ticker.remove(this.tickerFunction), this.options.disableOnContextMenu && ((e2 = this.options.events.domElement) == null || e2.removeEventListener("contextmenu", this._disableOnContextMenu)), this.input.destroy(), super.destroy(t2);
|
|
36210
|
+
}
|
|
36211
|
+
update(t2) {
|
|
36212
|
+
this.pause || (this.plugins.update(t2), this.lastViewport && (this.lastViewport.x !== this.x || this.lastViewport.y !== this.y ? this.moving = true : this.moving && (this.emit("moved-end", this), this.moving = false), this.lastViewport.scaleX !== this.scale.x || this.lastViewport.scaleY !== this.scale.y ? this.zooming = true : this.zooming && (this.emit("zoomed-end", this), this.zooming = false)), this.forceHitArea || (this._hitAreaDefault = new 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 = {
|
|
36213
|
+
x: this.x,
|
|
36214
|
+
y: this.y,
|
|
36215
|
+
scaleX: this.scale.x,
|
|
36216
|
+
scaleY: this.scale.y
|
|
36217
|
+
}, this.emit("frame-end", this));
|
|
36218
|
+
}
|
|
36219
|
+
resize(t2 = typeof window > "u" ? 0 : window.innerWidth, e2 = typeof window > "u" ? 0 : window.innerHeight, n2, i2) {
|
|
36220
|
+
this.screenWidth = t2, this.screenHeight = e2, typeof n2 < "u" && (this._worldWidth = n2), typeof i2 < "u" && (this._worldHeight = i2), this.plugins.resize(), this.dirty = true;
|
|
36221
|
+
}
|
|
36222
|
+
get worldWidth() {
|
|
36223
|
+
return this._worldWidth ? this._worldWidth : this.width / this.scale.x;
|
|
36224
|
+
}
|
|
36225
|
+
set worldWidth(t2) {
|
|
36226
|
+
this._worldWidth = t2, this.plugins.resize();
|
|
36227
|
+
}
|
|
36228
|
+
get worldHeight() {
|
|
36229
|
+
return this._worldHeight ? this._worldHeight : this.height / this.scale.y;
|
|
36230
|
+
}
|
|
36231
|
+
set worldHeight(t2) {
|
|
36232
|
+
this._worldHeight = t2, this.plugins.resize();
|
|
36233
|
+
}
|
|
36234
|
+
getVisibleBounds() {
|
|
36235
|
+
return new Rectangle(this.left, this.top, this.worldScreenWidth, this.worldScreenHeight);
|
|
36236
|
+
}
|
|
36237
|
+
toWorld(t2, e2) {
|
|
36238
|
+
return arguments.length === 2 ? this.toLocal(new Point(t2, e2)) : this.toLocal(t2);
|
|
36239
|
+
}
|
|
36240
|
+
toScreen(t2, e2) {
|
|
36241
|
+
return arguments.length === 2 ? this.toGlobal(new Point(t2, e2)) : this.toGlobal(t2);
|
|
36242
|
+
}
|
|
36243
|
+
get worldScreenWidth() {
|
|
36244
|
+
return this.screenWidth / this.scale.x;
|
|
36245
|
+
}
|
|
36246
|
+
get worldScreenHeight() {
|
|
36247
|
+
return this.screenHeight / this.scale.y;
|
|
36248
|
+
}
|
|
36249
|
+
get screenWorldWidth() {
|
|
36250
|
+
return this.worldWidth * this.scale.x;
|
|
36251
|
+
}
|
|
36252
|
+
get screenWorldHeight() {
|
|
36253
|
+
return this.worldHeight * this.scale.y;
|
|
36254
|
+
}
|
|
36255
|
+
get center() {
|
|
36256
|
+
return new Point(this.worldScreenWidth / 2 - this.x / this.scale.x, this.worldScreenHeight / 2 - this.y / this.scale.y);
|
|
36257
|
+
}
|
|
36258
|
+
set center(t2) {
|
|
36259
|
+
this.moveCenter(t2);
|
|
36260
|
+
}
|
|
36261
|
+
moveCenter(...t2) {
|
|
36262
|
+
let e2, n2;
|
|
36263
|
+
typeof t2[0] == "number" ? (e2 = t2[0], n2 = t2[1]) : (e2 = t2[0].x, n2 = t2[0].y);
|
|
36264
|
+
const i2 = (this.worldScreenWidth / 2 - e2) * this.scale.x, s2 = (this.worldScreenHeight / 2 - n2) * this.scale.y;
|
|
36265
|
+
return (this.x !== i2 || this.y !== s2) && (this.position.set(i2, s2), this.plugins.reset(), this.dirty = true), this;
|
|
36266
|
+
}
|
|
36267
|
+
get corner() {
|
|
36268
|
+
return new Point(-this.x / this.scale.x, -this.y / this.scale.y);
|
|
36269
|
+
}
|
|
36270
|
+
set corner(t2) {
|
|
36271
|
+
this.moveCorner(t2);
|
|
36272
|
+
}
|
|
36273
|
+
moveCorner(...t2) {
|
|
36274
|
+
let e2, n2;
|
|
36275
|
+
return t2.length === 1 ? (e2 = -t2[0].x * this.scale.x, n2 = -t2[0].y * this.scale.y) : (e2 = -t2[0] * this.scale.x, n2 = -t2[1] * this.scale.y), (e2 !== this.x || n2 !== this.y) && (this.position.set(e2, n2), this.plugins.reset(), this.dirty = true), this;
|
|
36276
|
+
}
|
|
36277
|
+
get screenWidthInWorldPixels() {
|
|
36278
|
+
return this.screenWidth / this.scale.x;
|
|
36279
|
+
}
|
|
36280
|
+
get screenHeightInWorldPixels() {
|
|
36281
|
+
return this.screenHeight / this.scale.y;
|
|
36282
|
+
}
|
|
36283
|
+
findFitWidth(t2) {
|
|
36284
|
+
return this.screenWidth / t2;
|
|
36285
|
+
}
|
|
36286
|
+
findFitHeight(t2) {
|
|
36287
|
+
return this.screenHeight / t2;
|
|
36288
|
+
}
|
|
36289
|
+
findFit(t2, e2) {
|
|
36290
|
+
const n2 = this.screenWidth / t2, i2 = this.screenHeight / e2;
|
|
36291
|
+
return Math.min(n2, i2);
|
|
36292
|
+
}
|
|
36293
|
+
findCover(t2, e2) {
|
|
36294
|
+
const n2 = this.screenWidth / t2, i2 = this.screenHeight / e2;
|
|
36295
|
+
return Math.max(n2, i2);
|
|
36296
|
+
}
|
|
36297
|
+
fitWidth(t2 = this.worldWidth, e2, n2 = true, i2) {
|
|
36298
|
+
let s2;
|
|
36299
|
+
e2 && (s2 = this.center), this.scale.x = this.screenWidth / t2, n2 && (this.scale.y = this.scale.x);
|
|
36300
|
+
const h2 = this.plugins.get("clamp-zoom", true);
|
|
36301
|
+
return !i2 && h2 && h2.clamp(), e2 && s2 && this.moveCenter(s2), this;
|
|
36302
|
+
}
|
|
36303
|
+
fitHeight(t2 = this.worldHeight, e2, n2 = true, i2) {
|
|
36304
|
+
let s2;
|
|
36305
|
+
e2 && (s2 = this.center), this.scale.y = this.screenHeight / t2, n2 && (this.scale.x = this.scale.y);
|
|
36306
|
+
const h2 = this.plugins.get("clamp-zoom", true);
|
|
36307
|
+
return !i2 && h2 && h2.clamp(), e2 && s2 && this.moveCenter(s2), this;
|
|
36308
|
+
}
|
|
36309
|
+
fitWorld(t2) {
|
|
36310
|
+
let e2;
|
|
36311
|
+
t2 && (e2 = 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;
|
|
36312
|
+
const n2 = this.plugins.get("clamp-zoom", true);
|
|
36313
|
+
return n2 && n2.clamp(), t2 && e2 && this.moveCenter(e2), this;
|
|
36314
|
+
}
|
|
36315
|
+
fit(t2, e2 = this.worldWidth, n2 = this.worldHeight) {
|
|
36316
|
+
let i2;
|
|
36317
|
+
t2 && (i2 = this.center), this.scale.x = this.screenWidth / e2, this.scale.y = this.screenHeight / n2, this.scale.x < this.scale.y ? this.scale.y = this.scale.x : this.scale.x = this.scale.y;
|
|
36318
|
+
const s2 = this.plugins.get("clamp-zoom", true);
|
|
36319
|
+
return s2 && s2.clamp(), t2 && i2 && this.moveCenter(i2), this;
|
|
36320
|
+
}
|
|
36321
|
+
setZoom(t2, e2) {
|
|
36322
|
+
let n2;
|
|
36323
|
+
e2 && (n2 = this.center), this.scale.set(t2);
|
|
36324
|
+
const i2 = this.plugins.get("clamp-zoom", true);
|
|
36325
|
+
return i2 && i2.clamp(), e2 && n2 && this.moveCenter(n2), this;
|
|
36326
|
+
}
|
|
36327
|
+
zoomPercent(t2, e2) {
|
|
36328
|
+
return this.setZoom(this.scale.x + this.scale.x * t2, e2);
|
|
36329
|
+
}
|
|
36330
|
+
zoom(t2, e2) {
|
|
36331
|
+
return this.fitWidth(t2 + this.worldScreenWidth, e2), this;
|
|
36332
|
+
}
|
|
36333
|
+
get scaled() {
|
|
36334
|
+
return this.scale.x;
|
|
36335
|
+
}
|
|
36336
|
+
set scaled(t2) {
|
|
36337
|
+
this.setZoom(t2, true);
|
|
36338
|
+
}
|
|
36339
|
+
snapZoom(t2) {
|
|
36340
|
+
return this.plugins.add("snap-zoom", new G(this, t2)), this;
|
|
36341
|
+
}
|
|
36342
|
+
OOB() {
|
|
36343
|
+
return {
|
|
36344
|
+
left: this.left < 0,
|
|
36345
|
+
right: this.right > this.worldWidth,
|
|
36346
|
+
top: this.top < 0,
|
|
36347
|
+
bottom: this.bottom > this.worldHeight,
|
|
36348
|
+
cornerPoint: new Point(this.worldWidth * this.scale.x - this.screenWidth, this.worldHeight * this.scale.y - this.screenHeight)
|
|
36349
|
+
};
|
|
36350
|
+
}
|
|
36351
|
+
get right() {
|
|
36352
|
+
return -this.x / this.scale.x + this.worldScreenWidth;
|
|
36353
|
+
}
|
|
36354
|
+
set right(t2) {
|
|
36355
|
+
this.x = -t2 * this.scale.x + this.screenWidth, this.plugins.reset();
|
|
36356
|
+
}
|
|
36357
|
+
get left() {
|
|
36358
|
+
return -this.x / this.scale.x;
|
|
36359
|
+
}
|
|
36360
|
+
set left(t2) {
|
|
36361
|
+
this.x = -t2 * this.scale.x, this.plugins.reset();
|
|
36362
|
+
}
|
|
36363
|
+
get top() {
|
|
36364
|
+
return -this.y / this.scale.y;
|
|
36365
|
+
}
|
|
36366
|
+
set top(t2) {
|
|
36367
|
+
this.y = -t2 * this.scale.y, this.plugins.reset();
|
|
36368
|
+
}
|
|
36369
|
+
get bottom() {
|
|
36370
|
+
return -this.y / this.scale.y + this.worldScreenHeight;
|
|
36371
|
+
}
|
|
36372
|
+
set bottom(t2) {
|
|
36373
|
+
this.y = -t2 * this.scale.y + this.screenHeight, this.plugins.reset();
|
|
36374
|
+
}
|
|
36375
|
+
get dirty() {
|
|
36376
|
+
return !!this._dirty;
|
|
36377
|
+
}
|
|
36378
|
+
set dirty(t2) {
|
|
36379
|
+
this._dirty = t2;
|
|
36380
|
+
}
|
|
36381
|
+
get forceHitArea() {
|
|
36382
|
+
return this._forceHitArea;
|
|
36383
|
+
}
|
|
36384
|
+
set forceHitArea(t2) {
|
|
36385
|
+
t2 ? (this._forceHitArea = t2, this.hitArea = t2) : (this._forceHitArea = null, this.hitArea = new Rectangle(0, 0, this.worldWidth, this.worldHeight));
|
|
36386
|
+
}
|
|
36387
|
+
drag(t2) {
|
|
36388
|
+
return this.plugins.add("drag", new U(this, t2)), this;
|
|
36389
|
+
}
|
|
36390
|
+
clamp(t2) {
|
|
36391
|
+
return this.plugins.add("clamp", new A(this, t2)), this;
|
|
36392
|
+
}
|
|
36393
|
+
decelerate(t2) {
|
|
36394
|
+
return this.plugins.add("decelerate", new E(this, t2)), this;
|
|
36395
|
+
}
|
|
36396
|
+
bounce(t2) {
|
|
36397
|
+
return this.plugins.add("bounce", new X(this, t2)), this;
|
|
36398
|
+
}
|
|
36399
|
+
pinch(t2) {
|
|
36400
|
+
return this.plugins.add("pinch", new j2(this, t2)), this;
|
|
36401
|
+
}
|
|
36402
|
+
snap(t2, e2, n2) {
|
|
36403
|
+
return this.plugins.add("snap", new q(this, t2, e2, n2)), this;
|
|
36404
|
+
}
|
|
36405
|
+
follow(t2, e2) {
|
|
36406
|
+
return this.plugins.add("follow", new B(this, t2, e2)), this;
|
|
36407
|
+
}
|
|
36408
|
+
wheel(t2) {
|
|
36409
|
+
return this.plugins.add("wheel", new $2(this, t2)), this;
|
|
36410
|
+
}
|
|
36411
|
+
animate(t2) {
|
|
36412
|
+
return this.plugins.add("animate", new k2(this, t2)), this;
|
|
36413
|
+
}
|
|
36414
|
+
clampZoom(t2) {
|
|
36415
|
+
return this.plugins.add("clamp-zoom", new _(this, t2)), this;
|
|
36416
|
+
}
|
|
36417
|
+
mouseEdges(t2) {
|
|
36418
|
+
return this.plugins.add("mouse-edges", new V(this, t2)), this;
|
|
36419
|
+
}
|
|
36420
|
+
get pause() {
|
|
36421
|
+
return !!this._pause;
|
|
36422
|
+
}
|
|
36423
|
+
set pause(t2) {
|
|
36424
|
+
this._pause = t2, this.lastViewport = null, this.moving = false, this.zooming = false, t2 && this.input.pause();
|
|
36425
|
+
}
|
|
36426
|
+
ensureVisible(t2, e2, n2, i2, s2) {
|
|
36427
|
+
s2 && (n2 > this.worldScreenWidth || i2 > this.worldScreenHeight) && (this.fit(true, n2, i2), this.emit("zoomed", { viewport: this, type: "ensureVisible" }));
|
|
36428
|
+
let h2 = false;
|
|
36429
|
+
t2 < this.left ? (this.left = t2, h2 = true) : t2 + n2 > this.right && (this.right = t2 + n2, h2 = true), e2 < this.top ? (this.top = e2, h2 = true) : e2 + i2 > this.bottom && (this.bottom = e2 + i2, h2 = true), h2 && this.emit("moved", { viewport: this, type: "ensureVisible" });
|
|
36430
|
+
}
|
|
36431
|
+
}
|
|
36432
|
+
|
|
36433
|
+
// src/plugins/ViewportPlugin.ts
|
|
36434
|
+
var DEFAULTS2 = {
|
|
36435
|
+
worldWidth: 0,
|
|
36436
|
+
worldHeight: 0,
|
|
36437
|
+
minScale: 0.1,
|
|
36438
|
+
maxScale: 10,
|
|
36439
|
+
drag: true,
|
|
36440
|
+
pinch: true,
|
|
36441
|
+
wheel: true,
|
|
36442
|
+
decelerate: true
|
|
36443
|
+
};
|
|
36444
|
+
|
|
36445
|
+
class ViewportPlugin {
|
|
36446
|
+
name = "viewport";
|
|
36447
|
+
options;
|
|
36448
|
+
engine;
|
|
36449
|
+
_viewport;
|
|
36450
|
+
constructor(options) {
|
|
36451
|
+
this.options = { ...DEFAULTS2, ...options };
|
|
36452
|
+
}
|
|
36453
|
+
get viewport() {
|
|
36454
|
+
return this._viewport;
|
|
36455
|
+
}
|
|
36456
|
+
get zoom() {
|
|
36457
|
+
return this._viewport?.scale.x ?? 1;
|
|
36458
|
+
}
|
|
36459
|
+
set zoom(value) {
|
|
36460
|
+
if (!this._viewport)
|
|
36461
|
+
return;
|
|
36462
|
+
const clamped = Math.max(this.options.minScale, Math.min(this.options.maxScale, value));
|
|
36463
|
+
this._viewport.setZoom(clamped, true);
|
|
36464
|
+
this.engine.eventBus.emit("viewport:zoomed", { zoom: clamped });
|
|
36465
|
+
}
|
|
36466
|
+
get drag() {
|
|
36467
|
+
return this.options.drag;
|
|
36468
|
+
}
|
|
36469
|
+
set drag(value) {
|
|
36470
|
+
this.options.drag = value;
|
|
36471
|
+
if (!this._viewport)
|
|
36472
|
+
return;
|
|
36473
|
+
if (value) {
|
|
36474
|
+
this._viewport.drag({ mouseButtons: "middle-right" });
|
|
36475
|
+
} else {
|
|
36476
|
+
this._viewport.plugins.remove("drag");
|
|
36477
|
+
}
|
|
36478
|
+
}
|
|
36479
|
+
get wheel() {
|
|
36480
|
+
return this.options.wheel;
|
|
36481
|
+
}
|
|
36482
|
+
set wheel(value) {
|
|
36483
|
+
this.options.wheel = value;
|
|
36484
|
+
if (!this._viewport)
|
|
36485
|
+
return;
|
|
36486
|
+
if (value) {
|
|
36487
|
+
this._viewport.wheel({ smooth: 3 });
|
|
36488
|
+
} else {
|
|
36489
|
+
this._viewport.plugins.remove("wheel");
|
|
36490
|
+
}
|
|
36491
|
+
}
|
|
36492
|
+
init(engine) {
|
|
36493
|
+
this.engine = engine;
|
|
36494
|
+
const { app } = engine;
|
|
36495
|
+
const { width, height } = engine.options;
|
|
36496
|
+
const worldWidth = this.options.worldWidth || width;
|
|
36497
|
+
const worldHeight = this.options.worldHeight || height;
|
|
36498
|
+
this._viewport = new it({
|
|
36499
|
+
screenWidth: width,
|
|
36500
|
+
screenHeight: height,
|
|
36501
|
+
worldWidth,
|
|
36502
|
+
worldHeight,
|
|
36503
|
+
events: app.renderer.events
|
|
36504
|
+
});
|
|
36505
|
+
this._viewport.clampZoom({
|
|
36506
|
+
minScale: this.options.minScale,
|
|
36507
|
+
maxScale: this.options.maxScale
|
|
36508
|
+
});
|
|
36509
|
+
if (this.options.drag)
|
|
36510
|
+
this._viewport.drag({ mouseButtons: "middle-right" });
|
|
36511
|
+
if (this.options.pinch)
|
|
36512
|
+
this._viewport.pinch();
|
|
36513
|
+
if (this.options.wheel)
|
|
36514
|
+
this._viewport.wheel({ smooth: 3 });
|
|
36515
|
+
if (this.options.decelerate)
|
|
36516
|
+
this._viewport.decelerate();
|
|
36517
|
+
const layers = [
|
|
36518
|
+
engine.getBackgroundLayer(),
|
|
36519
|
+
engine.getElementsLayer(),
|
|
36520
|
+
engine.getSelectionLayer(),
|
|
36521
|
+
engine.getOverlayLayer()
|
|
36522
|
+
];
|
|
36523
|
+
for (const layer of layers) {
|
|
36524
|
+
layer.parent?.removeChild(layer);
|
|
36525
|
+
this._viewport.addChild(layer);
|
|
36526
|
+
}
|
|
36527
|
+
app.stage.addChildAt(this._viewport, 0);
|
|
36528
|
+
this._viewport.on("zoomed", () => {
|
|
36529
|
+
this.engine.eventBus.emit("viewport:zoomed", { zoom: this._viewport.scale.x });
|
|
36530
|
+
});
|
|
36531
|
+
this._viewport.on("moved", () => {
|
|
36532
|
+
this.engine.eventBus.emit("viewport:moved", {
|
|
36533
|
+
x: this._viewport.x,
|
|
36534
|
+
y: this._viewport.y
|
|
36535
|
+
});
|
|
36536
|
+
});
|
|
36537
|
+
}
|
|
36538
|
+
destroy() {
|
|
36539
|
+
if (!this._viewport)
|
|
36540
|
+
return;
|
|
36541
|
+
const { app } = this.engine;
|
|
36542
|
+
const layers = [
|
|
36543
|
+
this.engine.getBackgroundLayer(),
|
|
36544
|
+
this.engine.getElementsLayer(),
|
|
36545
|
+
this.engine.getSelectionLayer(),
|
|
36546
|
+
this.engine.getOverlayLayer()
|
|
36547
|
+
];
|
|
36548
|
+
for (const layer of layers) {
|
|
36549
|
+
this._viewport.removeChild(layer);
|
|
36550
|
+
app.stage.addChild(layer);
|
|
36551
|
+
}
|
|
36552
|
+
this._viewport.destroy();
|
|
36553
|
+
}
|
|
36554
|
+
}
|
|
34987
36555
|
export {
|
|
34988
36556
|
ZOrderManager,
|
|
34989
36557
|
WatchfaceEngine,
|
|
36558
|
+
ViewportPlugin,
|
|
34990
36559
|
UndoRedoPlugin,
|
|
34991
36560
|
TextElement,
|
|
34992
36561
|
ShapeElement,
|