@prefecthq/graphs 0.1.6 → 0.1.7
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/graphs.mjs +3 -15135
- package/dist/graphs.mjs.map +1 -1
- package/dist/graphs.umd.js +49 -49
- package/dist/graphs.umd.js.map +1 -1
- package/dist/index-91d339eb.mjs +13634 -0
- package/dist/index-91d339eb.mjs.map +1 -0
- package/dist/types/src/pixiFunctions/initViewport.d.ts +2 -2
- package/dist/types/src/pixiFunctions/timelineGuides.d.ts +1 -1
- package/dist/types/src/pixiFunctions/viewport.d.ts +1 -0
- package/dist/viewport.es-fd5aad9a.mjs +1533 -0
- package/dist/viewport.es-fd5aad9a.mjs.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,1533 @@
|
|
|
1
|
+
import { P as c, R as b, T as C, C as P } from "./index-91d339eb.mjs";
|
|
2
|
+
import "vue";
|
|
3
|
+
class u {
|
|
4
|
+
constructor(t) {
|
|
5
|
+
this.parent = t, this.paused = !1;
|
|
6
|
+
}
|
|
7
|
+
destroy() {
|
|
8
|
+
}
|
|
9
|
+
down(t) {
|
|
10
|
+
return !1;
|
|
11
|
+
}
|
|
12
|
+
move(t) {
|
|
13
|
+
return !1;
|
|
14
|
+
}
|
|
15
|
+
up(t) {
|
|
16
|
+
return !1;
|
|
17
|
+
}
|
|
18
|
+
wheel(t) {
|
|
19
|
+
return !1;
|
|
20
|
+
}
|
|
21
|
+
update(t) {
|
|
22
|
+
}
|
|
23
|
+
resize() {
|
|
24
|
+
}
|
|
25
|
+
reset() {
|
|
26
|
+
}
|
|
27
|
+
pause() {
|
|
28
|
+
this.paused = !0;
|
|
29
|
+
}
|
|
30
|
+
resume() {
|
|
31
|
+
this.paused = !1;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
var _ = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
35
|
+
function I(l, t, e) {
|
|
36
|
+
return e = {
|
|
37
|
+
path: t,
|
|
38
|
+
exports: {},
|
|
39
|
+
require: function(n, i) {
|
|
40
|
+
return k(n, i ?? e.path);
|
|
41
|
+
}
|
|
42
|
+
}, l(e, e.exports), e.exports;
|
|
43
|
+
}
|
|
44
|
+
function k() {
|
|
45
|
+
throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs");
|
|
46
|
+
}
|
|
47
|
+
var M = I(function(l, t) {
|
|
48
|
+
(function() {
|
|
49
|
+
var e, n;
|
|
50
|
+
n = function(i) {
|
|
51
|
+
return l.exports = i;
|
|
52
|
+
}, e = {
|
|
53
|
+
linear: function(i, s, h, o) {
|
|
54
|
+
return h * i / o + s;
|
|
55
|
+
},
|
|
56
|
+
easeInQuad: function(i, s, h, o) {
|
|
57
|
+
return h * (i /= o) * i + s;
|
|
58
|
+
},
|
|
59
|
+
easeOutQuad: function(i, s, h, o) {
|
|
60
|
+
return -h * (i /= o) * (i - 2) + s;
|
|
61
|
+
},
|
|
62
|
+
easeInOutQuad: function(i, s, h, o) {
|
|
63
|
+
return (i /= o / 2) < 1 ? h / 2 * i * i + s : -h / 2 * (--i * (i - 2) - 1) + s;
|
|
64
|
+
},
|
|
65
|
+
easeInCubic: function(i, s, h, o) {
|
|
66
|
+
return h * (i /= o) * i * i + s;
|
|
67
|
+
},
|
|
68
|
+
easeOutCubic: function(i, s, h, o) {
|
|
69
|
+
return h * ((i = i / o - 1) * i * i + 1) + s;
|
|
70
|
+
},
|
|
71
|
+
easeInOutCubic: function(i, s, h, o) {
|
|
72
|
+
return (i /= o / 2) < 1 ? h / 2 * i * i * i + s : h / 2 * ((i -= 2) * i * i + 2) + s;
|
|
73
|
+
},
|
|
74
|
+
easeInQuart: function(i, s, h, o) {
|
|
75
|
+
return h * (i /= o) * i * i * i + s;
|
|
76
|
+
},
|
|
77
|
+
easeOutQuart: function(i, s, h, o) {
|
|
78
|
+
return -h * ((i = i / o - 1) * i * i * i - 1) + s;
|
|
79
|
+
},
|
|
80
|
+
easeInOutQuart: function(i, s, h, o) {
|
|
81
|
+
return (i /= o / 2) < 1 ? h / 2 * i * i * i * i + s : -h / 2 * ((i -= 2) * i * i * i - 2) + s;
|
|
82
|
+
},
|
|
83
|
+
easeInQuint: function(i, s, h, o) {
|
|
84
|
+
return h * (i /= o) * i * i * i * i + s;
|
|
85
|
+
},
|
|
86
|
+
easeOutQuint: function(i, s, h, o) {
|
|
87
|
+
return h * ((i = i / o - 1) * i * i * i * i + 1) + s;
|
|
88
|
+
},
|
|
89
|
+
easeInOutQuint: function(i, s, h, o) {
|
|
90
|
+
return (i /= o / 2) < 1 ? h / 2 * i * i * i * i * i + s : h / 2 * ((i -= 2) * i * i * i * i + 2) + s;
|
|
91
|
+
},
|
|
92
|
+
easeInSine: function(i, s, h, o) {
|
|
93
|
+
return -h * Math.cos(i / o * (Math.PI / 2)) + h + s;
|
|
94
|
+
},
|
|
95
|
+
easeOutSine: function(i, s, h, o) {
|
|
96
|
+
return h * Math.sin(i / o * (Math.PI / 2)) + s;
|
|
97
|
+
},
|
|
98
|
+
easeInOutSine: function(i, s, h, o) {
|
|
99
|
+
return -h / 2 * (Math.cos(Math.PI * i / o) - 1) + s;
|
|
100
|
+
},
|
|
101
|
+
easeInExpo: function(i, s, h, o) {
|
|
102
|
+
return i === 0 ? s : h * Math.pow(2, 10 * (i / o - 1)) + s;
|
|
103
|
+
},
|
|
104
|
+
easeOutExpo: function(i, s, h, o) {
|
|
105
|
+
return i === o ? s + h : h * (-Math.pow(2, -10 * i / o) + 1) + s;
|
|
106
|
+
},
|
|
107
|
+
easeInOutExpo: function(i, s, h, o) {
|
|
108
|
+
return (i /= o / 2) < 1 ? h / 2 * Math.pow(2, 10 * (i - 1)) + s : h / 2 * (-Math.pow(2, -10 * --i) + 2) + s;
|
|
109
|
+
},
|
|
110
|
+
easeInCirc: function(i, s, h, o) {
|
|
111
|
+
return -h * (Math.sqrt(1 - (i /= o) * i) - 1) + s;
|
|
112
|
+
},
|
|
113
|
+
easeOutCirc: function(i, s, h, o) {
|
|
114
|
+
return h * Math.sqrt(1 - (i = i / o - 1) * i) + s;
|
|
115
|
+
},
|
|
116
|
+
easeInOutCirc: function(i, s, h, o) {
|
|
117
|
+
return (i /= o / 2) < 1 ? -h / 2 * (Math.sqrt(1 - i * i) - 1) + s : h / 2 * (Math.sqrt(1 - (i -= 2) * i) + 1) + s;
|
|
118
|
+
},
|
|
119
|
+
easeInElastic: function(i, s, h, o) {
|
|
120
|
+
var r, a, p;
|
|
121
|
+
return p = 1.70158, a = 0, r = h, i === 0 || (i /= o), a || (a = o * 0.3), r < Math.abs(h) ? (r = h, p = a / 4) : p = a / (2 * Math.PI) * Math.asin(h / r), -(r * Math.pow(2, 10 * (i -= 1)) * Math.sin((i * o - p) * (2 * Math.PI) / a)) + s;
|
|
122
|
+
},
|
|
123
|
+
easeOutElastic: function(i, s, h, o) {
|
|
124
|
+
var r, a, p;
|
|
125
|
+
return p = 1.70158, a = 0, r = h, i === 0 || (i /= o), a || (a = o * 0.3), r < Math.abs(h) ? (r = h, p = a / 4) : p = a / (2 * Math.PI) * Math.asin(h / r), r * Math.pow(2, -10 * i) * Math.sin((i * o - p) * (2 * Math.PI) / a) + h + s;
|
|
126
|
+
},
|
|
127
|
+
easeInOutElastic: function(i, s, h, o) {
|
|
128
|
+
var r, a, p;
|
|
129
|
+
return p = 1.70158, a = 0, r = h, i === 0 || (i /= o / 2), a || (a = o * (0.3 * 1.5)), r < Math.abs(h) ? (r = h, p = a / 4) : p = a / (2 * Math.PI) * Math.asin(h / r), i < 1 ? -0.5 * (r * Math.pow(2, 10 * (i -= 1)) * Math.sin((i * o - p) * (2 * Math.PI) / a)) + s : r * Math.pow(2, -10 * (i -= 1)) * Math.sin((i * o - p) * (2 * Math.PI) / a) * 0.5 + h + s;
|
|
130
|
+
},
|
|
131
|
+
easeInBack: function(i, s, h, o, r) {
|
|
132
|
+
return r === void 0 && (r = 1.70158), h * (i /= o) * i * ((r + 1) * i - r) + s;
|
|
133
|
+
},
|
|
134
|
+
easeOutBack: function(i, s, h, o, r) {
|
|
135
|
+
return r === void 0 && (r = 1.70158), h * ((i = i / o - 1) * i * ((r + 1) * i + r) + 1) + s;
|
|
136
|
+
},
|
|
137
|
+
easeInOutBack: function(i, s, h, o, r) {
|
|
138
|
+
return r === void 0 && (r = 1.70158), (i /= o / 2) < 1 ? h / 2 * (i * i * (((r *= 1.525) + 1) * i - r)) + s : h / 2 * ((i -= 2) * i * (((r *= 1.525) + 1) * i + r) + 2) + s;
|
|
139
|
+
},
|
|
140
|
+
easeInBounce: function(i, s, h, o) {
|
|
141
|
+
var r;
|
|
142
|
+
return r = e.easeOutBounce(o - i, 0, h, o), h - r + s;
|
|
143
|
+
},
|
|
144
|
+
easeOutBounce: function(i, s, h, o) {
|
|
145
|
+
return (i /= o) < 1 / 2.75 ? h * (7.5625 * i * i) + s : i < 2 / 2.75 ? h * (7.5625 * (i -= 1.5 / 2.75) * i + 0.75) + s : i < 2.5 / 2.75 ? h * (7.5625 * (i -= 2.25 / 2.75) * i + 0.9375) + s : h * (7.5625 * (i -= 2.625 / 2.75) * i + 0.984375) + s;
|
|
146
|
+
},
|
|
147
|
+
easeInOutBounce: function(i, s, h, o) {
|
|
148
|
+
var r;
|
|
149
|
+
return i < o / 2 ? (r = e.easeInBounce(i * 2, 0, h, o), r * 0.5 + s) : (r = e.easeOutBounce(i * 2 - o, 0, h, o), r * 0.5 + h * 0.5 + s);
|
|
150
|
+
}
|
|
151
|
+
}, n(e);
|
|
152
|
+
}).call(_);
|
|
153
|
+
});
|
|
154
|
+
function H(l, t) {
|
|
155
|
+
if (l) {
|
|
156
|
+
if (typeof l == "function")
|
|
157
|
+
return l;
|
|
158
|
+
if (typeof l == "string")
|
|
159
|
+
return M[l];
|
|
160
|
+
} else
|
|
161
|
+
return M[t];
|
|
162
|
+
}
|
|
163
|
+
const Y = {
|
|
164
|
+
removeOnInterrupt: !1,
|
|
165
|
+
ease: "linear",
|
|
166
|
+
time: 1e3
|
|
167
|
+
};
|
|
168
|
+
class d extends u {
|
|
169
|
+
__init() {
|
|
170
|
+
this.startWidth = null;
|
|
171
|
+
}
|
|
172
|
+
__init2() {
|
|
173
|
+
this.startHeight = null;
|
|
174
|
+
}
|
|
175
|
+
__init3() {
|
|
176
|
+
this.deltaWidth = null;
|
|
177
|
+
}
|
|
178
|
+
__init4() {
|
|
179
|
+
this.deltaHeight = null;
|
|
180
|
+
}
|
|
181
|
+
__init5() {
|
|
182
|
+
this.width = null;
|
|
183
|
+
}
|
|
184
|
+
__init6() {
|
|
185
|
+
this.height = null;
|
|
186
|
+
}
|
|
187
|
+
__init7() {
|
|
188
|
+
this.time = 0;
|
|
189
|
+
}
|
|
190
|
+
constructor(t, e = {}) {
|
|
191
|
+
super(t), d.prototype.__init.call(this), d.prototype.__init2.call(this), d.prototype.__init3.call(this), d.prototype.__init4.call(this), d.prototype.__init5.call(this), d.prototype.__init6.call(this), d.prototype.__init7.call(this), this.options = Object.assign({}, Y, e), this.options.ease = H(this.options.ease), this.setupPosition(), this.setupZoom(), this.time = 0;
|
|
192
|
+
}
|
|
193
|
+
setupPosition() {
|
|
194
|
+
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 = !1) : this.keepCenter = !0;
|
|
195
|
+
}
|
|
196
|
+
setupZoom() {
|
|
197
|
+
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);
|
|
198
|
+
}
|
|
199
|
+
down() {
|
|
200
|
+
return this.options.removeOnInterrupt && this.parent.plugins.remove("animate"), !1;
|
|
201
|
+
}
|
|
202
|
+
complete() {
|
|
203
|
+
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);
|
|
204
|
+
}
|
|
205
|
+
update(t) {
|
|
206
|
+
if (this.paused)
|
|
207
|
+
return;
|
|
208
|
+
this.time += t;
|
|
209
|
+
const e = new c(this.parent.scale.x, this.parent.scale.y);
|
|
210
|
+
if (this.time >= this.options.time) {
|
|
211
|
+
const n = this.parent.width, i = this.parent.height;
|
|
212
|
+
this.complete(), (n !== this.parent.width || i !== this.parent.height) && this.parent.emit("zoomed", { viewport: this.parent, original: e, type: "animate" });
|
|
213
|
+
} else {
|
|
214
|
+
const n = this.options.ease(this.time, 0, 1, this.options.time);
|
|
215
|
+
if (this.width !== null) {
|
|
216
|
+
const i = this.startWidth, s = this.deltaWidth;
|
|
217
|
+
this.parent.fitWidth(
|
|
218
|
+
i + s * n,
|
|
219
|
+
this.keepCenter,
|
|
220
|
+
this.height === null
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
if (this.height !== null) {
|
|
224
|
+
const i = this.startHeight, s = this.deltaHeight;
|
|
225
|
+
this.parent.fitHeight(
|
|
226
|
+
i + s * n,
|
|
227
|
+
this.keepCenter,
|
|
228
|
+
this.width === null
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
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) {
|
|
232
|
+
const i = this.startX, s = this.startY, h = this.deltaX, o = this.deltaY, r = new c(this.parent.x, this.parent.y);
|
|
233
|
+
this.parent.moveCenter(i + h * n, s + o * n), this.parent.emit("moved", { viewport: this.parent, original: r, type: "animate" });
|
|
234
|
+
}
|
|
235
|
+
(this.width || this.height) && this.parent.emit("zoomed", { viewport: this.parent, original: e, type: "animate" });
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
function v(l) {
|
|
240
|
+
let t, e = l[0], n = 1;
|
|
241
|
+
for (; n < l.length; ) {
|
|
242
|
+
const i = l[n], s = l[n + 1];
|
|
243
|
+
if (n += 2, (i === "optionalAccess" || i === "optionalCall") && e == null)
|
|
244
|
+
return;
|
|
245
|
+
i === "access" || i === "optionalAccess" ? (t = e, e = s(e)) : (i === "call" || i === "optionalCall") && (e = s((...h) => e.call(t, ...h)), t = void 0);
|
|
246
|
+
}
|
|
247
|
+
return e;
|
|
248
|
+
}
|
|
249
|
+
const X = {
|
|
250
|
+
sides: "all",
|
|
251
|
+
friction: 0.5,
|
|
252
|
+
time: 150,
|
|
253
|
+
ease: "easeInOutSine",
|
|
254
|
+
underflow: "center",
|
|
255
|
+
bounceBox: null
|
|
256
|
+
};
|
|
257
|
+
class z extends u {
|
|
258
|
+
constructor(t, e = {}) {
|
|
259
|
+
super(t), this.options = Object.assign({}, X, e), this.ease = H(this.options.ease, "easeInOutSine"), this.options.sides ? this.options.sides === "all" ? this.top = this.bottom = this.left = this.right = !0 : this.options.sides === "horizontal" ? (this.right = this.left = !0, this.top = this.bottom = !1) : this.options.sides === "vertical" ? (this.left = this.right = !1, this.top = this.bottom = !0) : (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 = !1;
|
|
260
|
+
const n = this.options.underflow.toLowerCase();
|
|
261
|
+
n === "center" ? (this.underflowX = 0, this.underflowY = 0) : (this.underflowX = n.indexOf("left") !== -1 ? -1 : n.indexOf("right") !== -1 ? 1 : 0, this.underflowY = n.indexOf("top") !== -1 ? -1 : n.indexOf("bottom") !== -1 ? 1 : 0), this.reset();
|
|
262
|
+
}
|
|
263
|
+
isActive() {
|
|
264
|
+
return this.toX !== null || this.toY !== null;
|
|
265
|
+
}
|
|
266
|
+
down() {
|
|
267
|
+
return this.toX = this.toY = null, !1;
|
|
268
|
+
}
|
|
269
|
+
up() {
|
|
270
|
+
return this.bounce(), !1;
|
|
271
|
+
}
|
|
272
|
+
update(t) {
|
|
273
|
+
if (!this.paused) {
|
|
274
|
+
if (this.bounce(), this.toX) {
|
|
275
|
+
const e = this.toX;
|
|
276
|
+
e.time += t, this.parent.emit("moved", { viewport: this.parent, type: "bounce-x" }), e.time >= this.options.time ? (this.parent.x = e.end, this.toX = null, this.parent.emit("bounce-x-end", this.parent)) : this.parent.x = this.ease(e.time, e.start, e.delta, this.options.time);
|
|
277
|
+
}
|
|
278
|
+
if (this.toY) {
|
|
279
|
+
const e = this.toY;
|
|
280
|
+
e.time += t, this.parent.emit("moved", { viewport: this.parent, type: "bounce-y" }), e.time >= this.options.time ? (this.parent.y = e.end, this.toY = null, this.parent.emit("bounce-y-end", this.parent)) : this.parent.y = this.ease(e.time, e.start, e.delta, this.options.time);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
calcUnderflowX() {
|
|
285
|
+
let t;
|
|
286
|
+
switch (this.underflowX) {
|
|
287
|
+
case -1:
|
|
288
|
+
t = 0;
|
|
289
|
+
break;
|
|
290
|
+
case 1:
|
|
291
|
+
t = this.parent.screenWidth - this.parent.screenWorldWidth;
|
|
292
|
+
break;
|
|
293
|
+
default:
|
|
294
|
+
t = (this.parent.screenWidth - this.parent.screenWorldWidth) / 2;
|
|
295
|
+
}
|
|
296
|
+
return t;
|
|
297
|
+
}
|
|
298
|
+
calcUnderflowY() {
|
|
299
|
+
let t;
|
|
300
|
+
switch (this.underflowY) {
|
|
301
|
+
case -1:
|
|
302
|
+
t = 0;
|
|
303
|
+
break;
|
|
304
|
+
case 1:
|
|
305
|
+
t = this.parent.screenHeight - this.parent.screenWorldHeight;
|
|
306
|
+
break;
|
|
307
|
+
default:
|
|
308
|
+
t = (this.parent.screenHeight - this.parent.screenWorldHeight) / 2;
|
|
309
|
+
}
|
|
310
|
+
return t;
|
|
311
|
+
}
|
|
312
|
+
oob() {
|
|
313
|
+
const t = this.options.bounceBox;
|
|
314
|
+
if (t) {
|
|
315
|
+
const e = typeof t.x > "u" ? 0 : t.x, n = typeof t.y > "u" ? 0 : t.y, i = typeof t.width > "u" ? this.parent.worldWidth : t.width, s = typeof t.height > "u" ? this.parent.worldHeight : t.height;
|
|
316
|
+
return {
|
|
317
|
+
left: this.parent.left < e,
|
|
318
|
+
right: this.parent.right > i,
|
|
319
|
+
top: this.parent.top < n,
|
|
320
|
+
bottom: this.parent.bottom > s,
|
|
321
|
+
topLeft: new c(
|
|
322
|
+
e * this.parent.scale.x,
|
|
323
|
+
n * this.parent.scale.y
|
|
324
|
+
),
|
|
325
|
+
bottomRight: new c(
|
|
326
|
+
i * this.parent.scale.x - this.parent.screenWidth,
|
|
327
|
+
s * this.parent.scale.y - this.parent.screenHeight
|
|
328
|
+
)
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
return {
|
|
332
|
+
left: this.parent.left < 0,
|
|
333
|
+
right: this.parent.right > this.parent.worldWidth,
|
|
334
|
+
top: this.parent.top < 0,
|
|
335
|
+
bottom: this.parent.bottom > this.parent.worldHeight,
|
|
336
|
+
topLeft: new c(0, 0),
|
|
337
|
+
bottomRight: new c(
|
|
338
|
+
this.parent.worldWidth * this.parent.scale.x - this.parent.screenWidth,
|
|
339
|
+
this.parent.worldHeight * this.parent.scale.y - this.parent.screenHeight
|
|
340
|
+
)
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
bounce() {
|
|
344
|
+
if (this.paused)
|
|
345
|
+
return;
|
|
346
|
+
let t, e = this.parent.plugins.get("decelerate", !0);
|
|
347
|
+
e && (e.x || e.y) && (e.x && e.percentChangeX === v([e, "access", (s) => s.options, "optionalAccess", (s) => s.friction]) || e.y && e.percentChangeY === v([e, "access", (s) => s.options, "optionalAccess", (s) => s.friction])) && (t = this.oob(), (t.left && this.left || t.right && this.right) && (e.percentChangeX = this.options.friction), (t.top && this.top || t.bottom && this.bottom) && (e.percentChangeY = this.options.friction));
|
|
348
|
+
const n = this.parent.plugins.get("drag", !0) || {}, i = this.parent.plugins.get("pinch", !0) || {};
|
|
349
|
+
if (e = e || {}, !v([n, "optionalAccess", (s) => s.active]) && !v([i, "optionalAccess", (s) => s.active]) && (!this.toX || !this.toY) && (!e.x || !e.y)) {
|
|
350
|
+
t = t || this.oob();
|
|
351
|
+
const s = t.topLeft, h = t.bottomRight;
|
|
352
|
+
if (!this.toX && !e.x) {
|
|
353
|
+
let o = null;
|
|
354
|
+
t.left && this.left ? o = this.parent.screenWorldWidth < this.parent.screenWidth ? this.calcUnderflowX() : -s.x : t.right && this.right && (o = this.parent.screenWorldWidth < this.parent.screenWidth ? this.calcUnderflowX() : -h.x), o !== null && this.parent.x !== o && (this.toX = { time: 0, start: this.parent.x, delta: o - this.parent.x, end: o }, this.parent.emit("bounce-x-start", this.parent));
|
|
355
|
+
}
|
|
356
|
+
if (!this.toY && !e.y) {
|
|
357
|
+
let o = null;
|
|
358
|
+
t.top && this.top ? o = this.parent.screenWorldHeight < this.parent.screenHeight ? this.calcUnderflowY() : -s.y : t.bottom && this.bottom && (o = this.parent.screenWorldHeight < this.parent.screenHeight ? this.calcUnderflowY() : -h.y), o !== null && this.parent.y !== o && (this.toY = { time: 0, start: this.parent.y, delta: o - this.parent.y, end: o }, this.parent.emit("bounce-y-start", this.parent));
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
reset() {
|
|
363
|
+
this.toX = this.toY = null, this.bounce();
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
const A = {
|
|
367
|
+
left: !1,
|
|
368
|
+
right: !1,
|
|
369
|
+
top: !1,
|
|
370
|
+
bottom: !1,
|
|
371
|
+
direction: null,
|
|
372
|
+
underflow: "center"
|
|
373
|
+
};
|
|
374
|
+
class T extends u {
|
|
375
|
+
constructor(t, e = {}) {
|
|
376
|
+
super(t), this.options = Object.assign({}, A, e), this.options.direction && (this.options.left = this.options.direction === "x" || this.options.direction === "all" ? !0 : null, this.options.right = this.options.direction === "x" || this.options.direction === "all" ? !0 : null, this.options.top = this.options.direction === "y" || this.options.direction === "all" ? !0 : null, this.options.bottom = this.options.direction === "y" || this.options.direction === "all" ? !0 : null), this.parseUnderflow(), this.last = { x: null, y: null, scaleX: null, scaleY: null }, this.update();
|
|
377
|
+
}
|
|
378
|
+
parseUnderflow() {
|
|
379
|
+
const t = this.options.underflow.toLowerCase();
|
|
380
|
+
t === "none" ? this.noUnderflow = !0 : t === "center" ? (this.underflowX = this.underflowY = 0, this.noUnderflow = !1) : (this.underflowX = t.indexOf("left") !== -1 ? -1 : t.indexOf("right") !== -1 ? 1 : 0, this.underflowY = t.indexOf("top") !== -1 ? -1 : t.indexOf("bottom") !== -1 ? 1 : 0, this.noUnderflow = !1);
|
|
381
|
+
}
|
|
382
|
+
move() {
|
|
383
|
+
return this.update(), !1;
|
|
384
|
+
}
|
|
385
|
+
update() {
|
|
386
|
+
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)
|
|
387
|
+
return;
|
|
388
|
+
const t = { x: this.parent.x, y: this.parent.y }, e = this.parent.plugins.decelerate || {};
|
|
389
|
+
if (this.options.left !== null || this.options.right !== null) {
|
|
390
|
+
let n = !1;
|
|
391
|
+
if (!this.noUnderflow && this.parent.screenWorldWidth < this.parent.screenWidth)
|
|
392
|
+
switch (this.underflowX) {
|
|
393
|
+
case -1:
|
|
394
|
+
this.parent.x !== 0 && (this.parent.x = 0, n = !0);
|
|
395
|
+
break;
|
|
396
|
+
case 1:
|
|
397
|
+
this.parent.x !== this.parent.screenWidth - this.parent.screenWorldWidth && (this.parent.x = this.parent.screenWidth - this.parent.screenWorldWidth, n = !0);
|
|
398
|
+
break;
|
|
399
|
+
default:
|
|
400
|
+
this.parent.x !== (this.parent.screenWidth - this.parent.screenWorldWidth) / 2 && (this.parent.x = (this.parent.screenWidth - this.parent.screenWorldWidth) / 2, n = !0);
|
|
401
|
+
}
|
|
402
|
+
else
|
|
403
|
+
this.options.left !== null && this.parent.left < (this.options.left === !0 ? 0 : this.options.left) && (this.parent.x = -(this.options.left === !0 ? 0 : this.options.left) * this.parent.scale.x, e.x = 0, n = !0), this.options.right !== null && this.parent.right > (this.options.right === !0 ? this.parent.worldWidth : this.options.right) && (this.parent.x = -(this.options.right === !0 ? this.parent.worldWidth : this.options.right) * this.parent.scale.x + this.parent.screenWidth, e.x = 0, n = !0);
|
|
404
|
+
n && this.parent.emit("moved", { viewport: this.parent, original: t, type: "clamp-x" });
|
|
405
|
+
}
|
|
406
|
+
if (this.options.top !== null || this.options.bottom !== null) {
|
|
407
|
+
let n = !1;
|
|
408
|
+
if (!this.noUnderflow && this.parent.screenWorldHeight < this.parent.screenHeight)
|
|
409
|
+
switch (this.underflowY) {
|
|
410
|
+
case -1:
|
|
411
|
+
this.parent.y !== 0 && (this.parent.y = 0, n = !0);
|
|
412
|
+
break;
|
|
413
|
+
case 1:
|
|
414
|
+
this.parent.y !== this.parent.screenHeight - this.parent.screenWorldHeight && (this.parent.y = this.parent.screenHeight - this.parent.screenWorldHeight, n = !0);
|
|
415
|
+
break;
|
|
416
|
+
default:
|
|
417
|
+
this.parent.y !== (this.parent.screenHeight - this.parent.screenWorldHeight) / 2 && (this.parent.y = (this.parent.screenHeight - this.parent.screenWorldHeight) / 2, n = !0);
|
|
418
|
+
}
|
|
419
|
+
else
|
|
420
|
+
this.options.top !== null && this.parent.top < (this.options.top === !0 ? 0 : this.options.top) && (this.parent.y = -(this.options.top === !0 ? 0 : this.options.top) * this.parent.scale.y, e.y = 0, n = !0), this.options.bottom !== null && this.parent.bottom > (this.options.bottom === !0 ? this.parent.worldHeight : this.options.bottom) && (this.parent.y = -(this.options.bottom === !0 ? this.parent.worldHeight : this.options.bottom) * this.parent.scale.y + this.parent.screenHeight, e.y = 0, n = !0);
|
|
421
|
+
n && this.parent.emit("moved", { viewport: this.parent, original: t, type: "clamp-y" });
|
|
422
|
+
}
|
|
423
|
+
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;
|
|
424
|
+
}
|
|
425
|
+
reset() {
|
|
426
|
+
this.update();
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
const E = {
|
|
430
|
+
minWidth: null,
|
|
431
|
+
minHeight: null,
|
|
432
|
+
maxWidth: null,
|
|
433
|
+
maxHeight: null,
|
|
434
|
+
minScale: null,
|
|
435
|
+
maxScale: null
|
|
436
|
+
};
|
|
437
|
+
class L extends u {
|
|
438
|
+
constructor(t, e = {}) {
|
|
439
|
+
super(t), this.options = Object.assign({}, E, e), this.clamp();
|
|
440
|
+
}
|
|
441
|
+
resize() {
|
|
442
|
+
this.clamp();
|
|
443
|
+
}
|
|
444
|
+
clamp() {
|
|
445
|
+
if (!this.paused) {
|
|
446
|
+
if (this.options.minWidth || this.options.minHeight || this.options.maxWidth || this.options.maxHeight) {
|
|
447
|
+
let t = this.parent.worldScreenWidth, e = this.parent.worldScreenHeight;
|
|
448
|
+
if (this.options.minWidth !== null && t < this.options.minWidth) {
|
|
449
|
+
const n = this.parent.scale.x;
|
|
450
|
+
this.parent.fitWidth(this.options.minWidth, !1, !1, !0), this.parent.scale.y *= this.parent.scale.x / n, t = this.parent.worldScreenWidth, e = this.parent.worldScreenHeight, this.parent.emit("zoomed", { viewport: this.parent, type: "clamp-zoom" });
|
|
451
|
+
}
|
|
452
|
+
if (this.options.maxWidth !== null && t > this.options.maxWidth) {
|
|
453
|
+
const n = this.parent.scale.x;
|
|
454
|
+
this.parent.fitWidth(this.options.maxWidth, !1, !1, !0), this.parent.scale.y *= this.parent.scale.x / n, t = this.parent.worldScreenWidth, e = this.parent.worldScreenHeight, this.parent.emit("zoomed", { viewport: this.parent, type: "clamp-zoom" });
|
|
455
|
+
}
|
|
456
|
+
if (this.options.minHeight !== null && e < this.options.minHeight) {
|
|
457
|
+
const n = this.parent.scale.y;
|
|
458
|
+
this.parent.fitHeight(this.options.minHeight, !1, !1, !0), this.parent.scale.x *= this.parent.scale.y / n, t = this.parent.worldScreenWidth, e = this.parent.worldScreenHeight, this.parent.emit("zoomed", { viewport: this.parent, type: "clamp-zoom" });
|
|
459
|
+
}
|
|
460
|
+
if (this.options.maxHeight !== null && e > this.options.maxHeight) {
|
|
461
|
+
const n = this.parent.scale.y;
|
|
462
|
+
this.parent.fitHeight(this.options.maxHeight, !1, !1, !0), this.parent.scale.x *= this.parent.scale.y / n, this.parent.emit("zoomed", { viewport: this.parent, type: "clamp-zoom" });
|
|
463
|
+
}
|
|
464
|
+
} else if (this.options.minScale || this.options.maxScale) {
|
|
465
|
+
const t = { x: null, y: null }, e = { x: null, y: null };
|
|
466
|
+
if (typeof this.options.minScale == "number")
|
|
467
|
+
t.x = this.options.minScale, t.y = this.options.minScale;
|
|
468
|
+
else if (this.options.minScale !== null) {
|
|
469
|
+
const s = this.options.minScale;
|
|
470
|
+
t.x = typeof s.x > "u" ? null : s.x, t.y = typeof s.y > "u" ? null : s.y;
|
|
471
|
+
}
|
|
472
|
+
if (typeof this.options.maxScale == "number")
|
|
473
|
+
e.x = this.options.maxScale, e.y = this.options.maxScale;
|
|
474
|
+
else if (this.options.maxScale !== null) {
|
|
475
|
+
const s = this.options.maxScale;
|
|
476
|
+
e.x = typeof s.x > "u" ? null : s.x, e.y = typeof s.y > "u" ? null : s.y;
|
|
477
|
+
}
|
|
478
|
+
let n = this.parent.scale.x, i = this.parent.scale.y;
|
|
479
|
+
t.x !== null && n < t.x && (n = t.x), e.x !== null && n > e.x && (n = e.x), t.y !== null && i < t.y && (i = t.y), e.y !== null && i > e.y && (i = e.y), (n !== this.parent.scale.x || i !== this.parent.scale.y) && (this.parent.scale.set(n, i), this.parent.emit("zoomed", { viewport: this.parent, type: "clamp-zoom" }));
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
reset() {
|
|
484
|
+
this.clamp();
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
const D = {
|
|
488
|
+
friction: 0.98,
|
|
489
|
+
bounce: 0.8,
|
|
490
|
+
minSpeed: 0.01
|
|
491
|
+
}, f = 16;
|
|
492
|
+
class U extends u {
|
|
493
|
+
constructor(t, e = {}) {
|
|
494
|
+
super(t), this.options = Object.assign({}, D, e), this.saved = [], this.timeSinceRelease = 0, this.reset(), this.parent.on("moved", (n) => this.moved(n));
|
|
495
|
+
}
|
|
496
|
+
down() {
|
|
497
|
+
return this.saved = [], this.x = this.y = null, !1;
|
|
498
|
+
}
|
|
499
|
+
isActive() {
|
|
500
|
+
return !!(this.x || this.y);
|
|
501
|
+
}
|
|
502
|
+
move() {
|
|
503
|
+
if (this.paused)
|
|
504
|
+
return !1;
|
|
505
|
+
const t = this.parent.input.count();
|
|
506
|
+
return (t === 1 || 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;
|
|
507
|
+
}
|
|
508
|
+
moved(t) {
|
|
509
|
+
if (this.saved.length) {
|
|
510
|
+
const e = this.saved[this.saved.length - 1];
|
|
511
|
+
t.type === "clamp-x" ? e.x === t.original.x && (e.x = this.parent.x) : t.type === "clamp-y" && e.y === t.original.y && (e.y = this.parent.y);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
up() {
|
|
515
|
+
if (this.parent.input.count() === 0 && this.saved.length) {
|
|
516
|
+
const t = performance.now();
|
|
517
|
+
for (const e of this.saved)
|
|
518
|
+
if (e.time >= t - 100) {
|
|
519
|
+
const n = t - e.time;
|
|
520
|
+
this.x = (this.parent.x - e.x) / n, this.y = (this.parent.y - e.y) / n, this.percentChangeX = this.percentChangeY = this.options.friction, this.timeSinceRelease = 0;
|
|
521
|
+
break;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
return !1;
|
|
525
|
+
}
|
|
526
|
+
activate(t) {
|
|
527
|
+
t = t || {}, typeof t.x < "u" && (this.x = t.x, this.percentChangeX = this.options.friction), typeof t.y < "u" && (this.y = t.y, this.percentChangeY = this.options.friction);
|
|
528
|
+
}
|
|
529
|
+
update(t) {
|
|
530
|
+
if (this.paused)
|
|
531
|
+
return;
|
|
532
|
+
const e = this.x || this.y, n = this.timeSinceRelease, i = this.timeSinceRelease + t;
|
|
533
|
+
if (this.x) {
|
|
534
|
+
const s = this.percentChangeX, h = Math.log(s);
|
|
535
|
+
this.parent.x += this.x * f / h * (Math.pow(s, i / f) - Math.pow(s, n / f)), this.x *= Math.pow(this.percentChangeX, t / f);
|
|
536
|
+
}
|
|
537
|
+
if (this.y) {
|
|
538
|
+
const s = this.percentChangeY, h = Math.log(s);
|
|
539
|
+
this.parent.y += this.y * f / h * (Math.pow(s, i / f) - Math.pow(s, n / f)), this.y *= Math.pow(this.percentChangeY, t / f);
|
|
540
|
+
}
|
|
541
|
+
this.timeSinceRelease += t, 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)), e && this.parent.emit("moved", { viewport: this.parent, type: "decelerate" });
|
|
542
|
+
}
|
|
543
|
+
reset() {
|
|
544
|
+
this.x = this.y = null;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
const B = {
|
|
548
|
+
direction: "all",
|
|
549
|
+
pressDrag: !0,
|
|
550
|
+
wheel: !0,
|
|
551
|
+
wheelScroll: 1,
|
|
552
|
+
reverse: !1,
|
|
553
|
+
clampWheel: !1,
|
|
554
|
+
underflow: "center",
|
|
555
|
+
factor: 1,
|
|
556
|
+
mouseButtons: "all",
|
|
557
|
+
keyToPress: null,
|
|
558
|
+
ignoreKeyToPressOnTouch: !1,
|
|
559
|
+
lineHeight: 20,
|
|
560
|
+
wheelSwapAxes: !1
|
|
561
|
+
};
|
|
562
|
+
class S extends u {
|
|
563
|
+
__init() {
|
|
564
|
+
this.windowEventHandlers = new Array();
|
|
565
|
+
}
|
|
566
|
+
constructor(t, e = {}) {
|
|
567
|
+
super(t), S.prototype.__init.call(this), this.options = Object.assign({}, B, e), this.moved = !1, 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 = !1, this.parseUnderflow(), this.mouseButtons(this.options.mouseButtons), this.options.keyToPress && this.handleKeyPresses(this.options.keyToPress);
|
|
568
|
+
}
|
|
569
|
+
handleKeyPresses(t) {
|
|
570
|
+
const e = (i) => {
|
|
571
|
+
t.includes(i.code) && (this.keyIsPressed = !0);
|
|
572
|
+
}, n = (i) => {
|
|
573
|
+
t.includes(i.code) && (this.keyIsPressed = !1);
|
|
574
|
+
};
|
|
575
|
+
this.addWindowEventHandler("keyup", n), this.addWindowEventHandler("keydown", e);
|
|
576
|
+
}
|
|
577
|
+
addWindowEventHandler(t, e) {
|
|
578
|
+
window.addEventListener(t, e), this.windowEventHandlers.push({ event: t, handler: e });
|
|
579
|
+
}
|
|
580
|
+
destroy() {
|
|
581
|
+
this.windowEventHandlers.forEach(({ event: t, handler: e }) => {
|
|
582
|
+
window.removeEventListener(t, e);
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
mouseButtons(t) {
|
|
586
|
+
!t || t === "all" ? this.mouse = [!0, !0, !0] : this.mouse = [
|
|
587
|
+
t.indexOf("left") !== -1,
|
|
588
|
+
t.indexOf("middle") !== -1,
|
|
589
|
+
t.indexOf("right") !== -1
|
|
590
|
+
];
|
|
591
|
+
}
|
|
592
|
+
parseUnderflow() {
|
|
593
|
+
const t = this.options.underflow.toLowerCase();
|
|
594
|
+
t === "center" ? (this.underflowX = 0, this.underflowY = 0) : (t.includes("left") ? this.underflowX = -1 : t.includes("right") ? this.underflowX = 1 : this.underflowX = 0, t.includes("top") ? this.underflowY = -1 : t.includes("bottom") ? this.underflowY = 1 : this.underflowY = 0);
|
|
595
|
+
}
|
|
596
|
+
checkButtons(t) {
|
|
597
|
+
const e = t.data.pointerType === "mouse", n = this.parent.input.count();
|
|
598
|
+
return !!((n === 1 || n > 1 && !this.parent.plugins.get("pinch", !0)) && (!e || this.mouse[t.data.button]));
|
|
599
|
+
}
|
|
600
|
+
checkKeyPress(t) {
|
|
601
|
+
return !this.options.keyToPress || this.keyIsPressed || this.options.ignoreKeyToPressOnTouch && t.data.pointerType === "touch";
|
|
602
|
+
}
|
|
603
|
+
down(t) {
|
|
604
|
+
return this.paused || !this.options.pressDrag ? !1 : 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);
|
|
605
|
+
}
|
|
606
|
+
get active() {
|
|
607
|
+
return this.moved;
|
|
608
|
+
}
|
|
609
|
+
move(t) {
|
|
610
|
+
if (this.paused || !this.options.pressDrag)
|
|
611
|
+
return !1;
|
|
612
|
+
if (this.last && this.current === t.data.pointerId) {
|
|
613
|
+
const e = t.data.global.x, n = t.data.global.y, i = this.parent.input.count();
|
|
614
|
+
if (i === 1 || i > 1 && !this.parent.plugins.get("pinch", !0)) {
|
|
615
|
+
const s = e - this.last.x, h = n - this.last.y;
|
|
616
|
+
if (this.moved || this.xDirection && this.parent.input.checkThreshold(s) || this.yDirection && this.parent.input.checkThreshold(h)) {
|
|
617
|
+
const o = { x: e, y: n };
|
|
618
|
+
return this.xDirection && (this.parent.x += (o.x - this.last.x) * this.options.factor), this.yDirection && (this.parent.y += (o.y - this.last.y) * this.options.factor), this.last = o, this.moved || this.parent.emit("drag-start", {
|
|
619
|
+
event: t,
|
|
620
|
+
screen: new c(this.last.x, this.last.y),
|
|
621
|
+
world: this.parent.toWorld(new c(this.last.x, this.last.y)),
|
|
622
|
+
viewport: this.parent
|
|
623
|
+
}), this.moved = !0, this.parent.emit("moved", { viewport: this.parent, type: "drag" }), !0;
|
|
624
|
+
}
|
|
625
|
+
} else
|
|
626
|
+
this.moved = !1;
|
|
627
|
+
}
|
|
628
|
+
return !1;
|
|
629
|
+
}
|
|
630
|
+
up(t) {
|
|
631
|
+
if (this.paused)
|
|
632
|
+
return !1;
|
|
633
|
+
const e = this.parent.input.touches;
|
|
634
|
+
if (e.length === 1) {
|
|
635
|
+
const n = e[0];
|
|
636
|
+
return n.last && (this.last = { x: n.last.x, y: n.last.y }, this.current = n.id), this.moved = !1, !0;
|
|
637
|
+
} else if (this.last && this.moved) {
|
|
638
|
+
const n = new c(this.last.x, this.last.y);
|
|
639
|
+
return this.parent.emit("drag-end", {
|
|
640
|
+
event: t,
|
|
641
|
+
screen: n,
|
|
642
|
+
world: this.parent.toWorld(n),
|
|
643
|
+
viewport: this.parent
|
|
644
|
+
}), this.last = null, this.moved = !1, !0;
|
|
645
|
+
}
|
|
646
|
+
return !1;
|
|
647
|
+
}
|
|
648
|
+
wheel(t) {
|
|
649
|
+
if (this.paused)
|
|
650
|
+
return !1;
|
|
651
|
+
if (this.options.wheel) {
|
|
652
|
+
const e = this.parent.plugins.get("wheel", !0);
|
|
653
|
+
if (!e || !e.options.wheelZoom && !t.ctrlKey) {
|
|
654
|
+
const n = t.deltaMode ? this.options.lineHeight : 1, i = [t.deltaX, t.deltaY], [s, h] = this.options.wheelSwapAxes ? i.reverse() : i;
|
|
655
|
+
return this.xDirection && (this.parent.x += s * n * this.options.wheelScroll * this.reverse), this.yDirection && (this.parent.y += h * n * 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(), this.parent.options.stopPropagation && t.stopPropagation(), !0;
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
return !1;
|
|
659
|
+
}
|
|
660
|
+
resume() {
|
|
661
|
+
this.last = null, this.paused = !1;
|
|
662
|
+
}
|
|
663
|
+
clamp() {
|
|
664
|
+
const t = this.parent.plugins.get("decelerate", !0) || {};
|
|
665
|
+
if (this.options.clampWheel !== "y")
|
|
666
|
+
if (this.parent.screenWorldWidth < this.parent.screenWidth)
|
|
667
|
+
switch (this.underflowX) {
|
|
668
|
+
case -1:
|
|
669
|
+
this.parent.x = 0;
|
|
670
|
+
break;
|
|
671
|
+
case 1:
|
|
672
|
+
this.parent.x = this.parent.screenWidth - this.parent.screenWorldWidth;
|
|
673
|
+
break;
|
|
674
|
+
default:
|
|
675
|
+
this.parent.x = (this.parent.screenWidth - this.parent.screenWorldWidth) / 2;
|
|
676
|
+
}
|
|
677
|
+
else
|
|
678
|
+
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);
|
|
679
|
+
if (this.options.clampWheel !== "x")
|
|
680
|
+
if (this.parent.screenWorldHeight < this.parent.screenHeight)
|
|
681
|
+
switch (this.underflowY) {
|
|
682
|
+
case -1:
|
|
683
|
+
this.parent.y = 0;
|
|
684
|
+
break;
|
|
685
|
+
case 1:
|
|
686
|
+
this.parent.y = this.parent.screenHeight - this.parent.screenWorldHeight;
|
|
687
|
+
break;
|
|
688
|
+
default:
|
|
689
|
+
this.parent.y = (this.parent.screenHeight - this.parent.screenWorldHeight) / 2;
|
|
690
|
+
}
|
|
691
|
+
else
|
|
692
|
+
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);
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
const F = {
|
|
696
|
+
speed: 0,
|
|
697
|
+
acceleration: null,
|
|
698
|
+
radius: null
|
|
699
|
+
};
|
|
700
|
+
class V extends u {
|
|
701
|
+
constructor(t, e, n = {}) {
|
|
702
|
+
super(t), this.target = e, this.options = Object.assign({}, F, n), this.velocity = { x: 0, y: 0 };
|
|
703
|
+
}
|
|
704
|
+
update(t) {
|
|
705
|
+
if (this.paused)
|
|
706
|
+
return;
|
|
707
|
+
const e = this.parent.center;
|
|
708
|
+
let n = this.target.x, i = this.target.y;
|
|
709
|
+
if (this.options.radius)
|
|
710
|
+
if (Math.sqrt(Math.pow(this.target.y - e.y, 2) + Math.pow(this.target.x - e.x, 2)) > this.options.radius) {
|
|
711
|
+
const r = Math.atan2(this.target.y - e.y, this.target.x - e.x);
|
|
712
|
+
n = this.target.x - Math.cos(r) * this.options.radius, i = this.target.y - Math.sin(r) * this.options.radius;
|
|
713
|
+
} else
|
|
714
|
+
return;
|
|
715
|
+
const s = n - e.x, h = i - e.y;
|
|
716
|
+
if (s || h)
|
|
717
|
+
if (this.options.speed)
|
|
718
|
+
if (this.options.acceleration) {
|
|
719
|
+
const o = Math.atan2(i - e.y, n - e.x), r = Math.sqrt(Math.pow(s, 2) + Math.pow(h, 2));
|
|
720
|
+
if (r) {
|
|
721
|
+
const a = (Math.pow(this.velocity.x, 2) + Math.pow(this.velocity.y, 2)) / (2 * this.options.acceleration);
|
|
722
|
+
r > a ? this.velocity = {
|
|
723
|
+
x: Math.min(this.velocity.x + (this.options.acceleration * t, this.options.speed)),
|
|
724
|
+
y: Math.min(this.velocity.y + (this.options.acceleration * t, this.options.speed))
|
|
725
|
+
} : this.velocity = {
|
|
726
|
+
x: Math.max(this.velocity.x - this.options.acceleration * this.options.speed, 0),
|
|
727
|
+
y: Math.max(this.velocity.y - this.options.acceleration * this.options.speed, 0)
|
|
728
|
+
};
|
|
729
|
+
const p = Math.cos(o) * this.velocity.x, g = Math.sin(o) * this.velocity.y, y = Math.abs(p) > Math.abs(s) ? n : e.x + p, x = Math.abs(g) > Math.abs(h) ? i : e.y + g;
|
|
730
|
+
this.parent.moveCenter(y, x), this.parent.emit("moved", { viewport: this.parent, type: "follow" });
|
|
731
|
+
}
|
|
732
|
+
} else {
|
|
733
|
+
const o = Math.atan2(i - e.y, n - e.x), r = Math.cos(o) * this.options.speed, a = Math.sin(o) * this.options.speed, p = Math.abs(r) > Math.abs(s) ? n : e.x + r, g = Math.abs(a) > Math.abs(h) ? i : e.y + a;
|
|
734
|
+
this.parent.moveCenter(p, g), this.parent.emit("moved", { viewport: this.parent, type: "follow" });
|
|
735
|
+
}
|
|
736
|
+
else
|
|
737
|
+
this.parent.moveCenter(n, i), this.parent.emit("moved", { viewport: this.parent, type: "follow" });
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
const Z = {
|
|
741
|
+
radius: null,
|
|
742
|
+
distance: null,
|
|
743
|
+
top: null,
|
|
744
|
+
bottom: null,
|
|
745
|
+
left: null,
|
|
746
|
+
right: null,
|
|
747
|
+
speed: 8,
|
|
748
|
+
reverse: !1,
|
|
749
|
+
noDecelerate: !1,
|
|
750
|
+
linear: !1,
|
|
751
|
+
allowButtons: !1
|
|
752
|
+
};
|
|
753
|
+
class N extends u {
|
|
754
|
+
constructor(t, e = {}) {
|
|
755
|
+
super(t), this.options = Object.assign({}, Z, e), this.reverse = this.options.reverse ? 1 : -1, this.radiusSquared = typeof this.options.radius == "number" ? Math.pow(this.options.radius, 2) : null, this.resize();
|
|
756
|
+
}
|
|
757
|
+
resize() {
|
|
758
|
+
const t = this.options.distance;
|
|
759
|
+
t !== null ? (this.left = t, this.top = t, this.right = this.parent.screenWidth - t, this.bottom = this.parent.screenHeight - t) : 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);
|
|
760
|
+
}
|
|
761
|
+
down() {
|
|
762
|
+
return this.paused || this.options.allowButtons || (this.horizontal = this.vertical = null), !1;
|
|
763
|
+
}
|
|
764
|
+
move(t) {
|
|
765
|
+
if (this.paused || t.data.pointerType !== "mouse" && t.data.identifier !== 1 || !this.options.allowButtons && t.data.buttons !== 0)
|
|
766
|
+
return !1;
|
|
767
|
+
const e = t.data.global.x, n = t.data.global.y;
|
|
768
|
+
if (this.radiusSquared) {
|
|
769
|
+
const i = this.parent.toScreen(this.parent.center);
|
|
770
|
+
if (Math.pow(i.x - e, 2) + Math.pow(i.y - n, 2) >= this.radiusSquared) {
|
|
771
|
+
const h = Math.atan2(i.y - n, i.x - e);
|
|
772
|
+
this.options.linear ? (this.horizontal = Math.round(Math.cos(h)) * this.options.speed * this.reverse * (60 / 1e3), this.vertical = Math.round(Math.sin(h)) * this.options.speed * this.reverse * (60 / 1e3)) : (this.horizontal = Math.cos(h) * this.options.speed * this.reverse * (60 / 1e3), this.vertical = Math.sin(h) * this.options.speed * this.reverse * (60 / 1e3));
|
|
773
|
+
} else
|
|
774
|
+
this.horizontal && this.decelerateHorizontal(), this.vertical && this.decelerateVertical(), this.horizontal = this.vertical = 0;
|
|
775
|
+
} else
|
|
776
|
+
this.left !== null && e < this.left ? this.horizontal = Number(this.reverse) * this.options.speed * (60 / 1e3) : this.right !== null && e > this.right ? this.horizontal = -1 * this.reverse * this.options.speed * (60 / 1e3) : (this.decelerateHorizontal(), this.horizontal = 0), this.top !== null && n < this.top ? this.vertical = Number(this.reverse) * this.options.speed * (60 / 1e3) : this.bottom !== null && n > this.bottom ? this.vertical = -1 * this.reverse * this.options.speed * (60 / 1e3) : (this.decelerateVertical(), this.vertical = 0);
|
|
777
|
+
return !1;
|
|
778
|
+
}
|
|
779
|
+
decelerateHorizontal() {
|
|
780
|
+
const t = this.parent.plugins.get("decelerate", !0);
|
|
781
|
+
this.horizontal && t && !this.options.noDecelerate && t.activate({ x: this.horizontal * this.options.speed * this.reverse / (1e3 / 60) });
|
|
782
|
+
}
|
|
783
|
+
decelerateVertical() {
|
|
784
|
+
const t = this.parent.plugins.get("decelerate", !0);
|
|
785
|
+
this.vertical && t && !this.options.noDecelerate && t.activate({ y: this.vertical * this.options.speed * this.reverse / (1e3 / 60) });
|
|
786
|
+
}
|
|
787
|
+
up() {
|
|
788
|
+
return this.paused || (this.horizontal && this.decelerateHorizontal(), this.vertical && this.decelerateVertical(), this.horizontal = this.vertical = null), !1;
|
|
789
|
+
}
|
|
790
|
+
update() {
|
|
791
|
+
if (!this.paused && (this.horizontal || this.vertical)) {
|
|
792
|
+
const t = this.parent.center;
|
|
793
|
+
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" });
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
const R = {
|
|
798
|
+
noDrag: !1,
|
|
799
|
+
percent: 1,
|
|
800
|
+
center: null,
|
|
801
|
+
factor: 1,
|
|
802
|
+
axis: "all"
|
|
803
|
+
};
|
|
804
|
+
class w extends u {
|
|
805
|
+
__init() {
|
|
806
|
+
this.active = !1;
|
|
807
|
+
}
|
|
808
|
+
__init2() {
|
|
809
|
+
this.pinching = !1;
|
|
810
|
+
}
|
|
811
|
+
__init3() {
|
|
812
|
+
this.moved = !1;
|
|
813
|
+
}
|
|
814
|
+
constructor(t, e = {}) {
|
|
815
|
+
super(t), w.prototype.__init.call(this), w.prototype.__init2.call(this), w.prototype.__init3.call(this), this.options = Object.assign({}, R, e);
|
|
816
|
+
}
|
|
817
|
+
down() {
|
|
818
|
+
return this.parent.input.count() >= 2 ? (this.active = !0, !0) : !1;
|
|
819
|
+
}
|
|
820
|
+
isAxisX() {
|
|
821
|
+
return ["all", "x"].includes(this.options.axis);
|
|
822
|
+
}
|
|
823
|
+
isAxisY() {
|
|
824
|
+
return ["all", "y"].includes(this.options.axis);
|
|
825
|
+
}
|
|
826
|
+
move(t) {
|
|
827
|
+
if (this.paused || !this.active)
|
|
828
|
+
return !1;
|
|
829
|
+
const e = t.data.global.x, n = t.data.global.y, i = this.parent.input.touches;
|
|
830
|
+
if (i.length >= 2) {
|
|
831
|
+
const s = i[0], h = i[1], o = s.last && h.last ? Math.sqrt(Math.pow(h.last.x - s.last.x, 2) + Math.pow(h.last.y - s.last.y, 2)) : null;
|
|
832
|
+
if (s.id === t.data.pointerId ? s.last = { x: e, y: n, data: t.data } : h.id === t.data.pointerId && (h.last = { x: e, y: n, data: t.data }), o) {
|
|
833
|
+
let r;
|
|
834
|
+
const a = {
|
|
835
|
+
x: s.last.x + (h.last.x - s.last.x) / 2,
|
|
836
|
+
y: s.last.y + (h.last.y - s.last.y) / 2
|
|
837
|
+
};
|
|
838
|
+
this.options.center || (r = this.parent.toLocal(a));
|
|
839
|
+
let p = Math.sqrt(Math.pow(
|
|
840
|
+
h.last.x - s.last.x,
|
|
841
|
+
2
|
|
842
|
+
) + Math.pow(h.last.y - s.last.y, 2));
|
|
843
|
+
p = p === 0 ? p = 1e-10 : p;
|
|
844
|
+
const g = (1 - o / p) * this.options.percent * (this.isAxisX() ? this.parent.scale.x : this.parent.scale.y);
|
|
845
|
+
this.isAxisX() && (this.parent.scale.x += g), this.isAxisY() && (this.parent.scale.y += g), this.parent.emit("zoomed", { viewport: this.parent, type: "pinch", center: a });
|
|
846
|
+
const y = this.parent.plugins.get("clamp-zoom", !0);
|
|
847
|
+
if (y && y.clamp(), this.options.center)
|
|
848
|
+
this.parent.moveCenter(this.options.center);
|
|
849
|
+
else {
|
|
850
|
+
const x = this.parent.toGlobal(r);
|
|
851
|
+
this.parent.x += (a.x - x.x) * this.options.factor, this.parent.y += (a.y - x.y) * this.options.factor, this.parent.emit("moved", { viewport: this.parent, type: "pinch" });
|
|
852
|
+
}
|
|
853
|
+
!this.options.noDrag && this.lastCenter && (this.parent.x += (a.x - this.lastCenter.x) * this.options.factor, this.parent.y += (a.y - this.lastCenter.y) * this.options.factor, this.parent.emit("moved", { viewport: this.parent, type: "pinch" })), this.lastCenter = a, this.moved = !0;
|
|
854
|
+
} else
|
|
855
|
+
this.pinching || (this.parent.emit("pinch-start", this.parent), this.pinching = !0);
|
|
856
|
+
return !0;
|
|
857
|
+
}
|
|
858
|
+
return !1;
|
|
859
|
+
}
|
|
860
|
+
up() {
|
|
861
|
+
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) : !1;
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
const j = {
|
|
865
|
+
topLeft: !1,
|
|
866
|
+
friction: 0.8,
|
|
867
|
+
time: 1e3,
|
|
868
|
+
ease: "easeInOutSine",
|
|
869
|
+
interrupt: !0,
|
|
870
|
+
removeOnComplete: !1,
|
|
871
|
+
removeOnInterrupt: !1,
|
|
872
|
+
forceStart: !1
|
|
873
|
+
};
|
|
874
|
+
class q extends u {
|
|
875
|
+
constructor(t, e, n, i = {}) {
|
|
876
|
+
super(t), this.options = Object.assign({}, j, i), this.ease = H(i.ease, "easeInOutSine"), this.x = e, this.y = n, this.options.forceStart && this.snapStart();
|
|
877
|
+
}
|
|
878
|
+
snapStart() {
|
|
879
|
+
this.percent = 0, this.snapping = { time: 0 };
|
|
880
|
+
const t = this.options.topLeft ? this.parent.corner : this.parent.center;
|
|
881
|
+
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);
|
|
882
|
+
}
|
|
883
|
+
wheel() {
|
|
884
|
+
return this.options.removeOnInterrupt && this.parent.plugins.remove("snap"), !1;
|
|
885
|
+
}
|
|
886
|
+
down() {
|
|
887
|
+
return this.options.removeOnInterrupt ? this.parent.plugins.remove("snap") : this.options.interrupt && (this.snapping = null), !1;
|
|
888
|
+
}
|
|
889
|
+
up() {
|
|
890
|
+
if (this.parent.input.count() === 0) {
|
|
891
|
+
const t = this.parent.plugins.get("decelerate", !0);
|
|
892
|
+
t && (t.x || t.y) && (t.percentChangeX = t.percentChangeY = this.options.friction);
|
|
893
|
+
}
|
|
894
|
+
return !1;
|
|
895
|
+
}
|
|
896
|
+
update(t) {
|
|
897
|
+
if (!this.paused && !(this.options.interrupt && this.parent.input.count() !== 0))
|
|
898
|
+
if (this.snapping) {
|
|
899
|
+
const e = this.snapping;
|
|
900
|
+
e.time += t;
|
|
901
|
+
let n, i, s;
|
|
902
|
+
const h = this.startX, o = this.startY, r = this.deltaX, a = this.deltaY;
|
|
903
|
+
if (e.time > this.options.time)
|
|
904
|
+
n = !0, i = h + r, s = o + a;
|
|
905
|
+
else {
|
|
906
|
+
const p = this.ease(e.time, 0, 1, this.options.time);
|
|
907
|
+
i = h + r * p, s = o + a * p;
|
|
908
|
+
}
|
|
909
|
+
this.options.topLeft ? this.parent.moveCorner(i, s) : this.parent.moveCenter(i, s), this.parent.emit("moved", { viewport: this.parent, type: "snap" }), n && (this.options.removeOnComplete && this.parent.plugins.remove("snap"), this.parent.emit("snap-end", this.parent), this.snapping = null);
|
|
910
|
+
} else {
|
|
911
|
+
const e = this.options.topLeft ? this.parent.corner : this.parent.center;
|
|
912
|
+
(e.x !== this.x || e.y !== this.y) && this.snapStart();
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
const K = {
|
|
917
|
+
width: 0,
|
|
918
|
+
height: 0,
|
|
919
|
+
time: 1e3,
|
|
920
|
+
ease: "easeInOutSine",
|
|
921
|
+
center: null,
|
|
922
|
+
interrupt: !0,
|
|
923
|
+
removeOnComplete: !1,
|
|
924
|
+
removeOnInterrupt: !1,
|
|
925
|
+
forceStart: !1,
|
|
926
|
+
noMove: !1
|
|
927
|
+
};
|
|
928
|
+
class G extends u {
|
|
929
|
+
constructor(t, e = {}) {
|
|
930
|
+
super(t), this.options = Object.assign({}, K, e), this.ease = H(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, this.options.time === 0 ? (t.container.scale.x = this.xScale, t.container.scale.y = this.yScale, this.options.removeOnComplete && this.parent.plugins.remove("snap-zoom")) : e.forceStart && this.createSnapping();
|
|
931
|
+
}
|
|
932
|
+
createSnapping() {
|
|
933
|
+
const t = this.parent.worldScreenWidth, e = this.parent.worldScreenHeight, n = this.parent.screenWidth / this.xScale, i = this.parent.screenHeight / this.yScale;
|
|
934
|
+
this.snapping = {
|
|
935
|
+
time: 0,
|
|
936
|
+
startX: t,
|
|
937
|
+
startY: e,
|
|
938
|
+
deltaX: n - t,
|
|
939
|
+
deltaY: i - e
|
|
940
|
+
}, this.parent.emit("snap-zoom-start", this.parent);
|
|
941
|
+
}
|
|
942
|
+
resize() {
|
|
943
|
+
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;
|
|
944
|
+
}
|
|
945
|
+
wheel() {
|
|
946
|
+
return this.options.removeOnInterrupt && this.parent.plugins.remove("snap-zoom"), !1;
|
|
947
|
+
}
|
|
948
|
+
down() {
|
|
949
|
+
return this.options.removeOnInterrupt ? this.parent.plugins.remove("snap-zoom") : this.options.interrupt && (this.snapping = null), !1;
|
|
950
|
+
}
|
|
951
|
+
update(t) {
|
|
952
|
+
if (this.paused || this.options.interrupt && this.parent.input.count() !== 0)
|
|
953
|
+
return;
|
|
954
|
+
let e;
|
|
955
|
+
if (!this.options.center && !this.options.noMove && (e = this.parent.center), !this.snapping)
|
|
956
|
+
(this.parent.scale.x !== this.xScale || this.parent.scale.y !== this.yScale) && this.createSnapping();
|
|
957
|
+
else if (this.snapping) {
|
|
958
|
+
const n = this.snapping;
|
|
959
|
+
if (n.time += t, n.time >= this.options.time)
|
|
960
|
+
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;
|
|
961
|
+
else {
|
|
962
|
+
const s = this.snapping, h = this.ease(s.time, s.startX, s.deltaX, this.options.time), o = this.ease(s.time, s.startY, s.deltaY, this.options.time);
|
|
963
|
+
this.parent.scale.x = this.parent.screenWidth / h, this.parent.scale.y = this.parent.screenHeight / o;
|
|
964
|
+
}
|
|
965
|
+
const i = this.parent.plugins.get("clamp-zoom", !0);
|
|
966
|
+
i && i.clamp(), this.options.noMove || (this.options.center ? this.parent.moveCenter(this.options.center) : this.parent.moveCenter(e));
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
resume() {
|
|
970
|
+
this.snapping = null, super.resume();
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
const Q = {
|
|
974
|
+
percent: 0.1,
|
|
975
|
+
smooth: !1,
|
|
976
|
+
interrupt: !0,
|
|
977
|
+
reverse: !1,
|
|
978
|
+
center: null,
|
|
979
|
+
lineHeight: 20,
|
|
980
|
+
axis: "all",
|
|
981
|
+
keyToPress: null,
|
|
982
|
+
trackpadPinch: !1,
|
|
983
|
+
wheelZoom: !0
|
|
984
|
+
};
|
|
985
|
+
class $ extends u {
|
|
986
|
+
constructor(t, e = {}) {
|
|
987
|
+
super(t), this.options = Object.assign({}, Q, e), this.keyIsPressed = !1, this.options.keyToPress && this.handleKeyPresses(this.options.keyToPress);
|
|
988
|
+
}
|
|
989
|
+
handleKeyPresses(t) {
|
|
990
|
+
window.addEventListener("keydown", (e) => {
|
|
991
|
+
t.includes(e.code) && (this.keyIsPressed = !0);
|
|
992
|
+
}), window.addEventListener("keyup", (e) => {
|
|
993
|
+
t.includes(e.code) && (this.keyIsPressed = !1);
|
|
994
|
+
});
|
|
995
|
+
}
|
|
996
|
+
checkKeyPress() {
|
|
997
|
+
return !this.options.keyToPress || this.keyIsPressed;
|
|
998
|
+
}
|
|
999
|
+
down() {
|
|
1000
|
+
return this.options.interrupt && (this.smoothing = null), !1;
|
|
1001
|
+
}
|
|
1002
|
+
isAxisX() {
|
|
1003
|
+
return ["all", "x"].includes(this.options.axis);
|
|
1004
|
+
}
|
|
1005
|
+
isAxisY() {
|
|
1006
|
+
return ["all", "y"].includes(this.options.axis);
|
|
1007
|
+
}
|
|
1008
|
+
update() {
|
|
1009
|
+
if (this.smoothing) {
|
|
1010
|
+
const t = this.smoothingCenter, e = this.smoothing;
|
|
1011
|
+
let n;
|
|
1012
|
+
this.options.center || (n = this.parent.toLocal(t)), this.isAxisX() && (this.parent.scale.x += e.x), this.isAxisY() && (this.parent.scale.y += e.y), this.parent.emit("zoomed", { viewport: this.parent, type: "wheel" });
|
|
1013
|
+
const i = this.parent.plugins.get("clamp-zoom", !0);
|
|
1014
|
+
if (i && i.clamp(), this.options.center)
|
|
1015
|
+
this.parent.moveCenter(this.options.center);
|
|
1016
|
+
else {
|
|
1017
|
+
const s = this.parent.toGlobal(n);
|
|
1018
|
+
this.parent.x += t.x - s.x, this.parent.y += t.y - s.y;
|
|
1019
|
+
}
|
|
1020
|
+
this.parent.emit("moved", { viewport: this.parent, type: "wheel" }), this.smoothingCount++, this.smoothingCount >= this.options.smooth && (this.smoothing = null);
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
pinch(t) {
|
|
1024
|
+
if (this.paused)
|
|
1025
|
+
return;
|
|
1026
|
+
const e = this.parent.input.getPointerPosition(t), n = -t.deltaY * (t.deltaMode ? this.options.lineHeight : 1) / 200, i = Math.pow(2, (1 + this.options.percent) * n);
|
|
1027
|
+
let s;
|
|
1028
|
+
this.options.center || (s = this.parent.toLocal(e)), this.isAxisX() && (this.parent.scale.x *= i), this.isAxisY() && (this.parent.scale.y *= i), this.parent.emit("zoomed", { viewport: this.parent, type: "wheel" });
|
|
1029
|
+
const h = this.parent.plugins.get("clamp-zoom", !0);
|
|
1030
|
+
if (h && h.clamp(), this.options.center)
|
|
1031
|
+
this.parent.moveCenter(this.options.center);
|
|
1032
|
+
else {
|
|
1033
|
+
const o = this.parent.toGlobal(s);
|
|
1034
|
+
this.parent.x += e.x - o.x, this.parent.y += e.y - o.y;
|
|
1035
|
+
}
|
|
1036
|
+
this.parent.emit("moved", { viewport: this.parent, type: "wheel" }), this.parent.emit(
|
|
1037
|
+
"wheel",
|
|
1038
|
+
{ wheel: { dx: t.deltaX, dy: t.deltaY, dz: t.deltaZ }, event: t, viewport: this.parent }
|
|
1039
|
+
);
|
|
1040
|
+
}
|
|
1041
|
+
wheel(t) {
|
|
1042
|
+
if (this.paused || !this.checkKeyPress())
|
|
1043
|
+
return !1;
|
|
1044
|
+
if (t.ctrlKey && this.options.trackpadPinch)
|
|
1045
|
+
this.pinch(t);
|
|
1046
|
+
else if (this.options.wheelZoom) {
|
|
1047
|
+
const e = this.parent.input.getPointerPosition(t), i = (this.options.reverse ? -1 : 1) * -t.deltaY * (t.deltaMode ? this.options.lineHeight : 1) / 500, s = Math.pow(2, (1 + this.options.percent) * i);
|
|
1048
|
+
if (this.options.smooth) {
|
|
1049
|
+
const h = {
|
|
1050
|
+
x: this.smoothing ? this.smoothing.x * (this.options.smooth - this.smoothingCount) : 0,
|
|
1051
|
+
y: this.smoothing ? this.smoothing.y * (this.options.smooth - this.smoothingCount) : 0
|
|
1052
|
+
};
|
|
1053
|
+
this.smoothing = {
|
|
1054
|
+
x: ((this.parent.scale.x + h.x) * s - this.parent.scale.x) / this.options.smooth,
|
|
1055
|
+
y: ((this.parent.scale.y + h.y) * s - this.parent.scale.y) / this.options.smooth
|
|
1056
|
+
}, this.smoothingCount = 0, this.smoothingCenter = e;
|
|
1057
|
+
} else {
|
|
1058
|
+
let h;
|
|
1059
|
+
this.options.center || (h = this.parent.toLocal(e)), this.isAxisX() && (this.parent.scale.x *= s), this.isAxisY() && (this.parent.scale.y *= s), this.parent.emit("zoomed", { viewport: this.parent, type: "wheel" });
|
|
1060
|
+
const o = this.parent.plugins.get("clamp-zoom", !0);
|
|
1061
|
+
if (o && o.clamp(), this.options.center)
|
|
1062
|
+
this.parent.moveCenter(this.options.center);
|
|
1063
|
+
else {
|
|
1064
|
+
const r = this.parent.toGlobal(h);
|
|
1065
|
+
this.parent.x += e.x - r.x, this.parent.y += e.y - r.y;
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
this.parent.emit("moved", { viewport: this.parent, type: "wheel" }), this.parent.emit(
|
|
1069
|
+
"wheel",
|
|
1070
|
+
{ wheel: { dx: t.deltaX, dy: t.deltaY, dz: t.deltaZ }, event: t, viewport: this.parent }
|
|
1071
|
+
);
|
|
1072
|
+
}
|
|
1073
|
+
return !this.parent.options.passiveWheel;
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
class J {
|
|
1077
|
+
constructor(t) {
|
|
1078
|
+
this.viewport = t, this.touches = [], this.addListeners();
|
|
1079
|
+
}
|
|
1080
|
+
addListeners() {
|
|
1081
|
+
this.viewport.interactive = !0, this.viewport.forceHitArea || (this.viewport.hitArea = new b(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(
|
|
1082
|
+
"wheel",
|
|
1083
|
+
this.wheelFunction,
|
|
1084
|
+
{ passive: this.viewport.options.passiveWheel }
|
|
1085
|
+
), this.isMouseDown = !1;
|
|
1086
|
+
}
|
|
1087
|
+
destroy() {
|
|
1088
|
+
this.viewport.options.divWheel.removeEventListener("wheel", this.wheelFunction);
|
|
1089
|
+
}
|
|
1090
|
+
down(t) {
|
|
1091
|
+
if (this.viewport.pause || !this.viewport.worldVisible)
|
|
1092
|
+
return;
|
|
1093
|
+
if (t.data.pointerType === "mouse" ? this.isMouseDown = !0 : this.get(t.data.pointerId) || this.touches.push({ id: t.data.pointerId, last: null }), this.count() === 1) {
|
|
1094
|
+
this.last = t.data.global.clone();
|
|
1095
|
+
const n = this.viewport.plugins.get("decelerate", !0), i = this.viewport.plugins.get("bounce", !0);
|
|
1096
|
+
(!n || !n.isActive()) && (!i || !i.isActive()) ? this.clickedAvailable = !0 : this.clickedAvailable = !1;
|
|
1097
|
+
} else
|
|
1098
|
+
this.clickedAvailable = !1;
|
|
1099
|
+
this.viewport.plugins.down(t) && this.viewport.options.stopPropagation && t.stopPropagation();
|
|
1100
|
+
}
|
|
1101
|
+
clear() {
|
|
1102
|
+
this.isMouseDown = !1, this.touches = [], this.last = null;
|
|
1103
|
+
}
|
|
1104
|
+
checkThreshold(t) {
|
|
1105
|
+
return Math.abs(t) >= this.viewport.threshold;
|
|
1106
|
+
}
|
|
1107
|
+
move(t) {
|
|
1108
|
+
if (this.viewport.pause || !this.viewport.worldVisible)
|
|
1109
|
+
return;
|
|
1110
|
+
const e = this.viewport.plugins.move(t);
|
|
1111
|
+
if (this.clickedAvailable && this.last) {
|
|
1112
|
+
const n = t.data.global.x - this.last.x, i = t.data.global.y - this.last.y;
|
|
1113
|
+
(this.checkThreshold(n) || this.checkThreshold(i)) && (this.clickedAvailable = !1);
|
|
1114
|
+
}
|
|
1115
|
+
e && this.viewport.options.stopPropagation && t.stopPropagation();
|
|
1116
|
+
}
|
|
1117
|
+
up(t) {
|
|
1118
|
+
if (this.viewport.pause || !this.viewport.worldVisible)
|
|
1119
|
+
return;
|
|
1120
|
+
t.data.pointerType === "mouse" && (this.isMouseDown = !1), t.data.pointerType !== "mouse" && this.remove(t.data.pointerId);
|
|
1121
|
+
const e = this.viewport.plugins.up(t);
|
|
1122
|
+
this.clickedAvailable && this.count() === 0 && this.last && (this.viewport.emit("clicked", {
|
|
1123
|
+
event: t,
|
|
1124
|
+
screen: this.last,
|
|
1125
|
+
world: this.viewport.toWorld(this.last),
|
|
1126
|
+
viewport: this
|
|
1127
|
+
}), this.clickedAvailable = !1), e && this.viewport.options.stopPropagation && t.stopPropagation();
|
|
1128
|
+
}
|
|
1129
|
+
getPointerPosition(t) {
|
|
1130
|
+
const e = new c();
|
|
1131
|
+
if (this.viewport.options.interaction)
|
|
1132
|
+
this.viewport.options.interaction.mapPositionToPoint(e, t.clientX, t.clientY);
|
|
1133
|
+
else if (this.viewport.options.useDivWheelForInputManager && this.viewport.options.divWheel) {
|
|
1134
|
+
const n = this.viewport.options.divWheel.getBoundingClientRect();
|
|
1135
|
+
e.x = t.clientX - n.left, e.y = t.clientY - n.top;
|
|
1136
|
+
} else
|
|
1137
|
+
e.x = t.clientX, e.y = t.clientY;
|
|
1138
|
+
return e;
|
|
1139
|
+
}
|
|
1140
|
+
handleWheel(t) {
|
|
1141
|
+
if (this.viewport.pause || !this.viewport.worldVisible || this.viewport.options.interaction && this.viewport.options.interaction.interactionDOMElement !== t.target)
|
|
1142
|
+
return;
|
|
1143
|
+
const e = this.viewport.toLocal(this.getPointerPosition(t));
|
|
1144
|
+
this.viewport.left <= e.x && e.x <= this.viewport.right && this.viewport.top <= e.y && e.y <= this.viewport.bottom && this.viewport.plugins.wheel(t) && !this.viewport.options.passiveWheel && t.preventDefault();
|
|
1145
|
+
}
|
|
1146
|
+
pause() {
|
|
1147
|
+
this.touches = [], this.isMouseDown = !1;
|
|
1148
|
+
}
|
|
1149
|
+
get(t) {
|
|
1150
|
+
for (const e of this.touches)
|
|
1151
|
+
if (e.id === t)
|
|
1152
|
+
return e;
|
|
1153
|
+
return null;
|
|
1154
|
+
}
|
|
1155
|
+
remove(t) {
|
|
1156
|
+
for (let e = 0; e < this.touches.length; e++)
|
|
1157
|
+
if (this.touches[e].id === t) {
|
|
1158
|
+
this.touches.splice(e, 1);
|
|
1159
|
+
return;
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
count() {
|
|
1163
|
+
return (this.isMouseDown ? 1 : 0) + this.touches.length;
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
function W(l) {
|
|
1167
|
+
let t, e = l[0], n = 1;
|
|
1168
|
+
for (; n < l.length; ) {
|
|
1169
|
+
const i = l[n], s = l[n + 1];
|
|
1170
|
+
if (n += 2, (i === "optionalAccess" || i === "optionalCall") && e == null)
|
|
1171
|
+
return;
|
|
1172
|
+
i === "access" || i === "optionalAccess" ? (t = e, e = s(e)) : (i === "call" || i === "optionalCall") && (e = s((...h) => e.call(t, ...h)), t = void 0);
|
|
1173
|
+
}
|
|
1174
|
+
return e;
|
|
1175
|
+
}
|
|
1176
|
+
const m = [
|
|
1177
|
+
"drag",
|
|
1178
|
+
"pinch",
|
|
1179
|
+
"wheel",
|
|
1180
|
+
"follow",
|
|
1181
|
+
"mouse-edges",
|
|
1182
|
+
"decelerate",
|
|
1183
|
+
"animate",
|
|
1184
|
+
"bounce",
|
|
1185
|
+
"snap-zoom",
|
|
1186
|
+
"clamp-zoom",
|
|
1187
|
+
"snap",
|
|
1188
|
+
"clamp"
|
|
1189
|
+
];
|
|
1190
|
+
class tt {
|
|
1191
|
+
constructor(t) {
|
|
1192
|
+
this.viewport = t, this.list = [], this.plugins = {};
|
|
1193
|
+
}
|
|
1194
|
+
add(t, e, n = m.length) {
|
|
1195
|
+
const i = this.plugins[t];
|
|
1196
|
+
i && i.destroy(), this.plugins[t] = e;
|
|
1197
|
+
const s = m.indexOf(t);
|
|
1198
|
+
s !== -1 && m.splice(s, 1), m.splice(n, 0, t), this.sort();
|
|
1199
|
+
}
|
|
1200
|
+
get(t, e) {
|
|
1201
|
+
return e && W([this, "access", (n) => n.plugins, "access", (n) => n[t], "optionalAccess", (n) => n.paused]) ? null : this.plugins[t];
|
|
1202
|
+
}
|
|
1203
|
+
update(t) {
|
|
1204
|
+
for (const e of this.list)
|
|
1205
|
+
e.update(t);
|
|
1206
|
+
}
|
|
1207
|
+
resize() {
|
|
1208
|
+
for (const t of this.list)
|
|
1209
|
+
t.resize();
|
|
1210
|
+
}
|
|
1211
|
+
reset() {
|
|
1212
|
+
for (const t of this.list)
|
|
1213
|
+
t.reset();
|
|
1214
|
+
}
|
|
1215
|
+
removeAll() {
|
|
1216
|
+
this.list.forEach((t) => {
|
|
1217
|
+
t.destroy();
|
|
1218
|
+
}), this.plugins = {}, this.sort();
|
|
1219
|
+
}
|
|
1220
|
+
remove(t) {
|
|
1221
|
+
this.plugins[t] && (W([this, "access", (e) => e.plugins, "access", (e) => e[t], "optionalAccess", (e) => e.destroy, "call", (e) => e()]), delete this.plugins[t], this.viewport.emit(`${t}-remove`), this.sort());
|
|
1222
|
+
}
|
|
1223
|
+
pause(t) {
|
|
1224
|
+
W([this, "access", (e) => e.plugins, "access", (e) => e[t], "optionalAccess", (e) => e.pause, "call", (e) => e()]);
|
|
1225
|
+
}
|
|
1226
|
+
resume(t) {
|
|
1227
|
+
W([this, "access", (e) => e.plugins, "access", (e) => e[t], "optionalAccess", (e) => e.resume, "call", (e) => e()]);
|
|
1228
|
+
}
|
|
1229
|
+
sort() {
|
|
1230
|
+
this.list = [];
|
|
1231
|
+
for (const t of m)
|
|
1232
|
+
this.plugins[t] && this.list.push(this.plugins[t]);
|
|
1233
|
+
}
|
|
1234
|
+
down(t) {
|
|
1235
|
+
let e = !1;
|
|
1236
|
+
for (const n of this.list)
|
|
1237
|
+
n.down(t) && (e = !0);
|
|
1238
|
+
return e;
|
|
1239
|
+
}
|
|
1240
|
+
move(t) {
|
|
1241
|
+
let e = !1;
|
|
1242
|
+
for (const n of this.viewport.plugins.list)
|
|
1243
|
+
n.move(t) && (e = !0);
|
|
1244
|
+
return e;
|
|
1245
|
+
}
|
|
1246
|
+
up(t) {
|
|
1247
|
+
let e = !1;
|
|
1248
|
+
for (const n of this.list)
|
|
1249
|
+
n.up(t) && (e = !0);
|
|
1250
|
+
return e;
|
|
1251
|
+
}
|
|
1252
|
+
wheel(t) {
|
|
1253
|
+
let e = !1;
|
|
1254
|
+
for (const n of this.list)
|
|
1255
|
+
n.wheel(t) && (e = !0);
|
|
1256
|
+
return e;
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
const et = {
|
|
1260
|
+
screenWidth: window.innerWidth,
|
|
1261
|
+
screenHeight: window.innerHeight,
|
|
1262
|
+
worldWidth: null,
|
|
1263
|
+
worldHeight: null,
|
|
1264
|
+
threshold: 5,
|
|
1265
|
+
passiveWheel: !0,
|
|
1266
|
+
stopPropagation: !1,
|
|
1267
|
+
forceHitArea: null,
|
|
1268
|
+
noTicker: !1,
|
|
1269
|
+
interaction: null,
|
|
1270
|
+
disableOnContextMenu: !1,
|
|
1271
|
+
ticker: C.shared
|
|
1272
|
+
};
|
|
1273
|
+
class O extends P {
|
|
1274
|
+
__init() {
|
|
1275
|
+
this._disableOnContextMenu = (t) => t.preventDefault();
|
|
1276
|
+
}
|
|
1277
|
+
constructor(t = {}) {
|
|
1278
|
+
super(), O.prototype.__init.call(this), this.options = Object.assign(
|
|
1279
|
+
{},
|
|
1280
|
+
{ divWheel: document.body },
|
|
1281
|
+
et,
|
|
1282
|
+
t
|
|
1283
|
+
), 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.addEventListener("contextmenu", this._disableOnContextMenu), this.options.noTicker || (this.tickerFunction = () => this.update(this.options.ticker.elapsedMS), this.options.ticker.add(this.tickerFunction)), this.input = new J(this), this.plugins = new tt(this);
|
|
1284
|
+
}
|
|
1285
|
+
destroy(t) {
|
|
1286
|
+
!this.options.noTicker && this.tickerFunction && this.options.ticker.remove(this.tickerFunction), this.options.disableOnContextMenu && this.options.divWheel.removeEventListener("contextmenu", this._disableOnContextMenu), this.input.destroy(), super.destroy(t);
|
|
1287
|
+
}
|
|
1288
|
+
update(t) {
|
|
1289
|
+
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 b(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 = {
|
|
1290
|
+
x: this.x,
|
|
1291
|
+
y: this.y,
|
|
1292
|
+
scaleX: this.scale.x,
|
|
1293
|
+
scaleY: this.scale.y
|
|
1294
|
+
}, this.emit("frame-end", this));
|
|
1295
|
+
}
|
|
1296
|
+
resize(t = window.innerWidth, e = window.innerHeight, n, i) {
|
|
1297
|
+
this.screenWidth = t, this.screenHeight = e, typeof n < "u" && (this._worldWidth = n), typeof i < "u" && (this._worldHeight = i), this.plugins.resize(), this.dirty = !0;
|
|
1298
|
+
}
|
|
1299
|
+
get worldWidth() {
|
|
1300
|
+
return this._worldWidth ? this._worldWidth : this.width / this.scale.x;
|
|
1301
|
+
}
|
|
1302
|
+
set worldWidth(t) {
|
|
1303
|
+
this._worldWidth = t, this.plugins.resize();
|
|
1304
|
+
}
|
|
1305
|
+
get worldHeight() {
|
|
1306
|
+
return this._worldHeight ? this._worldHeight : this.height / this.scale.y;
|
|
1307
|
+
}
|
|
1308
|
+
set worldHeight(t) {
|
|
1309
|
+
this._worldHeight = t, this.plugins.resize();
|
|
1310
|
+
}
|
|
1311
|
+
getVisibleBounds() {
|
|
1312
|
+
return new b(this.left, this.top, this.worldScreenWidth, this.worldScreenHeight);
|
|
1313
|
+
}
|
|
1314
|
+
toWorld(t, e) {
|
|
1315
|
+
return arguments.length === 2 ? this.toLocal(new c(t, e)) : this.toLocal(t);
|
|
1316
|
+
}
|
|
1317
|
+
toScreen(t, e) {
|
|
1318
|
+
return arguments.length === 2 ? this.toGlobal(new c(t, e)) : this.toGlobal(t);
|
|
1319
|
+
}
|
|
1320
|
+
get worldScreenWidth() {
|
|
1321
|
+
return this.screenWidth / this.scale.x;
|
|
1322
|
+
}
|
|
1323
|
+
get worldScreenHeight() {
|
|
1324
|
+
return this.screenHeight / this.scale.y;
|
|
1325
|
+
}
|
|
1326
|
+
get screenWorldWidth() {
|
|
1327
|
+
return this.worldWidth * this.scale.x;
|
|
1328
|
+
}
|
|
1329
|
+
get screenWorldHeight() {
|
|
1330
|
+
return this.worldHeight * this.scale.y;
|
|
1331
|
+
}
|
|
1332
|
+
get center() {
|
|
1333
|
+
return new c(
|
|
1334
|
+
this.worldScreenWidth / 2 - this.x / this.scale.x,
|
|
1335
|
+
this.worldScreenHeight / 2 - this.y / this.scale.y
|
|
1336
|
+
);
|
|
1337
|
+
}
|
|
1338
|
+
set center(t) {
|
|
1339
|
+
this.moveCenter(t);
|
|
1340
|
+
}
|
|
1341
|
+
moveCenter(...t) {
|
|
1342
|
+
let e, n;
|
|
1343
|
+
typeof t[0] == "number" ? (e = t[0], n = t[1]) : (e = t[0].x, n = t[0].y);
|
|
1344
|
+
const i = (this.worldScreenWidth / 2 - e) * this.scale.x, s = (this.worldScreenHeight / 2 - n) * this.scale.y;
|
|
1345
|
+
return (this.x !== i || this.y !== s) && (this.position.set(i, s), this.plugins.reset(), this.dirty = !0), this;
|
|
1346
|
+
}
|
|
1347
|
+
get corner() {
|
|
1348
|
+
return new c(-this.x / this.scale.x, -this.y / this.scale.y);
|
|
1349
|
+
}
|
|
1350
|
+
set corner(t) {
|
|
1351
|
+
this.moveCorner(t);
|
|
1352
|
+
}
|
|
1353
|
+
moveCorner(...t) {
|
|
1354
|
+
let e, n;
|
|
1355
|
+
return t.length === 1 ? (e = -t[0].x * this.scale.x, n = -t[0].y * this.scale.y) : (e = -t[0] * this.scale.x, n = -t[1] * this.scale.y), (e !== this.x || n !== this.y) && (this.position.set(e, n), this.plugins.reset(), this.dirty = !0), this;
|
|
1356
|
+
}
|
|
1357
|
+
get screenWidthInWorldPixels() {
|
|
1358
|
+
return this.screenWidth / this.scale.x;
|
|
1359
|
+
}
|
|
1360
|
+
get screenHeightInWorldPixels() {
|
|
1361
|
+
return this.screenHeight / this.scale.y;
|
|
1362
|
+
}
|
|
1363
|
+
findFitWidth(t) {
|
|
1364
|
+
return this.screenWidth / t;
|
|
1365
|
+
}
|
|
1366
|
+
findFitHeight(t) {
|
|
1367
|
+
return this.screenHeight / t;
|
|
1368
|
+
}
|
|
1369
|
+
findFit(t, e) {
|
|
1370
|
+
const n = this.screenWidth / t, i = this.screenHeight / e;
|
|
1371
|
+
return Math.min(n, i);
|
|
1372
|
+
}
|
|
1373
|
+
findCover(t, e) {
|
|
1374
|
+
const n = this.screenWidth / t, i = this.screenHeight / e;
|
|
1375
|
+
return Math.max(n, i);
|
|
1376
|
+
}
|
|
1377
|
+
fitWidth(t = this.worldWidth, e, n = !0, i) {
|
|
1378
|
+
let s;
|
|
1379
|
+
e && (s = this.center), this.scale.x = this.screenWidth / t, n && (this.scale.y = this.scale.x);
|
|
1380
|
+
const h = this.plugins.get("clamp-zoom", !0);
|
|
1381
|
+
return !i && h && h.clamp(), e && s && this.moveCenter(s), this;
|
|
1382
|
+
}
|
|
1383
|
+
fitHeight(t = this.worldHeight, e, n = !0, i) {
|
|
1384
|
+
let s;
|
|
1385
|
+
e && (s = this.center), this.scale.y = this.screenHeight / t, n && (this.scale.x = this.scale.y);
|
|
1386
|
+
const h = this.plugins.get("clamp-zoom", !0);
|
|
1387
|
+
return !i && h && h.clamp(), e && s && this.moveCenter(s), this;
|
|
1388
|
+
}
|
|
1389
|
+
fitWorld(t) {
|
|
1390
|
+
let e;
|
|
1391
|
+
t && (e = 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;
|
|
1392
|
+
const n = this.plugins.get("clamp-zoom", !0);
|
|
1393
|
+
return n && n.clamp(), t && e && this.moveCenter(e), this;
|
|
1394
|
+
}
|
|
1395
|
+
fit(t, e = this.worldWidth, n = this.worldHeight) {
|
|
1396
|
+
let i;
|
|
1397
|
+
t && (i = this.center), this.scale.x = this.screenWidth / e, this.scale.y = this.screenHeight / n, this.scale.x < this.scale.y ? this.scale.y = this.scale.x : this.scale.x = this.scale.y;
|
|
1398
|
+
const s = this.plugins.get("clamp-zoom", !0);
|
|
1399
|
+
return s && s.clamp(), t && i && this.moveCenter(i), this;
|
|
1400
|
+
}
|
|
1401
|
+
setZoom(t, e) {
|
|
1402
|
+
let n;
|
|
1403
|
+
e && (n = this.center), this.scale.set(t);
|
|
1404
|
+
const i = this.plugins.get("clamp-zoom", !0);
|
|
1405
|
+
return i && i.clamp(), e && n && this.moveCenter(n), this;
|
|
1406
|
+
}
|
|
1407
|
+
zoomPercent(t, e) {
|
|
1408
|
+
return this.setZoom(this.scale.x + this.scale.x * t, e);
|
|
1409
|
+
}
|
|
1410
|
+
zoom(t, e) {
|
|
1411
|
+
return this.fitWidth(t + this.worldScreenWidth, e), this;
|
|
1412
|
+
}
|
|
1413
|
+
get scaled() {
|
|
1414
|
+
return this.scale.x;
|
|
1415
|
+
}
|
|
1416
|
+
set scaled(t) {
|
|
1417
|
+
this.setZoom(t, !0);
|
|
1418
|
+
}
|
|
1419
|
+
snapZoom(t) {
|
|
1420
|
+
return this.plugins.add("snap-zoom", new G(this, t)), this;
|
|
1421
|
+
}
|
|
1422
|
+
OOB() {
|
|
1423
|
+
return {
|
|
1424
|
+
left: this.left < 0,
|
|
1425
|
+
right: this.right > this.worldWidth,
|
|
1426
|
+
top: this.top < 0,
|
|
1427
|
+
bottom: this.bottom > this.worldHeight,
|
|
1428
|
+
cornerPoint: new c(
|
|
1429
|
+
this.worldWidth * this.scale.x - this.screenWidth,
|
|
1430
|
+
this.worldHeight * this.scale.y - this.screenHeight
|
|
1431
|
+
)
|
|
1432
|
+
};
|
|
1433
|
+
}
|
|
1434
|
+
get right() {
|
|
1435
|
+
return -this.x / this.scale.x + this.worldScreenWidth;
|
|
1436
|
+
}
|
|
1437
|
+
set right(t) {
|
|
1438
|
+
this.x = -t * this.scale.x + this.screenWidth, this.plugins.reset();
|
|
1439
|
+
}
|
|
1440
|
+
get left() {
|
|
1441
|
+
return -this.x / this.scale.x;
|
|
1442
|
+
}
|
|
1443
|
+
set left(t) {
|
|
1444
|
+
this.x = -t * this.scale.x, this.plugins.reset();
|
|
1445
|
+
}
|
|
1446
|
+
get top() {
|
|
1447
|
+
return -this.y / this.scale.y;
|
|
1448
|
+
}
|
|
1449
|
+
set top(t) {
|
|
1450
|
+
this.y = -t * this.scale.y, this.plugins.reset();
|
|
1451
|
+
}
|
|
1452
|
+
get bottom() {
|
|
1453
|
+
return -this.y / this.scale.y + this.worldScreenHeight;
|
|
1454
|
+
}
|
|
1455
|
+
set bottom(t) {
|
|
1456
|
+
this.y = -t * this.scale.y + this.screenHeight, this.plugins.reset();
|
|
1457
|
+
}
|
|
1458
|
+
get dirty() {
|
|
1459
|
+
return !!this._dirty;
|
|
1460
|
+
}
|
|
1461
|
+
set dirty(t) {
|
|
1462
|
+
this._dirty = t;
|
|
1463
|
+
}
|
|
1464
|
+
get forceHitArea() {
|
|
1465
|
+
return this._forceHitArea;
|
|
1466
|
+
}
|
|
1467
|
+
set forceHitArea(t) {
|
|
1468
|
+
t ? (this._forceHitArea = t, this.hitArea = t) : (this._forceHitArea = null, this.hitArea = new b(0, 0, this.worldWidth, this.worldHeight));
|
|
1469
|
+
}
|
|
1470
|
+
drag(t) {
|
|
1471
|
+
return this.plugins.add("drag", new S(this, t)), this;
|
|
1472
|
+
}
|
|
1473
|
+
clamp(t) {
|
|
1474
|
+
return this.plugins.add("clamp", new T(this, t)), this;
|
|
1475
|
+
}
|
|
1476
|
+
decelerate(t) {
|
|
1477
|
+
return this.plugins.add("decelerate", new U(this, t)), this;
|
|
1478
|
+
}
|
|
1479
|
+
bounce(t) {
|
|
1480
|
+
return this.plugins.add("bounce", new z(this, t)), this;
|
|
1481
|
+
}
|
|
1482
|
+
pinch(t) {
|
|
1483
|
+
return this.plugins.add("pinch", new w(this, t)), this;
|
|
1484
|
+
}
|
|
1485
|
+
snap(t, e, n) {
|
|
1486
|
+
return this.plugins.add("snap", new q(this, t, e, n)), this;
|
|
1487
|
+
}
|
|
1488
|
+
follow(t, e) {
|
|
1489
|
+
return this.plugins.add("follow", new V(this, t, e)), this;
|
|
1490
|
+
}
|
|
1491
|
+
wheel(t) {
|
|
1492
|
+
return this.plugins.add("wheel", new $(this, t)), this;
|
|
1493
|
+
}
|
|
1494
|
+
animate(t) {
|
|
1495
|
+
return this.plugins.add("animate", new d(this, t)), this;
|
|
1496
|
+
}
|
|
1497
|
+
clampZoom(t) {
|
|
1498
|
+
return this.plugins.add("clamp-zoom", new L(this, t)), this;
|
|
1499
|
+
}
|
|
1500
|
+
mouseEdges(t) {
|
|
1501
|
+
return this.plugins.add("mouse-edges", new N(this, t)), this;
|
|
1502
|
+
}
|
|
1503
|
+
get pause() {
|
|
1504
|
+
return !!this._pause;
|
|
1505
|
+
}
|
|
1506
|
+
set pause(t) {
|
|
1507
|
+
this._pause = t, this.lastViewport = null, this.moving = !1, this.zooming = !1, t && this.input.pause();
|
|
1508
|
+
}
|
|
1509
|
+
ensureVisible(t, e, n, i, s) {
|
|
1510
|
+
s && (n > this.worldScreenWidth || i > this.worldScreenHeight) && (this.fit(!0, n, i), this.emit("zoomed", { viewport: this, type: "ensureVisible" }));
|
|
1511
|
+
let h = !1;
|
|
1512
|
+
t < this.left ? (this.left = t, h = !0) : t + n > this.right && (this.right = t + n, h = !0), e < this.top ? (this.top = e, h = !0) : e + i > this.bottom && (this.bottom = e + i, h = !0), h && this.emit("moved", { viewport: this, type: "ensureVisible" });
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
export {
|
|
1516
|
+
d as Animate,
|
|
1517
|
+
z as Bounce,
|
|
1518
|
+
T as Clamp,
|
|
1519
|
+
L as ClampZoom,
|
|
1520
|
+
U as Decelerate,
|
|
1521
|
+
S as Drag,
|
|
1522
|
+
V as Follow,
|
|
1523
|
+
J as InputManager,
|
|
1524
|
+
N as MouseEdges,
|
|
1525
|
+
w as Pinch,
|
|
1526
|
+
u as Plugin,
|
|
1527
|
+
tt as PluginManager,
|
|
1528
|
+
q as Snap,
|
|
1529
|
+
G as SnapZoom,
|
|
1530
|
+
O as Viewport,
|
|
1531
|
+
$ as Wheel
|
|
1532
|
+
};
|
|
1533
|
+
//# sourceMappingURL=viewport.es-fd5aad9a.mjs.map
|