@prefecthq/graphs 2.0.5 → 2.1.0

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.
Files changed (129) hide show
  1. package/dist/assets/runGraph.worker-57858a3b.js.map +1 -0
  2. package/dist/graphs.mjs +31635 -5
  3. package/dist/graphs.mjs.map +1 -1
  4. package/dist/graphs.umd.js +693 -1093
  5. package/dist/graphs.umd.js.map +1 -1
  6. package/dist/style.css +1 -1
  7. package/dist/types/demo/{sections/components/FlowRunTimelineDemo.vue.d.ts → components/AppComponentNavigationItems.vue.d.ts} +5 -0
  8. package/dist/types/demo/components/{HashLink.vue.d.ts → AppNavigationBar.vue.d.ts} +5 -3
  9. package/dist/types/demo/main.d.ts +1 -1
  10. package/dist/types/src/components/RunGraph.vue.d.ts +39 -0
  11. package/dist/types/src/components/index.d.ts +1 -0
  12. package/dist/types/src/consts.d.ts +16 -0
  13. package/dist/types/src/factories/animation.d.ts +4 -0
  14. package/dist/types/src/factories/arrow.d.ts +15 -0
  15. package/dist/types/src/factories/bar.d.ts +13 -0
  16. package/dist/types/src/factories/border.d.ts +12 -0
  17. package/dist/types/src/factories/cap.d.ts +12 -0
  18. package/dist/types/src/factories/data.d.ts +7 -0
  19. package/dist/types/src/factories/edge.d.ts +8 -0
  20. package/dist/types/src/factories/events.d.ts +13 -0
  21. package/dist/types/src/factories/guide.d.ts +7 -0
  22. package/dist/types/src/factories/guides.d.ts +5 -0
  23. package/dist/types/src/factories/label.d.ts +6 -0
  24. package/dist/types/src/factories/node.d.ts +10 -0
  25. package/dist/types/src/factories/nodeArrowButton.d.ts +11 -0
  26. package/dist/types/src/factories/nodeBar.d.ts +6 -0
  27. package/dist/types/src/factories/nodeFlowRun.d.ts +9 -0
  28. package/dist/types/src/factories/nodeTaskRun.d.ts +9 -0
  29. package/dist/types/src/factories/nodes.d.ts +11 -0
  30. package/dist/types/src/factories/offsets.d.ts +24 -0
  31. package/dist/types/src/factories/position.d.ts +12 -0
  32. package/dist/types/src/factories/rectangle.d.ts +2 -0
  33. package/dist/types/src/factories/settings.d.ts +3 -0
  34. package/dist/types/src/index.d.ts +1 -2
  35. package/dist/types/src/models/RunGraph.d.ts +70 -0
  36. package/dist/types/src/models/boundsContainer.d.ts +15 -0
  37. package/dist/types/src/models/guides.d.ts +6 -0
  38. package/dist/types/src/models/index.d.ts +3 -1
  39. package/dist/types/src/models/layout.d.ts +35 -0
  40. package/dist/types/src/models/nonTemporalLayoutError.d.ts +3 -0
  41. package/dist/types/src/models/selection.d.ts +5 -0
  42. package/dist/types/src/models/states.d.ts +2 -0
  43. package/dist/types/src/models/viewport.d.ts +1 -0
  44. package/dist/types/src/objects/application.d.ts +5 -0
  45. package/dist/types/src/objects/config.d.ts +4 -0
  46. package/dist/types/src/objects/culling.d.ts +6 -0
  47. package/dist/types/src/objects/edgeCulling.d.ts +4 -0
  48. package/dist/types/src/objects/events.d.ts +48 -0
  49. package/dist/types/src/objects/fonts.d.ts +9 -0
  50. package/dist/types/src/objects/guides.d.ts +2 -0
  51. package/dist/types/src/objects/index.d.ts +10 -0
  52. package/dist/types/src/objects/labelCulling.d.ts +4 -0
  53. package/dist/types/src/objects/nodes.d.ts +4 -0
  54. package/dist/types/src/objects/scale.d.ts +4 -0
  55. package/dist/types/src/objects/scope.d.ts +4 -0
  56. package/dist/types/src/objects/selection.d.ts +5 -0
  57. package/dist/types/src/objects/settings.d.ts +26 -0
  58. package/dist/types/src/objects/stage.d.ts +4 -0
  59. package/dist/types/src/objects/viewport.d.ts +17 -0
  60. package/dist/types/src/services/visibilityCull.d.ts +12 -0
  61. package/dist/types/src/textures/cap.d.ts +6 -0
  62. package/dist/types/src/textures/corner.d.ts +7 -0
  63. package/dist/types/src/textures/pixel.d.ts +2 -0
  64. package/dist/types/src/utilities/columns.d.ts +14 -0
  65. package/dist/types/src/utilities/effectScopeFactory.d.ts +6 -0
  66. package/dist/types/src/utilities/exhaustive.d.ts +1 -0
  67. package/dist/types/src/utilities/getEdgesCount.d.ts +2 -0
  68. package/dist/types/src/utilities/getInitialHorizontalScaleMultiplier.d.ts +2 -0
  69. package/dist/types/src/utilities/keyboard.d.ts +1 -0
  70. package/dist/types/src/utilities/repeat.d.ts +1 -0
  71. package/dist/types/src/utilities/timeIncrements.d.ts +21 -0
  72. package/dist/types/src/workers/layouts/horizontal.d.ts +6 -0
  73. package/dist/types/src/workers/layouts/nearestParentVertical.d.ts +4 -0
  74. package/dist/types/src/workers/layouts/vertical.d.ts +4 -0
  75. package/dist/types/src/workers/runGraph.d.ts +21 -0
  76. package/dist/types/vite.config.d.ts +1 -1
  77. package/package.json +23 -19
  78. package/dist/assets/nodeLayout.worker-ba54e168.js.map +0 -1
  79. package/dist/index-cd319f80.mjs +0 -19948
  80. package/dist/index-cd319f80.mjs.map +0 -1
  81. package/dist/types/demo/components/ComponentPage.vue.d.ts +0 -30
  82. package/dist/types/demo/components/ResizableSection.vue.d.ts +0 -9
  83. package/dist/types/demo/components/contextAccordionChildItem.d.ts +0 -5
  84. package/dist/types/demo/components/router.d.ts +0 -3
  85. package/dist/types/demo/sections/components/TimescaleTable.vue.d.ts +0 -30
  86. package/dist/types/demo/utilities/randomColor.d.ts +0 -5
  87. package/dist/types/demo/utilities/randomDate.d.ts +0 -7
  88. package/dist/types/demo/utilities/randomStarName.d.ts +0 -4
  89. package/dist/types/demo/utilities/starnames/index.d.ts +0 -3
  90. package/dist/types/demo/utilities/starnames/names.d.ts +0 -2
  91. package/dist/types/demo/utilities/starnames/prefixes.d.ts +0 -2
  92. package/dist/types/demo/utilities/starnames/suffixes.d.ts +0 -2
  93. package/dist/types/demo/utilities/timescaleData.d.ts +0 -14
  94. package/dist/types/src/FlowRunTimeline.vue.d.ts +0 -52
  95. package/dist/types/src/containers/guide.d.ts +0 -29
  96. package/dist/types/src/containers/guides.d.ts +0 -26
  97. package/dist/types/src/models/FlowRunTimeline.d.ts +0 -191
  98. package/dist/types/src/pixiFunctions/bitmapFonts.d.ts +0 -4
  99. package/dist/types/src/pixiFunctions/deselectLayer.d.ts +0 -12
  100. package/dist/types/src/pixiFunctions/index.d.ts +0 -13
  101. package/dist/types/src/pixiFunctions/initPixiApp.d.ts +0 -2
  102. package/dist/types/src/pixiFunctions/initViewport.d.ts +0 -3
  103. package/dist/types/src/pixiFunctions/loadingIndicator.d.ts +0 -19
  104. package/dist/types/src/pixiFunctions/nodeSprites.d.ts +0 -34
  105. package/dist/types/src/pixiFunctions/roundedBorderRect.d.ts +0 -39
  106. package/dist/types/src/pixiFunctions/subNodesToggle.d.ts +0 -41
  107. package/dist/types/src/pixiFunctions/timeScale.d.ts +0 -2
  108. package/dist/types/src/pixiFunctions/timelineEdge.d.ts +0 -49
  109. package/dist/types/src/pixiFunctions/timelineNode.d.ts +0 -112
  110. package/dist/types/src/pixiFunctions/timelineNodes.d.ts +0 -54
  111. package/dist/types/src/pixiFunctions/timelinePlayhead.d.ts +0 -14
  112. package/dist/types/src/pixiFunctions/viewport.d.ts +0 -1
  113. package/dist/types/src/types/index.d.ts +0 -1
  114. package/dist/types/src/types/timeline.d.ts +0 -11
  115. package/dist/types/src/utilities/index.d.ts +0 -5
  116. package/dist/types/src/utilities/map.d.ts +0 -1
  117. package/dist/types/src/utilities/math.d.ts +0 -13
  118. package/dist/types/src/utilities/style.d.ts +0 -4
  119. package/dist/types/src/utilities/time.d.ts +0 -42
  120. package/dist/types/src/utilities/viewport.d.ts +0 -3
  121. package/dist/types/src/utilities/zIndex.d.ts +0 -5
  122. package/dist/types/src/workers/layouts/nearestNeighbor.d.ts +0 -10
  123. package/dist/types/src/workers/layouts/waterfall.d.ts +0 -3
  124. package/dist/viewport.es-3ce16114.mjs +0 -2237
  125. package/dist/viewport.es-3ce16114.mjs.map +0 -1
  126. /package/dist/types/demo/{components/ContextSidebar.vue.d.ts → sections/WelcomePage.vue.d.ts} +0 -0
  127. /package/dist/types/demo/sections/{Data.vue.d.ts → components/RunGraphDemo.vue.d.ts} +0 -0
  128. /package/dist/types/{demo/sections/Home.vue.d.ts → src/components/RunGraphSettings.vue.d.ts} +0 -0
  129. /package/dist/types/src/workers/{nodeLayout.worker.d.ts → runGraph.worker.d.ts} +0 -0
@@ -1,2237 +0,0 @@
1
- import { T as C, C as P, R as b, P as c } from "./index-cd319f80.mjs";
2
- import "vue";
3
- class u {
4
- /** The viewport to which this plugin is attached. */
5
- /**
6
- * Flags whether this plugin has been "paused".
7
- *
8
- * @see Plugin#pause
9
- * @see Plugin#resume
10
- */
11
- /** @param {Viewport} parent */
12
- constructor(t) {
13
- this.parent = t, this.paused = !1;
14
- }
15
- /** Called when plugin is removed */
16
- destroy() {
17
- }
18
- /** Handler for pointerdown PIXI event */
19
- down(t) {
20
- return !1;
21
- }
22
- /** Handler for pointermove PIXI event */
23
- move(t) {
24
- return !1;
25
- }
26
- /** Handler for pointerup PIXI event */
27
- up(t) {
28
- return !1;
29
- }
30
- /** Handler for wheel event on div */
31
- wheel(t) {
32
- return !1;
33
- }
34
- /**
35
- * Called on each tick
36
- * @param {number} elapsed time in millisecond since last update
37
- */
38
- update(t) {
39
- }
40
- /** Called when the viewport is resized */
41
- resize() {
42
- }
43
- /** Called when the viewport is manually moved */
44
- reset() {
45
- }
46
- /** Pause the plugin */
47
- pause() {
48
- this.paused = !0;
49
- }
50
- /** Un-pause the plugin */
51
- resume() {
52
- this.paused = !1;
53
- }
54
- }
55
- var _ = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
56
- function I(l, t, e) {
57
- return e = {
58
- path: t,
59
- exports: {},
60
- require: function(n, i) {
61
- return k(n, i ?? e.path);
62
- }
63
- }, l(e, e.exports), e.exports;
64
- }
65
- function k() {
66
- throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs");
67
- }
68
- var M = I(function(l, t) {
69
- (function() {
70
- var e, n;
71
- n = function(i) {
72
- return l.exports = i;
73
- }, e = {
74
- linear: function(i, s, h, o) {
75
- return h * i / o + s;
76
- },
77
- easeInQuad: function(i, s, h, o) {
78
- return h * (i /= o) * i + s;
79
- },
80
- easeOutQuad: function(i, s, h, o) {
81
- return -h * (i /= o) * (i - 2) + s;
82
- },
83
- easeInOutQuad: function(i, s, h, o) {
84
- return (i /= o / 2) < 1 ? h / 2 * i * i + s : -h / 2 * (--i * (i - 2) - 1) + s;
85
- },
86
- easeInCubic: function(i, s, h, o) {
87
- return h * (i /= o) * i * i + s;
88
- },
89
- easeOutCubic: function(i, s, h, o) {
90
- return h * ((i = i / o - 1) * i * i + 1) + s;
91
- },
92
- easeInOutCubic: function(i, s, h, o) {
93
- return (i /= o / 2) < 1 ? h / 2 * i * i * i + s : h / 2 * ((i -= 2) * i * i + 2) + s;
94
- },
95
- easeInQuart: function(i, s, h, o) {
96
- return h * (i /= o) * i * i * i + s;
97
- },
98
- easeOutQuart: function(i, s, h, o) {
99
- return -h * ((i = i / o - 1) * i * i * i - 1) + s;
100
- },
101
- easeInOutQuart: function(i, s, h, o) {
102
- return (i /= o / 2) < 1 ? h / 2 * i * i * i * i + s : -h / 2 * ((i -= 2) * i * i * i - 2) + s;
103
- },
104
- easeInQuint: function(i, s, h, o) {
105
- return h * (i /= o) * i * i * i * i + s;
106
- },
107
- easeOutQuint: function(i, s, h, o) {
108
- return h * ((i = i / o - 1) * i * i * i * i + 1) + s;
109
- },
110
- easeInOutQuint: function(i, s, h, o) {
111
- return (i /= o / 2) < 1 ? h / 2 * i * i * i * i * i + s : h / 2 * ((i -= 2) * i * i * i * i + 2) + s;
112
- },
113
- easeInSine: function(i, s, h, o) {
114
- return -h * Math.cos(i / o * (Math.PI / 2)) + h + s;
115
- },
116
- easeOutSine: function(i, s, h, o) {
117
- return h * Math.sin(i / o * (Math.PI / 2)) + s;
118
- },
119
- easeInOutSine: function(i, s, h, o) {
120
- return -h / 2 * (Math.cos(Math.PI * i / o) - 1) + s;
121
- },
122
- easeInExpo: function(i, s, h, o) {
123
- return i === 0 ? s : h * Math.pow(2, 10 * (i / o - 1)) + s;
124
- },
125
- easeOutExpo: function(i, s, h, o) {
126
- return i === o ? s + h : h * (-Math.pow(2, -10 * i / o) + 1) + s;
127
- },
128
- easeInOutExpo: function(i, s, h, o) {
129
- return (i /= o / 2) < 1 ? h / 2 * Math.pow(2, 10 * (i - 1)) + s : h / 2 * (-Math.pow(2, -10 * --i) + 2) + s;
130
- },
131
- easeInCirc: function(i, s, h, o) {
132
- return -h * (Math.sqrt(1 - (i /= o) * i) - 1) + s;
133
- },
134
- easeOutCirc: function(i, s, h, o) {
135
- return h * Math.sqrt(1 - (i = i / o - 1) * i) + s;
136
- },
137
- easeInOutCirc: function(i, s, h, o) {
138
- return (i /= o / 2) < 1 ? -h / 2 * (Math.sqrt(1 - i * i) - 1) + s : h / 2 * (Math.sqrt(1 - (i -= 2) * i) + 1) + s;
139
- },
140
- easeInElastic: function(i, s, h, o) {
141
- var r, a, p;
142
- 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;
143
- },
144
- easeOutElastic: function(i, s, h, o) {
145
- var r, a, p;
146
- 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;
147
- },
148
- easeInOutElastic: function(i, s, h, o) {
149
- var r, a, p;
150
- 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;
151
- },
152
- easeInBack: function(i, s, h, o, r) {
153
- return r === void 0 && (r = 1.70158), h * (i /= o) * i * ((r + 1) * i - r) + s;
154
- },
155
- easeOutBack: function(i, s, h, o, r) {
156
- return r === void 0 && (r = 1.70158), h * ((i = i / o - 1) * i * ((r + 1) * i + r) + 1) + s;
157
- },
158
- easeInOutBack: function(i, s, h, o, r) {
159
- 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;
160
- },
161
- easeInBounce: function(i, s, h, o) {
162
- var r;
163
- return r = e.easeOutBounce(o - i, 0, h, o), h - r + s;
164
- },
165
- easeOutBounce: function(i, s, h, o) {
166
- 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;
167
- },
168
- easeInOutBounce: function(i, s, h, o) {
169
- var r;
170
- 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);
171
- }
172
- }, n(e);
173
- }).call(_);
174
- });
175
- function H(l, t) {
176
- if (l) {
177
- if (typeof l == "function")
178
- return l;
179
- if (typeof l == "string")
180
- return M[l];
181
- } else
182
- return M[t];
183
- }
184
- const Y = {
185
- removeOnInterrupt: !1,
186
- ease: "linear",
187
- time: 1e3
188
- };
189
- class d extends u {
190
- /** The starting x-coordinate of the viewport. */
191
- /** The starting y-coordinate of the viewport. */
192
- /** The change in the x-coordinate of the viewport through the animation.*/
193
- /** The change in the y-coordinate of the viewport through the animation. */
194
- /** Marks whether the center of the viewport is preserved in the animation. */
195
- /** The starting viewport width. */
196
- __init() {
197
- this.startWidth = null;
198
- }
199
- /** The starting viewport height. */
200
- __init2() {
201
- this.startHeight = null;
202
- }
203
- /** The change in the viewport's width through the animation. */
204
- __init3() {
205
- this.deltaWidth = null;
206
- }
207
- /** The change in the viewport's height through the animation. */
208
- __init4() {
209
- this.deltaHeight = null;
210
- }
211
- /** The viewport's width post-animation. */
212
- __init5() {
213
- this.width = null;
214
- }
215
- /** The viewport's height post-animation. */
216
- __init6() {
217
- this.height = null;
218
- }
219
- /** The time since the animation started. */
220
- __init7() {
221
- this.time = 0;
222
- }
223
- /**
224
- * This is called by {@link Viewport.animate}.
225
- *
226
- * @param parent
227
- * @param options
228
- */
229
- constructor(t, e = {}) {
230
- 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;
231
- }
232
- /**
233
- * Setup `startX`, `startY`, `deltaX`, `deltaY`, `keepCenter`.
234
- *
235
- * This is called during construction.
236
- */
237
- setupPosition() {
238
- 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;
239
- }
240
- /**
241
- * Setup `startWidth, `startHeight`, `deltaWidth, `deltaHeight, `width`, `height`.
242
- *
243
- * This is called during construction.
244
- */
245
- setupZoom() {
246
- 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);
247
- }
248
- down() {
249
- return this.options.removeOnInterrupt && this.parent.plugins.remove("animate"), !1;
250
- }
251
- complete() {
252
- 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);
253
- }
254
- update(t) {
255
- if (this.paused)
256
- return;
257
- this.time += t;
258
- const e = new c(this.parent.scale.x, this.parent.scale.y);
259
- if (this.time >= this.options.time) {
260
- const n = this.parent.width, i = this.parent.height;
261
- this.complete(), (n !== this.parent.width || i !== this.parent.height) && this.parent.emit("zoomed", { viewport: this.parent, original: e, type: "animate" });
262
- } else {
263
- const n = this.options.ease(this.time, 0, 1, this.options.time);
264
- if (this.width !== null) {
265
- const i = this.startWidth, s = this.deltaWidth;
266
- this.parent.fitWidth(
267
- i + s * n,
268
- this.keepCenter,
269
- this.height === null
270
- );
271
- }
272
- if (this.height !== null) {
273
- const i = this.startHeight, s = this.deltaHeight;
274
- this.parent.fitHeight(
275
- i + s * n,
276
- this.keepCenter,
277
- this.width === null
278
- );
279
- }
280
- 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) {
281
- const i = this.startX, s = this.startY, h = this.deltaX, o = this.deltaY, r = new c(this.parent.x, this.parent.y);
282
- this.parent.moveCenter(i + h * n, s + o * n), this.parent.emit("moved", { viewport: this.parent, original: r, type: "animate" });
283
- }
284
- (this.width || this.height) && this.parent.emit("zoomed", { viewport: this.parent, original: e, type: "animate" });
285
- }
286
- }
287
- }
288
- function v(l) {
289
- let t, e = l[0], n = 1;
290
- for (; n < l.length; ) {
291
- const i = l[n], s = l[n + 1];
292
- if (n += 2, (i === "optionalAccess" || i === "optionalCall") && e == null)
293
- return;
294
- i === "access" || i === "optionalAccess" ? (t = e, e = s(e)) : (i === "call" || i === "optionalCall") && (e = s((...h) => e.call(t, ...h)), t = void 0);
295
- }
296
- return e;
297
- }
298
- const X = {
299
- sides: "all",
300
- friction: 0.5,
301
- time: 150,
302
- ease: "easeInOutSine",
303
- underflow: "center",
304
- bounceBox: null
305
- };
306
- class z extends u {
307
- /** The options passed to initialize this plugin, cannot be modified again. */
308
- /** Holds whether to bounce from left side. */
309
- /** Holds whether to bounce from top side. */
310
- /** Holds whether to bounce from right side. */
311
- /** Holds whether to bounce from bottom side. */
312
- /** Direction of underflow along x-axis. */
313
- /** Direction of underflow along y-axis. */
314
- /** Easing */
315
- /** Bounce state along x-axis */
316
- /** Bounce state along y-axis */
317
- /**
318
- * This is called by {@link Viewport.bounce}.
319
- */
320
- constructor(t, e = {}) {
321
- 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;
322
- const n = this.options.underflow.toLowerCase();
323
- 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();
324
- }
325
- isActive() {
326
- return this.toX !== null || this.toY !== null;
327
- }
328
- down() {
329
- return this.toX = this.toY = null, !1;
330
- }
331
- up() {
332
- return this.bounce(), !1;
333
- }
334
- update(t) {
335
- if (!this.paused) {
336
- if (this.bounce(), this.toX) {
337
- const e = this.toX;
338
- 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);
339
- }
340
- if (this.toY) {
341
- const e = this.toY;
342
- 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);
343
- }
344
- }
345
- }
346
- /** @internal */
347
- calcUnderflowX() {
348
- let t;
349
- switch (this.underflowX) {
350
- case -1:
351
- t = 0;
352
- break;
353
- case 1:
354
- t = this.parent.screenWidth - this.parent.screenWorldWidth;
355
- break;
356
- default:
357
- t = (this.parent.screenWidth - this.parent.screenWorldWidth) / 2;
358
- }
359
- return t;
360
- }
361
- /** @internal */
362
- calcUnderflowY() {
363
- let t;
364
- switch (this.underflowY) {
365
- case -1:
366
- t = 0;
367
- break;
368
- case 1:
369
- t = this.parent.screenHeight - this.parent.screenWorldHeight;
370
- break;
371
- default:
372
- t = (this.parent.screenHeight - this.parent.screenWorldHeight) / 2;
373
- }
374
- return t;
375
- }
376
- oob() {
377
- const t = this.options.bounceBox;
378
- if (t) {
379
- 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;
380
- return {
381
- left: this.parent.left < e,
382
- right: this.parent.right > i,
383
- top: this.parent.top < n,
384
- bottom: this.parent.bottom > s,
385
- topLeft: new c(
386
- e * this.parent.scale.x,
387
- n * this.parent.scale.y
388
- ),
389
- bottomRight: new c(
390
- i * this.parent.scale.x - this.parent.screenWidth,
391
- s * this.parent.scale.y - this.parent.screenHeight
392
- )
393
- };
394
- }
395
- return {
396
- left: this.parent.left < 0,
397
- right: this.parent.right > this.parent.worldWidth,
398
- top: this.parent.top < 0,
399
- bottom: this.parent.bottom > this.parent.worldHeight,
400
- topLeft: new c(0, 0),
401
- bottomRight: new c(
402
- this.parent.worldWidth * this.parent.scale.x - this.parent.screenWidth,
403
- this.parent.worldHeight * this.parent.scale.y - this.parent.screenHeight
404
- )
405
- };
406
- }
407
- bounce() {
408
- if (this.paused)
409
- return;
410
- let t, e = this.parent.plugins.get("decelerate", !0);
411
- 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));
412
- const n = this.parent.plugins.get("drag", !0) || {}, i = this.parent.plugins.get("pinch", !0) || {};
413
- if (e = e || {}, !v([n, "optionalAccess", (s) => s.active]) && !v([i, "optionalAccess", (s) => s.active]) && (!this.toX || !this.toY) && (!e.x || !e.y)) {
414
- t = t || this.oob();
415
- const s = t.topLeft, h = t.bottomRight;
416
- if (!this.toX && !e.x) {
417
- let o = null;
418
- 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));
419
- }
420
- if (!this.toY && !e.y) {
421
- let o = null;
422
- 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));
423
- }
424
- }
425
- }
426
- reset() {
427
- this.toX = this.toY = null, this.bounce();
428
- }
429
- }
430
- const A = {
431
- left: !1,
432
- right: !1,
433
- top: !1,
434
- bottom: !1,
435
- direction: null,
436
- underflow: "center"
437
- };
438
- class T extends u {
439
- /** Options used to initialize this plugin, cannot be modified later. */
440
- /** Last state of viewport */
441
- /**
442
- * This is called by {@link Viewport.clamp}.
443
- */
444
- constructor(t, e = {}) {
445
- 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();
446
- }
447
- parseUnderflow() {
448
- const t = this.options.underflow.toLowerCase();
449
- 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);
450
- }
451
- move() {
452
- return this.update(), !1;
453
- }
454
- update() {
455
- 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)
456
- return;
457
- const t = { x: this.parent.x, y: this.parent.y }, e = this.parent.plugins.decelerate || {};
458
- if (this.options.left !== null || this.options.right !== null) {
459
- let n = !1;
460
- if (!this.noUnderflow && this.parent.screenWorldWidth < this.parent.screenWidth)
461
- switch (this.underflowX) {
462
- case -1:
463
- this.parent.x !== 0 && (this.parent.x = 0, n = !0);
464
- break;
465
- case 1:
466
- this.parent.x !== this.parent.screenWidth - this.parent.screenWorldWidth && (this.parent.x = this.parent.screenWidth - this.parent.screenWorldWidth, n = !0);
467
- break;
468
- default:
469
- this.parent.x !== (this.parent.screenWidth - this.parent.screenWorldWidth) / 2 && (this.parent.x = (this.parent.screenWidth - this.parent.screenWorldWidth) / 2, n = !0);
470
- }
471
- else
472
- 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);
473
- n && this.parent.emit("moved", { viewport: this.parent, original: t, type: "clamp-x" });
474
- }
475
- if (this.options.top !== null || this.options.bottom !== null) {
476
- let n = !1;
477
- if (!this.noUnderflow && this.parent.screenWorldHeight < this.parent.screenHeight)
478
- switch (this.underflowY) {
479
- case -1:
480
- this.parent.y !== 0 && (this.parent.y = 0, n = !0);
481
- break;
482
- case 1:
483
- this.parent.y !== this.parent.screenHeight - this.parent.screenWorldHeight && (this.parent.y = this.parent.screenHeight - this.parent.screenWorldHeight, n = !0);
484
- break;
485
- default:
486
- this.parent.y !== (this.parent.screenHeight - this.parent.screenWorldHeight) / 2 && (this.parent.y = (this.parent.screenHeight - this.parent.screenWorldHeight) / 2, n = !0);
487
- }
488
- else
489
- 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);
490
- n && this.parent.emit("moved", { viewport: this.parent, original: t, type: "clamp-y" });
491
- }
492
- 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;
493
- }
494
- reset() {
495
- this.update();
496
- }
497
- }
498
- const E = {
499
- minWidth: null,
500
- minHeight: null,
501
- maxWidth: null,
502
- maxHeight: null,
503
- minScale: null,
504
- maxScale: null
505
- };
506
- class L extends u {
507
- /**
508
- * This is called by {@link Viewport.clampZoom}.
509
- */
510
- constructor(t, e = {}) {
511
- super(t), this.options = Object.assign({}, E, e), this.clamp();
512
- }
513
- resize() {
514
- this.clamp();
515
- }
516
- /** Clamp the viewport scale zoom) */
517
- clamp() {
518
- if (!this.paused) {
519
- if (this.options.minWidth || this.options.minHeight || this.options.maxWidth || this.options.maxHeight) {
520
- let t = this.parent.worldScreenWidth, e = this.parent.worldScreenHeight;
521
- if (this.options.minWidth !== null && t < this.options.minWidth) {
522
- const n = this.parent.scale.x;
523
- 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" });
524
- }
525
- if (this.options.maxWidth !== null && t > this.options.maxWidth) {
526
- const n = this.parent.scale.x;
527
- 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" });
528
- }
529
- if (this.options.minHeight !== null && e < this.options.minHeight) {
530
- const n = this.parent.scale.y;
531
- 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" });
532
- }
533
- if (this.options.maxHeight !== null && e > this.options.maxHeight) {
534
- const n = this.parent.scale.y;
535
- 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" });
536
- }
537
- } else if (this.options.minScale || this.options.maxScale) {
538
- const t = { x: null, y: null }, e = { x: null, y: null };
539
- if (typeof this.options.minScale == "number")
540
- t.x = this.options.minScale, t.y = this.options.minScale;
541
- else if (this.options.minScale !== null) {
542
- const s = this.options.minScale;
543
- t.x = typeof s.x > "u" ? null : s.x, t.y = typeof s.y > "u" ? null : s.y;
544
- }
545
- if (typeof this.options.maxScale == "number")
546
- e.x = this.options.maxScale, e.y = this.options.maxScale;
547
- else if (this.options.maxScale !== null) {
548
- const s = this.options.maxScale;
549
- e.x = typeof s.x > "u" ? null : s.x, e.y = typeof s.y > "u" ? null : s.y;
550
- }
551
- let n = this.parent.scale.x, i = this.parent.scale.y;
552
- 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" }));
553
- }
554
- }
555
- }
556
- reset() {
557
- this.clamp();
558
- }
559
- }
560
- const D = {
561
- friction: 0.98,
562
- bounce: 0.8,
563
- minSpeed: 0.01
564
- }, f = 16;
565
- class U extends u {
566
- /** Options used to initialize this plugin. */
567
- /**
568
- * x-component of the velocity of viewport provided by this plugin, at the current time.
569
- *
570
- * This is measured in px/frame, where a frame is normalized to 16 milliseconds.
571
- */
572
- /**
573
- * y-component of the velocity of the viewport provided by this plugin, at the current time.
574
- *
575
- * This is measured in px/frame, where a frame is normalized to 16 milliseconds.
576
- */
577
- /**
578
- * The decay factor for the x-component of the viewport.
579
- *
580
- * The viewport's velocity decreased by this amount each 16 milliseconds.
581
- */
582
- /**
583
- * The decay factor for the y-component of the viewport.
584
- *
585
- * The viewport's velocity decreased by this amount each 16 milliseconds.
586
- */
587
- /** Saved list of recent viewport position snapshots, to estimate velocity. */
588
- /** The time since the user released panning of the viewport. */
589
- /**
590
- * This is called by {@link Viewport.decelerate}.
591
- */
592
- constructor(t, e = {}) {
593
- super(t), this.options = Object.assign({}, D, e), this.saved = [], this.timeSinceRelease = 0, this.reset(), this.parent.on("moved", (n) => this.moved(n));
594
- }
595
- down() {
596
- return this.saved = [], this.x = this.y = null, !1;
597
- }
598
- isActive() {
599
- return !!(this.x || this.y);
600
- }
601
- move() {
602
- if (this.paused)
603
- return !1;
604
- const t = this.parent.input.count();
605
- 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;
606
- }
607
- /** Listener to viewport's "moved" event. */
608
- moved(t) {
609
- if (this.saved.length) {
610
- const e = this.saved[this.saved.length - 1];
611
- 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);
612
- }
613
- }
614
- up() {
615
- if (this.parent.input.count() === 0 && this.saved.length) {
616
- const t = performance.now();
617
- for (const e of this.saved)
618
- if (e.time >= t - 100) {
619
- const n = t - e.time;
620
- 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;
621
- break;
622
- }
623
- }
624
- return !1;
625
- }
626
- /**
627
- * Manually activate deceleration, starting from the (x, y) velocity components passed in the options.
628
- *
629
- * @param {object} options
630
- * @param {number} [options.x] - Specify x-component of initial velocity.
631
- * @param {number} [options.y] - Specify y-component of initial velocity.
632
- */
633
- activate(t) {
634
- 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);
635
- }
636
- update(t) {
637
- if (this.paused)
638
- return;
639
- const e = this.x || this.y, n = this.timeSinceRelease, i = this.timeSinceRelease + t;
640
- if (this.x) {
641
- const s = this.percentChangeX, h = Math.log(s);
642
- 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);
643
- }
644
- if (this.y) {
645
- const s = this.percentChangeY, h = Math.log(s);
646
- 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);
647
- }
648
- 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" });
649
- }
650
- reset() {
651
- this.x = this.y = null;
652
- }
653
- }
654
- const B = {
655
- direction: "all",
656
- pressDrag: !0,
657
- wheel: !0,
658
- wheelScroll: 1,
659
- reverse: !1,
660
- clampWheel: !1,
661
- underflow: "center",
662
- factor: 1,
663
- mouseButtons: "all",
664
- keyToPress: null,
665
- ignoreKeyToPressOnTouch: !1,
666
- lineHeight: 20,
667
- wheelSwapAxes: !1
668
- };
669
- class S extends u {
670
- /** Options used to initialize this plugin, cannot be modified later. */
671
- /** Flags when viewport is moving. */
672
- /** Factor to apply from {@link IDecelerateOptions}'s reverse. */
673
- /** Holds whether dragging is enabled along the x-axis. */
674
- /** Holds whether dragging is enabled along the y-axis. */
675
- /** Flags whether the keys required to drag are pressed currently. */
676
- /** Holds whether the left, center, and right buttons are required to pan. */
677
- /** Underflow factor along x-axis */
678
- /** Underflow factor along y-axis */
679
- /** Last pointer position while panning. */
680
- /** The ID of the pointer currently panning the viewport. */
681
- /** Array of event-handlers for window */
682
- __init() {
683
- this.windowEventHandlers = new Array();
684
- }
685
- /**
686
- * This is called by {@link Viewport.drag}.
687
- */
688
- constructor(t, e = {}) {
689
- 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);
690
- }
691
- /**
692
- * Handles keypress events and set the keyIsPressed boolean accordingly
693
- *
694
- * @param {array} codes - key codes that can be used to trigger drag event
695
- */
696
- handleKeyPresses(t) {
697
- const e = (i) => {
698
- t.includes(i.code) && (this.keyIsPressed = !0);
699
- }, n = (i) => {
700
- t.includes(i.code) && (this.keyIsPressed = !1);
701
- };
702
- this.addWindowEventHandler("keyup", n), this.addWindowEventHandler("keydown", e);
703
- }
704
- addWindowEventHandler(t, e) {
705
- window.addEventListener(t, e), this.windowEventHandlers.push({ event: t, handler: e });
706
- }
707
- destroy() {
708
- this.windowEventHandlers.forEach(({ event: t, handler: e }) => {
709
- window.removeEventListener(t, e);
710
- });
711
- }
712
- /**
713
- * initialize mousebuttons array
714
- * @param {string} buttons
715
- */
716
- mouseButtons(t) {
717
- !t || t === "all" ? this.mouse = [!0, !0, !0] : this.mouse = [
718
- t.indexOf("left") !== -1,
719
- t.indexOf("middle") !== -1,
720
- t.indexOf("right") !== -1
721
- ];
722
- }
723
- parseUnderflow() {
724
- const t = this.options.underflow.toLowerCase();
725
- 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);
726
- }
727
- /**
728
- * @param {PIXI.InteractionEvent} event
729
- * @returns {boolean}
730
- */
731
- checkButtons(t) {
732
- const e = t.data.pointerType === "mouse", n = this.parent.input.count();
733
- return !!((n === 1 || n > 1 && !this.parent.plugins.get("pinch", !0)) && (!e || this.mouse[t.data.button]));
734
- }
735
- /**
736
- * @param {PIXI.InteractionEvent} event
737
- * @returns {boolean}
738
- */
739
- checkKeyPress(t) {
740
- return !this.options.keyToPress || this.keyIsPressed || this.options.ignoreKeyToPressOnTouch && t.data.pointerType === "touch";
741
- }
742
- down(t) {
743
- 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);
744
- }
745
- get active() {
746
- return this.moved;
747
- }
748
- move(t) {
749
- if (this.paused || !this.options.pressDrag)
750
- return !1;
751
- if (this.last && this.current === t.data.pointerId) {
752
- const e = t.data.global.x, n = t.data.global.y, i = this.parent.input.count();
753
- if (i === 1 || i > 1 && !this.parent.plugins.get("pinch", !0)) {
754
- const s = e - this.last.x, h = n - this.last.y;
755
- if (this.moved || this.xDirection && this.parent.input.checkThreshold(s) || this.yDirection && this.parent.input.checkThreshold(h)) {
756
- const o = { x: e, y: n };
757
- 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", {
758
- event: t,
759
- screen: new c(this.last.x, this.last.y),
760
- world: this.parent.toWorld(new c(this.last.x, this.last.y)),
761
- viewport: this.parent
762
- }), this.moved = !0, this.parent.emit("moved", { viewport: this.parent, type: "drag" }), !0;
763
- }
764
- } else
765
- this.moved = !1;
766
- }
767
- return !1;
768
- }
769
- up(t) {
770
- if (this.paused)
771
- return !1;
772
- const e = this.parent.input.touches;
773
- if (e.length === 1) {
774
- const n = e[0];
775
- return n.last && (this.last = { x: n.last.x, y: n.last.y }, this.current = n.id), this.moved = !1, !0;
776
- } else if (this.last && this.moved) {
777
- const n = new c(this.last.x, this.last.y);
778
- return this.parent.emit("drag-end", {
779
- event: t,
780
- screen: n,
781
- world: this.parent.toWorld(n),
782
- viewport: this.parent
783
- }), this.last = null, this.moved = !1, !0;
784
- }
785
- return !1;
786
- }
787
- wheel(t) {
788
- if (this.paused)
789
- return !1;
790
- if (this.options.wheel) {
791
- const e = this.parent.plugins.get("wheel", !0);
792
- if (!e || !e.options.wheelZoom && !t.ctrlKey) {
793
- const n = t.deltaMode ? this.options.lineHeight : 1, i = [t.deltaX, t.deltaY], [s, h] = this.options.wheelSwapAxes ? i.reverse() : i;
794
- 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;
795
- }
796
- }
797
- return !1;
798
- }
799
- resume() {
800
- this.last = null, this.paused = !1;
801
- }
802
- clamp() {
803
- const t = this.parent.plugins.get("decelerate", !0) || {};
804
- if (this.options.clampWheel !== "y")
805
- if (this.parent.screenWorldWidth < this.parent.screenWidth)
806
- switch (this.underflowX) {
807
- case -1:
808
- this.parent.x = 0;
809
- break;
810
- case 1:
811
- this.parent.x = this.parent.screenWidth - this.parent.screenWorldWidth;
812
- break;
813
- default:
814
- this.parent.x = (this.parent.screenWidth - this.parent.screenWorldWidth) / 2;
815
- }
816
- else
817
- 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);
818
- if (this.options.clampWheel !== "x")
819
- if (this.parent.screenWorldHeight < this.parent.screenHeight)
820
- switch (this.underflowY) {
821
- case -1:
822
- this.parent.y = 0;
823
- break;
824
- case 1:
825
- this.parent.y = this.parent.screenHeight - this.parent.screenWorldHeight;
826
- break;
827
- default:
828
- this.parent.y = (this.parent.screenHeight - this.parent.screenWorldHeight) / 2;
829
- }
830
- else
831
- 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);
832
- }
833
- }
834
- const F = {
835
- speed: 0,
836
- acceleration: null,
837
- radius: null
838
- };
839
- class V extends u {
840
- /** The options used to initialize this plugin. */
841
- /** The target this plugin will make the viewport follow. */
842
- /** The velocity provided the viewport by following, at the current time. */
843
- /**
844
- * This is called by {@link Viewport.follow}.
845
- *
846
- * @param parent
847
- * @param target - target to follow
848
- * @param options
849
- */
850
- constructor(t, e, n = {}) {
851
- super(t), this.target = e, this.options = Object.assign({}, F, n), this.velocity = { x: 0, y: 0 };
852
- }
853
- update(t) {
854
- if (this.paused)
855
- return;
856
- const e = this.parent.center;
857
- let n = this.target.x, i = this.target.y;
858
- if (this.options.radius)
859
- if (Math.sqrt(Math.pow(this.target.y - e.y, 2) + Math.pow(this.target.x - e.x, 2)) > this.options.radius) {
860
- const r = Math.atan2(this.target.y - e.y, this.target.x - e.x);
861
- n = this.target.x - Math.cos(r) * this.options.radius, i = this.target.y - Math.sin(r) * this.options.radius;
862
- } else
863
- return;
864
- const s = n - e.x, h = i - e.y;
865
- if (s || h)
866
- if (this.options.speed)
867
- if (this.options.acceleration) {
868
- const o = Math.atan2(i - e.y, n - e.x), r = Math.sqrt(Math.pow(s, 2) + Math.pow(h, 2));
869
- if (r) {
870
- const a = (Math.pow(this.velocity.x, 2) + Math.pow(this.velocity.y, 2)) / (2 * this.options.acceleration);
871
- r > a ? this.velocity = {
872
- x: Math.min(this.velocity.x + (this.options.acceleration * t, this.options.speed)),
873
- y: Math.min(this.velocity.y + (this.options.acceleration * t, this.options.speed))
874
- } : this.velocity = {
875
- x: Math.max(this.velocity.x - this.options.acceleration * this.options.speed, 0),
876
- y: Math.max(this.velocity.y - this.options.acceleration * this.options.speed, 0)
877
- };
878
- 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;
879
- this.parent.moveCenter(y, x), this.parent.emit("moved", { viewport: this.parent, type: "follow" });
880
- }
881
- } else {
882
- 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;
883
- this.parent.moveCenter(p, g), this.parent.emit("moved", { viewport: this.parent, type: "follow" });
884
- }
885
- else
886
- this.parent.moveCenter(n, i), this.parent.emit("moved", { viewport: this.parent, type: "follow" });
887
- }
888
- }
889
- const Z = {
890
- radius: null,
891
- distance: null,
892
- top: null,
893
- bottom: null,
894
- left: null,
895
- right: null,
896
- speed: 8,
897
- reverse: !1,
898
- noDecelerate: !1,
899
- linear: !1,
900
- allowButtons: !1
901
- };
902
- class N extends u {
903
- /** Options used to initialize this plugin, cannot be modified later. */
904
- /** Factor from reverse option. */
905
- /** Radius squared */
906
- /** Scroll region size on the left side. */
907
- /** Scroll region size on the top size. */
908
- /** Scroll region size on the right side. */
909
- /** Scroll region size on the bottom side. */
910
- /**
911
- * This is called by {@link Viewport.mouseEdges}.
912
- */
913
- constructor(t, e = {}) {
914
- 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();
915
- }
916
- resize() {
917
- const t = this.options.distance;
918
- 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);
919
- }
920
- down() {
921
- return this.paused || this.options.allowButtons || (this.horizontal = this.vertical = null), !1;
922
- }
923
- move(t) {
924
- if (this.paused || t.data.pointerType !== "mouse" && t.data.identifier !== 1 || !this.options.allowButtons && t.data.buttons !== 0)
925
- return !1;
926
- const e = t.data.global.x, n = t.data.global.y;
927
- if (this.radiusSquared) {
928
- const i = this.parent.toScreen(this.parent.center);
929
- if (Math.pow(i.x - e, 2) + Math.pow(i.y - n, 2) >= this.radiusSquared) {
930
- const h = Math.atan2(i.y - n, i.x - e);
931
- 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));
932
- } else
933
- this.horizontal && this.decelerateHorizontal(), this.vertical && this.decelerateVertical(), this.horizontal = this.vertical = 0;
934
- } else
935
- 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);
936
- return !1;
937
- }
938
- decelerateHorizontal() {
939
- const t = this.parent.plugins.get("decelerate", !0);
940
- this.horizontal && t && !this.options.noDecelerate && t.activate({ x: this.horizontal * this.options.speed * this.reverse / (1e3 / 60) });
941
- }
942
- decelerateVertical() {
943
- const t = this.parent.plugins.get("decelerate", !0);
944
- this.vertical && t && !this.options.noDecelerate && t.activate({ y: this.vertical * this.options.speed * this.reverse / (1e3 / 60) });
945
- }
946
- up() {
947
- return this.paused || (this.horizontal && this.decelerateHorizontal(), this.vertical && this.decelerateVertical(), this.horizontal = this.vertical = null), !1;
948
- }
949
- update() {
950
- if (!this.paused && (this.horizontal || this.vertical)) {
951
- const t = this.parent.center;
952
- 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" });
953
- }
954
- }
955
- }
956
- const R = {
957
- noDrag: !1,
958
- percent: 1,
959
- center: null,
960
- factor: 1,
961
- axis: "all"
962
- };
963
- class w extends u {
964
- /** Options used to initialize this plugin. */
965
- /** Flags whether this plugin is active, i.e. a pointer is down on the viewport. */
966
- __init() {
967
- this.active = !1;
968
- }
969
- /** Flags whether the viewport is being pinched. */
970
- __init2() {
971
- this.pinching = !1;
972
- }
973
- __init3() {
974
- this.moved = !1;
975
- }
976
- /**
977
- * This is called by {@link Viewport.pinch}.
978
- */
979
- constructor(t, e = {}) {
980
- super(t), w.prototype.__init.call(this), w.prototype.__init2.call(this), w.prototype.__init3.call(this), this.options = Object.assign({}, R, e);
981
- }
982
- down() {
983
- return this.parent.input.count() >= 2 ? (this.active = !0, !0) : !1;
984
- }
985
- isAxisX() {
986
- return ["all", "x"].includes(this.options.axis);
987
- }
988
- isAxisY() {
989
- return ["all", "y"].includes(this.options.axis);
990
- }
991
- move(t) {
992
- if (this.paused || !this.active)
993
- return !1;
994
- const e = t.data.global.x, n = t.data.global.y, i = this.parent.input.touches;
995
- if (i.length >= 2) {
996
- 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;
997
- 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) {
998
- let r;
999
- const a = {
1000
- x: s.last.x + (h.last.x - s.last.x) / 2,
1001
- y: s.last.y + (h.last.y - s.last.y) / 2
1002
- };
1003
- this.options.center || (r = this.parent.toLocal(a));
1004
- let p = Math.sqrt(Math.pow(
1005
- h.last.x - s.last.x,
1006
- 2
1007
- ) + Math.pow(h.last.y - s.last.y, 2));
1008
- p = p === 0 ? p = 1e-10 : p;
1009
- const g = (1 - o / p) * this.options.percent * (this.isAxisX() ? this.parent.scale.x : this.parent.scale.y);
1010
- 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 });
1011
- const y = this.parent.plugins.get("clamp-zoom", !0);
1012
- if (y && y.clamp(), this.options.center)
1013
- this.parent.moveCenter(this.options.center);
1014
- else {
1015
- const x = this.parent.toGlobal(r);
1016
- 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" });
1017
- }
1018
- !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;
1019
- } else
1020
- this.pinching || (this.parent.emit("pinch-start", this.parent), this.pinching = !0);
1021
- return !0;
1022
- }
1023
- return !1;
1024
- }
1025
- up() {
1026
- 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;
1027
- }
1028
- }
1029
- const j = {
1030
- topLeft: !1,
1031
- friction: 0.8,
1032
- time: 1e3,
1033
- ease: "easeInOutSine",
1034
- interrupt: !0,
1035
- removeOnComplete: !1,
1036
- removeOnInterrupt: !1,
1037
- forceStart: !1
1038
- };
1039
- class q extends u {
1040
- /**
1041
- * This is called by {@link Viewport.snap}.
1042
- */
1043
- constructor(t, e, n, i = {}) {
1044
- 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();
1045
- }
1046
- snapStart() {
1047
- this.percent = 0, this.snapping = { time: 0 };
1048
- const t = this.options.topLeft ? this.parent.corner : this.parent.center;
1049
- 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);
1050
- }
1051
- wheel() {
1052
- return this.options.removeOnInterrupt && this.parent.plugins.remove("snap"), !1;
1053
- }
1054
- down() {
1055
- return this.options.removeOnInterrupt ? this.parent.plugins.remove("snap") : this.options.interrupt && (this.snapping = null), !1;
1056
- }
1057
- up() {
1058
- if (this.parent.input.count() === 0) {
1059
- const t = this.parent.plugins.get("decelerate", !0);
1060
- t && (t.x || t.y) && (t.percentChangeX = t.percentChangeY = this.options.friction);
1061
- }
1062
- return !1;
1063
- }
1064
- update(t) {
1065
- if (!this.paused && !(this.options.interrupt && this.parent.input.count() !== 0))
1066
- if (this.snapping) {
1067
- const e = this.snapping;
1068
- e.time += t;
1069
- let n, i, s;
1070
- const h = this.startX, o = this.startY, r = this.deltaX, a = this.deltaY;
1071
- if (e.time > this.options.time)
1072
- n = !0, i = h + r, s = o + a;
1073
- else {
1074
- const p = this.ease(e.time, 0, 1, this.options.time);
1075
- i = h + r * p, s = o + a * p;
1076
- }
1077
- 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);
1078
- } else {
1079
- const e = this.options.topLeft ? this.parent.corner : this.parent.center;
1080
- (e.x !== this.x || e.y !== this.y) && this.snapStart();
1081
- }
1082
- }
1083
- }
1084
- const K = {
1085
- width: 0,
1086
- height: 0,
1087
- time: 1e3,
1088
- ease: "easeInOutSine",
1089
- center: null,
1090
- interrupt: !0,
1091
- removeOnComplete: !1,
1092
- removeOnInterrupt: !1,
1093
- forceStart: !1,
1094
- noMove: !1
1095
- };
1096
- class G extends u {
1097
- /**
1098
- * This is called by {@link Viewport.snapZoom}.
1099
- */
1100
- constructor(t, e = {}) {
1101
- 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();
1102
- }
1103
- createSnapping() {
1104
- const t = this.parent.worldScreenWidth, e = this.parent.worldScreenHeight, n = this.parent.screenWidth / this.xScale, i = this.parent.screenHeight / this.yScale;
1105
- this.snapping = {
1106
- time: 0,
1107
- startX: t,
1108
- startY: e,
1109
- deltaX: n - t,
1110
- deltaY: i - e
1111
- }, this.parent.emit("snap-zoom-start", this.parent);
1112
- }
1113
- resize() {
1114
- 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;
1115
- }
1116
- wheel() {
1117
- return this.options.removeOnInterrupt && this.parent.plugins.remove("snap-zoom"), !1;
1118
- }
1119
- down() {
1120
- return this.options.removeOnInterrupt ? this.parent.plugins.remove("snap-zoom") : this.options.interrupt && (this.snapping = null), !1;
1121
- }
1122
- update(t) {
1123
- if (this.paused || this.options.interrupt && this.parent.input.count() !== 0)
1124
- return;
1125
- let e;
1126
- if (!this.options.center && !this.options.noMove && (e = this.parent.center), !this.snapping)
1127
- (this.parent.scale.x !== this.xScale || this.parent.scale.y !== this.yScale) && this.createSnapping();
1128
- else if (this.snapping) {
1129
- const n = this.snapping;
1130
- if (n.time += t, n.time >= this.options.time)
1131
- 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;
1132
- else {
1133
- 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);
1134
- this.parent.scale.x = this.parent.screenWidth / h, this.parent.scale.y = this.parent.screenHeight / o;
1135
- }
1136
- const i = this.parent.plugins.get("clamp-zoom", !0);
1137
- i && i.clamp(), this.options.noMove || (this.options.center ? this.parent.moveCenter(this.options.center) : this.parent.moveCenter(e));
1138
- }
1139
- }
1140
- resume() {
1141
- this.snapping = null, super.resume();
1142
- }
1143
- }
1144
- const Q = {
1145
- percent: 0.1,
1146
- smooth: !1,
1147
- interrupt: !0,
1148
- reverse: !1,
1149
- center: null,
1150
- lineHeight: 20,
1151
- axis: "all",
1152
- keyToPress: null,
1153
- trackpadPinch: !1,
1154
- wheelZoom: !0
1155
- };
1156
- class $ extends u {
1157
- /** Flags whether the keys required to zoom are pressed currently. */
1158
- /**
1159
- * This is called by {@link Viewport.wheel}.
1160
- */
1161
- constructor(t, e = {}) {
1162
- super(t), this.options = Object.assign({}, Q, e), this.keyIsPressed = !1, this.options.keyToPress && this.handleKeyPresses(this.options.keyToPress);
1163
- }
1164
- /**
1165
- * Handles keypress events and set the keyIsPressed boolean accordingly
1166
- *
1167
- * @param {array} codes - key codes that can be used to trigger zoom event
1168
- */
1169
- handleKeyPresses(t) {
1170
- window.addEventListener("keydown", (e) => {
1171
- t.includes(e.code) && (this.keyIsPressed = !0);
1172
- }), window.addEventListener("keyup", (e) => {
1173
- t.includes(e.code) && (this.keyIsPressed = !1);
1174
- });
1175
- }
1176
- checkKeyPress() {
1177
- return !this.options.keyToPress || this.keyIsPressed;
1178
- }
1179
- down() {
1180
- return this.options.interrupt && (this.smoothing = null), !1;
1181
- }
1182
- isAxisX() {
1183
- return ["all", "x"].includes(this.options.axis);
1184
- }
1185
- isAxisY() {
1186
- return ["all", "y"].includes(this.options.axis);
1187
- }
1188
- update() {
1189
- if (this.smoothing) {
1190
- const t = this.smoothingCenter, e = this.smoothing;
1191
- let n;
1192
- 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" });
1193
- const i = this.parent.plugins.get("clamp-zoom", !0);
1194
- if (i && i.clamp(), this.options.center)
1195
- this.parent.moveCenter(this.options.center);
1196
- else {
1197
- const s = this.parent.toGlobal(n);
1198
- this.parent.x += t.x - s.x, this.parent.y += t.y - s.y;
1199
- }
1200
- this.parent.emit("moved", { viewport: this.parent, type: "wheel" }), this.smoothingCount++, this.smoothingCount >= this.options.smooth && (this.smoothing = null);
1201
- }
1202
- }
1203
- pinch(t) {
1204
- if (this.paused)
1205
- return;
1206
- 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);
1207
- let s;
1208
- 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" });
1209
- const h = this.parent.plugins.get("clamp-zoom", !0);
1210
- if (h && h.clamp(), this.options.center)
1211
- this.parent.moveCenter(this.options.center);
1212
- else {
1213
- const o = this.parent.toGlobal(s);
1214
- this.parent.x += e.x - o.x, this.parent.y += e.y - o.y;
1215
- }
1216
- this.parent.emit("moved", { viewport: this.parent, type: "wheel" }), this.parent.emit(
1217
- "wheel",
1218
- { wheel: { dx: t.deltaX, dy: t.deltaY, dz: t.deltaZ }, event: t, viewport: this.parent }
1219
- );
1220
- }
1221
- wheel(t) {
1222
- if (this.paused || !this.checkKeyPress())
1223
- return !1;
1224
- if (t.ctrlKey && this.options.trackpadPinch)
1225
- this.pinch(t);
1226
- else if (this.options.wheelZoom) {
1227
- 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);
1228
- if (this.options.smooth) {
1229
- const h = {
1230
- x: this.smoothing ? this.smoothing.x * (this.options.smooth - this.smoothingCount) : 0,
1231
- y: this.smoothing ? this.smoothing.y * (this.options.smooth - this.smoothingCount) : 0
1232
- };
1233
- this.smoothing = {
1234
- x: ((this.parent.scale.x + h.x) * s - this.parent.scale.x) / this.options.smooth,
1235
- y: ((this.parent.scale.y + h.y) * s - this.parent.scale.y) / this.options.smooth
1236
- }, this.smoothingCount = 0, this.smoothingCenter = e;
1237
- } else {
1238
- let h;
1239
- 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" });
1240
- const o = this.parent.plugins.get("clamp-zoom", !0);
1241
- if (o && o.clamp(), this.options.center)
1242
- this.parent.moveCenter(this.options.center);
1243
- else {
1244
- const r = this.parent.toGlobal(h);
1245
- this.parent.x += e.x - r.x, this.parent.y += e.y - r.y;
1246
- }
1247
- }
1248
- this.parent.emit("moved", { viewport: this.parent, type: "wheel" }), this.parent.emit(
1249
- "wheel",
1250
- { wheel: { dx: t.deltaX, dy: t.deltaY, dz: t.deltaZ }, event: t, viewport: this.parent }
1251
- );
1252
- }
1253
- return !this.parent.options.passiveWheel;
1254
- }
1255
- }
1256
- class J {
1257
- /** List of active touches on viewport */
1258
- constructor(t) {
1259
- this.viewport = t, this.touches = [], this.addListeners();
1260
- }
1261
- /** Add input listeners */
1262
- addListeners() {
1263
- 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(
1264
- "wheel",
1265
- this.wheelFunction,
1266
- { passive: this.viewport.options.passiveWheel }
1267
- ), this.isMouseDown = !1;
1268
- }
1269
- /**
1270
- * Removes all event listeners from viewport
1271
- * (useful for cleanup of wheel when removing viewport)
1272
- */
1273
- destroy() {
1274
- this.viewport.options.divWheel.removeEventListener("wheel", this.wheelFunction);
1275
- }
1276
- /**
1277
- * handle down events for viewport
1278
- *
1279
- * @param {PIXI.InteractionEvent} event
1280
- */
1281
- down(t) {
1282
- if (this.viewport.pause || !this.viewport.worldVisible)
1283
- return;
1284
- 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) {
1285
- this.last = t.data.global.clone();
1286
- const n = this.viewport.plugins.get("decelerate", !0), i = this.viewport.plugins.get("bounce", !0);
1287
- (!n || !n.isActive()) && (!i || !i.isActive()) ? this.clickedAvailable = !0 : this.clickedAvailable = !1;
1288
- } else
1289
- this.clickedAvailable = !1;
1290
- this.viewport.plugins.down(t) && this.viewport.options.stopPropagation && t.stopPropagation();
1291
- }
1292
- /** Clears all pointer events */
1293
- clear() {
1294
- this.isMouseDown = !1, this.touches = [], this.last = null;
1295
- }
1296
- /**
1297
- * @param {number} change
1298
- * @returns whether change exceeds threshold
1299
- */
1300
- checkThreshold(t) {
1301
- return Math.abs(t) >= this.viewport.threshold;
1302
- }
1303
- /** Handle move events for viewport */
1304
- move(t) {
1305
- if (this.viewport.pause || !this.viewport.worldVisible)
1306
- return;
1307
- const e = this.viewport.plugins.move(t);
1308
- if (this.clickedAvailable && this.last) {
1309
- const n = t.data.global.x - this.last.x, i = t.data.global.y - this.last.y;
1310
- (this.checkThreshold(n) || this.checkThreshold(i)) && (this.clickedAvailable = !1);
1311
- }
1312
- e && this.viewport.options.stopPropagation && t.stopPropagation();
1313
- }
1314
- /** Handle up events for viewport */
1315
- up(t) {
1316
- if (this.viewport.pause || !this.viewport.worldVisible)
1317
- return;
1318
- t.data.pointerType === "mouse" && (this.isMouseDown = !1), t.data.pointerType !== "mouse" && this.remove(t.data.pointerId);
1319
- const e = this.viewport.plugins.up(t);
1320
- this.clickedAvailable && this.count() === 0 && this.last && (this.viewport.emit("clicked", {
1321
- event: t,
1322
- screen: this.last,
1323
- world: this.viewport.toWorld(this.last),
1324
- viewport: this
1325
- }), this.clickedAvailable = !1), e && this.viewport.options.stopPropagation && t.stopPropagation();
1326
- }
1327
- /** Gets pointer position if this.interaction is set */
1328
- getPointerPosition(t) {
1329
- const e = new c();
1330
- if (this.viewport.options.interaction)
1331
- this.viewport.options.interaction.mapPositionToPoint(e, t.clientX, t.clientY);
1332
- else if (this.viewport.options.useDivWheelForInputManager && this.viewport.options.divWheel) {
1333
- const n = this.viewport.options.divWheel.getBoundingClientRect();
1334
- e.x = t.clientX - n.left, e.y = t.clientY - n.top;
1335
- } else
1336
- e.x = t.clientX, e.y = t.clientY;
1337
- return e;
1338
- }
1339
- /** Handle wheel events */
1340
- handleWheel(t) {
1341
- if (this.viewport.pause || !this.viewport.worldVisible || this.viewport.options.interaction && this.viewport.options.interaction.interactionDOMElement !== t.target)
1342
- return;
1343
- const e = this.viewport.toLocal(this.getPointerPosition(t));
1344
- 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();
1345
- }
1346
- pause() {
1347
- this.touches = [], this.isMouseDown = !1;
1348
- }
1349
- /** Get touch by id */
1350
- get(t) {
1351
- for (const e of this.touches)
1352
- if (e.id === t)
1353
- return e;
1354
- return null;
1355
- }
1356
- /** Remove touch by number */
1357
- remove(t) {
1358
- for (let e = 0; e < this.touches.length; e++)
1359
- if (this.touches[e].id === t) {
1360
- this.touches.splice(e, 1);
1361
- return;
1362
- }
1363
- }
1364
- /**
1365
- * @returns {number} count of mouse/touch pointers that are down on the viewport
1366
- */
1367
- count() {
1368
- return (this.isMouseDown ? 1 : 0) + this.touches.length;
1369
- }
1370
- }
1371
- function W(l) {
1372
- let t, e = l[0], n = 1;
1373
- for (; n < l.length; ) {
1374
- const i = l[n], s = l[n + 1];
1375
- if (n += 2, (i === "optionalAccess" || i === "optionalCall") && e == null)
1376
- return;
1377
- i === "access" || i === "optionalAccess" ? (t = e, e = s(e)) : (i === "call" || i === "optionalCall") && (e = s((...h) => e.call(t, ...h)), t = void 0);
1378
- }
1379
- return e;
1380
- }
1381
- const m = [
1382
- "drag",
1383
- "pinch",
1384
- "wheel",
1385
- "follow",
1386
- "mouse-edges",
1387
- "decelerate",
1388
- "animate",
1389
- "bounce",
1390
- "snap-zoom",
1391
- "clamp-zoom",
1392
- "snap",
1393
- "clamp"
1394
- ];
1395
- class tt {
1396
- /** Maps mounted plugins by their type */
1397
- /**
1398
- * List of plugins mounted
1399
- *
1400
- * This list is kept sorted by the internal priority of plugins (hard-coded).
1401
- */
1402
- /** The viewport using the plugins managed by `this`. */
1403
- /** This is called by {@link Viewport} to initialize the {@link Viewport.plugins plugins}. */
1404
- constructor(t) {
1405
- this.viewport = t, this.list = [], this.plugins = {};
1406
- }
1407
- /**
1408
- * Inserts a named plugin or a user plugin into the viewport
1409
- * default plugin order: 'drag', 'pinch', 'wheel', 'follow', 'mouse-edges', 'decelerate', 'bounce',
1410
- * 'snap-zoom', 'clamp-zoom', 'snap', 'clamp'
1411
- *
1412
- * @param {string} name of plugin
1413
- * @param {Plugin} plugin - instantiated Plugin class
1414
- * @param {number} index to insert userPlugin (otherwise inserts it at the end)
1415
- */
1416
- add(t, e, n = m.length) {
1417
- const i = this.plugins[t];
1418
- i && i.destroy(), this.plugins[t] = e;
1419
- const s = m.indexOf(t);
1420
- s !== -1 && m.splice(s, 1), m.splice(n, 0, t), this.sort();
1421
- }
1422
- /**
1423
- * Get plugin
1424
- *
1425
- * @param {string} name of plugin
1426
- * @param {boolean} [ignorePaused] return null if plugin is paused
1427
- */
1428
- get(t, e) {
1429
- return e && W([this, "access", (n) => n.plugins, "access", (n) => n[t], "optionalAccess", (n) => n.paused]) ? null : this.plugins[t];
1430
- }
1431
- /**
1432
- * Update all active plugins
1433
- *
1434
- * @internal
1435
- * @ignore
1436
- * @param {number} elapsed type in milliseconds since last update
1437
- */
1438
- update(t) {
1439
- for (const e of this.list)
1440
- e.update(t);
1441
- }
1442
- /**
1443
- * Resize all active plugins
1444
- *
1445
- * @internal
1446
- * @ignore
1447
- */
1448
- resize() {
1449
- for (const t of this.list)
1450
- t.resize();
1451
- }
1452
- /** Clamps and resets bounce and decelerate (as needed) after manually moving viewport */
1453
- reset() {
1454
- for (const t of this.list)
1455
- t.reset();
1456
- }
1457
- /** removes all installed plugins */
1458
- removeAll() {
1459
- this.list.forEach((t) => {
1460
- t.destroy();
1461
- }), this.plugins = {}, this.sort();
1462
- }
1463
- /**
1464
- * Removes installed plugin
1465
- *
1466
- * @param {string} name of plugin (e.g., 'drag', 'pinch')
1467
- */
1468
- remove(t) {
1469
- 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());
1470
- }
1471
- /**
1472
- * Pause plugin
1473
- *
1474
- * @param {string} name of plugin (e.g., 'drag', 'pinch')
1475
- */
1476
- pause(t) {
1477
- W([this, "access", (e) => e.plugins, "access", (e) => e[t], "optionalAccess", (e) => e.pause, "call", (e) => e()]);
1478
- }
1479
- /**
1480
- * Resume plugin
1481
- *
1482
- * @param {string} name of plugin (e.g., 'drag', 'pinch')
1483
- */
1484
- resume(t) {
1485
- W([this, "access", (e) => e.plugins, "access", (e) => e[t], "optionalAccess", (e) => e.resume, "call", (e) => e()]);
1486
- }
1487
- /**
1488
- * Sort plugins according to PLUGIN_ORDER
1489
- *
1490
- * @internal
1491
- * @ignore
1492
- */
1493
- sort() {
1494
- this.list = [];
1495
- for (const t of m)
1496
- this.plugins[t] && this.list.push(this.plugins[t]);
1497
- }
1498
- /**
1499
- * Handle down for all plugins
1500
- *
1501
- * @internal
1502
- * @ignore
1503
- */
1504
- down(t) {
1505
- let e = !1;
1506
- for (const n of this.list)
1507
- n.down(t) && (e = !0);
1508
- return e;
1509
- }
1510
- /**
1511
- * Handle move for all plugins
1512
- *
1513
- * @internal
1514
- * @ignore
1515
- */
1516
- move(t) {
1517
- let e = !1;
1518
- for (const n of this.viewport.plugins.list)
1519
- n.move(t) && (e = !0);
1520
- return e;
1521
- }
1522
- /**
1523
- * Handle up for all plugins
1524
- *
1525
- * @internal
1526
- * @ignore
1527
- */
1528
- up(t) {
1529
- let e = !1;
1530
- for (const n of this.list)
1531
- n.up(t) && (e = !0);
1532
- return e;
1533
- }
1534
- /**
1535
- * Handle wheel event for all plugins
1536
- *
1537
- * @internal
1538
- * @ignore
1539
- */
1540
- wheel(t) {
1541
- let e = !1;
1542
- for (const n of this.list)
1543
- n.wheel(t) && (e = !0);
1544
- return e;
1545
- }
1546
- }
1547
- const et = {
1548
- screenWidth: window.innerWidth,
1549
- screenHeight: window.innerHeight,
1550
- worldWidth: null,
1551
- worldHeight: null,
1552
- threshold: 5,
1553
- passiveWheel: !0,
1554
- stopPropagation: !1,
1555
- forceHitArea: null,
1556
- noTicker: !1,
1557
- interaction: null,
1558
- disableOnContextMenu: !1,
1559
- ticker: C.shared
1560
- };
1561
- class O extends P {
1562
- /** Flags whether the viewport is being panned */
1563
- /** Number of pixels to move to trigger an input event (e.g., drag, pinch) or disable a clicked event */
1564
- /** Use this to add user plugins or access existing plugins (e.g., to pause, resume, or remove them) */
1565
- /** Flags whether the viewport zoom is being changed. */
1566
- /** The options passed when creating this viewport, merged with the default values */
1567
- __init() {
1568
- this._disableOnContextMenu = (t) => t.preventDefault();
1569
- }
1570
- /**
1571
- * @param {IViewportOptions} ViewportOptions
1572
- * @param {number} [options.screenWidth=window.innerWidth]
1573
- * @param {number} [options.screenHeight=window.innerHeight]
1574
- * @param {number} [options.worldWidth=this.width]
1575
- * @param {number} [options.worldHeight=this.height]
1576
- * @param {number} [options.threshold=5] number of pixels to move to trigger an input event (e.g., drag, pinch)
1577
- * or disable a clicked event
1578
- * @param {boolean} [options.passiveWheel=true] whether the 'wheel' event is set to passive (note: if false,
1579
- * e.preventDefault() will be called when wheel is used over the viewport)
1580
- * @param {boolean} [options.stopPropagation=false] whether to stopPropagation of events that impact the viewport
1581
- * (except wheel events, see options.passiveWheel)
1582
- * @param {HitArea} [options.forceHitArea] change the default hitArea from world size to a new value
1583
- * @param {boolean} [options.noTicker] set this if you want to manually call update() function on each frame
1584
- * @param {PIXI.Ticker} [options.ticker=PIXI.Ticker.shared] use this PIXI.ticker for updates
1585
- * @param {PIXI.InteractionManager} [options.interaction=null] InteractionManager, available from instantiated
1586
- * WebGLRenderer/CanvasRenderer.plugins.interaction - used to calculate pointer position relative to canvas
1587
- * location on screen
1588
- * @param {HTMLElement} [options.divWheel=document.body] div to attach the wheel event
1589
- * @param {boolean} [options.disableOnContextMenu] remove oncontextmenu=() => {} from the divWheel element
1590
- */
1591
- constructor(t = {}) {
1592
- super(), O.prototype.__init.call(this), this.options = Object.assign(
1593
- {},
1594
- { divWheel: document.body },
1595
- et,
1596
- t
1597
- ), 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);
1598
- }
1599
- /** Overrides PIXI.Container's destroy to also remove the 'wheel' and PIXI.Ticker listeners */
1600
- destroy(t) {
1601
- !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);
1602
- }
1603
- /**
1604
- * Update viewport on each frame.
1605
- *
1606
- * By default, you do not need to call this unless you set `options.noTicker=true`.
1607
- *
1608
- * @param {number} elapsed time in milliseconds since last update
1609
- */
1610
- update(t) {
1611
- 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 = {
1612
- x: this.x,
1613
- y: this.y,
1614
- scaleX: this.scale.x,
1615
- scaleY: this.scale.y
1616
- }, this.emit("frame-end", this));
1617
- }
1618
- /**
1619
- * Use this to set screen and world sizes, needed for pinch/wheel/clamp/bounce.
1620
- * @param {number} screenWidth=window.innerWidth
1621
- * @param {number} screenHeight=window.innerHeight
1622
- * @param {number} [worldWidth]
1623
- * @param {number} [worldHeight]
1624
- */
1625
- resize(t = window.innerWidth, e = window.innerHeight, n, i) {
1626
- this.screenWidth = t, this.screenHeight = e, typeof n < "u" && (this._worldWidth = n), typeof i < "u" && (this._worldHeight = i), this.plugins.resize(), this.dirty = !0;
1627
- }
1628
- /** World width, in pixels */
1629
- get worldWidth() {
1630
- return this._worldWidth ? this._worldWidth : this.width / this.scale.x;
1631
- }
1632
- set worldWidth(t) {
1633
- this._worldWidth = t, this.plugins.resize();
1634
- }
1635
- /** World height, in pixels */
1636
- get worldHeight() {
1637
- return this._worldHeight ? this._worldHeight : this.height / this.scale.y;
1638
- }
1639
- set worldHeight(t) {
1640
- this._worldHeight = t, this.plugins.resize();
1641
- }
1642
- /** Get visible world bounds of viewport */
1643
- getVisibleBounds() {
1644
- return new b(this.left, this.top, this.worldScreenWidth, this.worldScreenHeight);
1645
- }
1646
- /** Change coordinates from screen to world */
1647
- /**
1648
- * Changes coordinate from screen to world
1649
- * @param {number|PIXI.Point} x
1650
- * @param {number} y
1651
- * @returns {PIXI.Point}
1652
- */
1653
- toWorld(t, e) {
1654
- return arguments.length === 2 ? this.toLocal(new c(t, e)) : this.toLocal(t);
1655
- }
1656
- /** Change coordinates from world to screen */
1657
- /**
1658
- * Changes coordinate from world to screen
1659
- * @param {number|PIXI.Point} x
1660
- * @param {number} y
1661
- * @returns {PIXI.Point}
1662
- */
1663
- toScreen(t, e) {
1664
- return arguments.length === 2 ? this.toGlobal(new c(t, e)) : this.toGlobal(t);
1665
- }
1666
- /** Screen width in world coordinates */
1667
- get worldScreenWidth() {
1668
- return this.screenWidth / this.scale.x;
1669
- }
1670
- /** Screen height in world coordinates */
1671
- get worldScreenHeight() {
1672
- return this.screenHeight / this.scale.y;
1673
- }
1674
- /** World width in screen coordinates */
1675
- get screenWorldWidth() {
1676
- return this.worldWidth * this.scale.x;
1677
- }
1678
- /** World height in screen coordinates */
1679
- get screenWorldHeight() {
1680
- return this.worldHeight * this.scale.y;
1681
- }
1682
- /** Center of screen in world coordinates */
1683
- get center() {
1684
- return new c(
1685
- this.worldScreenWidth / 2 - this.x / this.scale.x,
1686
- this.worldScreenHeight / 2 - this.y / this.scale.y
1687
- );
1688
- }
1689
- set center(t) {
1690
- this.moveCenter(t);
1691
- }
1692
- /**
1693
- * Move center of viewport to (x, y)
1694
- * @param {number|PIXI.Point} x
1695
- * @param {number} [y]
1696
- * @return {Viewport}
1697
- */
1698
- moveCenter(...t) {
1699
- let e, n;
1700
- typeof t[0] == "number" ? (e = t[0], n = t[1]) : (e = t[0].x, n = t[0].y);
1701
- const i = (this.worldScreenWidth / 2 - e) * this.scale.x, s = (this.worldScreenHeight / 2 - n) * this.scale.y;
1702
- return (this.x !== i || this.y !== s) && (this.position.set(i, s), this.plugins.reset(), this.dirty = !0), this;
1703
- }
1704
- /** Top-left corner of Viewport */
1705
- get corner() {
1706
- return new c(-this.x / this.scale.x, -this.y / this.scale.y);
1707
- }
1708
- set corner(t) {
1709
- this.moveCorner(t);
1710
- }
1711
- /** Move Viewport's top-left corner; also clamps and resets decelerate and bounce (as needed) */
1712
- /**
1713
- * MoveCorner
1714
- * @param {number|PIXI.Point} x
1715
- * @param {number} [y]
1716
- * @returns {Viewport}
1717
- */
1718
- moveCorner(...t) {
1719
- let e, n;
1720
- 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;
1721
- }
1722
- /** Get how many world pixels fit in screen's width */
1723
- get screenWidthInWorldPixels() {
1724
- return this.screenWidth / this.scale.x;
1725
- }
1726
- /** Get how many world pixels fit on screen's height */
1727
- get screenHeightInWorldPixels() {
1728
- return this.screenHeight / this.scale.y;
1729
- }
1730
- /**
1731
- * Find the scale value that fits a world width on the screen
1732
- * does not change the viewport (use fit... to change)
1733
- *
1734
- * @param width - Width in world pixels
1735
- * @return - scale
1736
- */
1737
- findFitWidth(t) {
1738
- return this.screenWidth / t;
1739
- }
1740
- /**
1741
- * Finds the scale value that fits a world height on the screens
1742
- * does not change the viewport (use fit... to change)
1743
- *
1744
- * @param height - Height in world pixels
1745
- * @return - scale
1746
- */
1747
- findFitHeight(t) {
1748
- return this.screenHeight / t;
1749
- }
1750
- /**
1751
- * Finds the scale value that fits the smaller of a world width and world height on the screen
1752
- * does not change the viewport (use fit... to change)
1753
- *
1754
- * @param {number} width in world pixels
1755
- * @param {number} height in world pixels
1756
- * @returns {number} scale
1757
- */
1758
- findFit(t, e) {
1759
- const n = this.screenWidth / t, i = this.screenHeight / e;
1760
- return Math.min(n, i);
1761
- }
1762
- /**
1763
- * Finds the scale value that fits the larger of a world width and world height on the screen
1764
- * does not change the viewport (use fit... to change)
1765
- *
1766
- * @param {number} width in world pixels
1767
- * @param {number} height in world pixels
1768
- * @returns {number} scale
1769
- */
1770
- findCover(t, e) {
1771
- const n = this.screenWidth / t, i = this.screenHeight / e;
1772
- return Math.max(n, i);
1773
- }
1774
- /**
1775
- * Change zoom so the width fits in the viewport
1776
- *
1777
- * @param width - width in world coordinates
1778
- * @param center - maintain the same center
1779
- * @param scaleY - whether to set scaleY=scaleX
1780
- * @param noClamp - whether to disable clamp-zoom
1781
- * @returns {Viewport} this
1782
- */
1783
- fitWidth(t = this.worldWidth, e, n = !0, i) {
1784
- let s;
1785
- e && (s = this.center), this.scale.x = this.screenWidth / t, n && (this.scale.y = this.scale.x);
1786
- const h = this.plugins.get("clamp-zoom", !0);
1787
- return !i && h && h.clamp(), e && s && this.moveCenter(s), this;
1788
- }
1789
- /**
1790
- * Change zoom so the height fits in the viewport
1791
- *
1792
- * @param {number} [height=this.worldHeight] in world coordinates
1793
- * @param {boolean} [center] maintain the same center of the screen after zoom
1794
- * @param {boolean} [scaleX=true] whether to set scaleX = scaleY
1795
- * @param {boolean} [noClamp] whether to disable clamp-zoom
1796
- * @returns {Viewport} this
1797
- */
1798
- fitHeight(t = this.worldHeight, e, n = !0, i) {
1799
- let s;
1800
- e && (s = this.center), this.scale.y = this.screenHeight / t, n && (this.scale.x = this.scale.y);
1801
- const h = this.plugins.get("clamp-zoom", !0);
1802
- return !i && h && h.clamp(), e && s && this.moveCenter(s), this;
1803
- }
1804
- /**
1805
- * Change zoom so it fits the entire world in the viewport
1806
- *
1807
- * @param {boolean} center maintain the same center of the screen after zoom
1808
- * @returns {Viewport} this
1809
- */
1810
- fitWorld(t) {
1811
- let e;
1812
- 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;
1813
- const n = this.plugins.get("clamp-zoom", !0);
1814
- return n && n.clamp(), t && e && this.moveCenter(e), this;
1815
- }
1816
- /**
1817
- * Change zoom so it fits the size or the entire world in the viewport
1818
- *
1819
- * @param {boolean} [center] maintain the same center of the screen after zoom
1820
- * @param {number} [width=this.worldWidth] desired width
1821
- * @param {number} [height=this.worldHeight] desired height
1822
- * @returns {Viewport} this
1823
- */
1824
- fit(t, e = this.worldWidth, n = this.worldHeight) {
1825
- let i;
1826
- 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;
1827
- const s = this.plugins.get("clamp-zoom", !0);
1828
- return s && s.clamp(), t && i && this.moveCenter(i), this;
1829
- }
1830
- /**
1831
- * Zoom viewport to specific value.
1832
- *
1833
- * @param {number} scale value (e.g., 1 would be 100%, 0.25 would be 25%)
1834
- * @param {boolean} [center] maintain the same center of the screen after zoom
1835
- * @return {Viewport} this
1836
- */
1837
- setZoom(t, e) {
1838
- let n;
1839
- e && (n = this.center), this.scale.set(t);
1840
- const i = this.plugins.get("clamp-zoom", !0);
1841
- return i && i.clamp(), e && n && this.moveCenter(n), this;
1842
- }
1843
- /**
1844
- * Zoom viewport by a certain percent (in both x and y direction).
1845
- *
1846
- * @param {number} percent change (e.g., 0.25 would increase a starting scale of 1.0 to 1.25)
1847
- * @param {boolean} [center] maintain the same center of the screen after zoom
1848
- * @return {Viewport} this
1849
- */
1850
- zoomPercent(t, e) {
1851
- return this.setZoom(this.scale.x + this.scale.x * t, e);
1852
- }
1853
- /**
1854
- * Zoom viewport by increasing/decreasing width by a certain number of pixels.
1855
- *
1856
- * @param {number} change in pixels
1857
- * @param {boolean} [center] maintain the same center of the screen after zoom
1858
- * @return {Viewport} this
1859
- */
1860
- zoom(t, e) {
1861
- return this.fitWidth(t + this.worldScreenWidth, e), this;
1862
- }
1863
- /** Changes scale of viewport and maintains center of viewport */
1864
- get scaled() {
1865
- return this.scale.x;
1866
- }
1867
- set scaled(t) {
1868
- this.setZoom(t, !0);
1869
- }
1870
- /**
1871
- * Returns zoom to the desired scale
1872
- *
1873
- * @param {ISnapZoomOptions} options
1874
- * @param {number} [options.width=0] - the desired width to snap (to maintain aspect ratio, choose width or height)
1875
- * @param {number} [options.height=0] - the desired height to snap (to maintain aspect ratio, choose width or height)
1876
- * @param {number} [options.time=1000] - time for snapping in ms
1877
- * @param {(string|function)} [options.ease=easeInOutSine] ease function or name (see http://easings.net/
1878
- * for supported names)
1879
- * @param {PIXI.Point} [options.center] - place this point at center during zoom instead of center of the viewport
1880
- * @param {boolean} [options.interrupt=true] - pause snapping with any user input on the viewport
1881
- * @param {boolean} [options.removeOnComplete] - removes this plugin after snapping is complete
1882
- * @param {boolean} [options.removeOnInterrupt] - removes this plugin if interrupted by any user input
1883
- * @param {boolean} [options.forceStart] - starts the snap immediately regardless of whether the viewport is at the
1884
- * desired zoom
1885
- * @param {boolean} [options.noMove] - zoom but do not move
1886
- */
1887
- snapZoom(t) {
1888
- return this.plugins.add("snap-zoom", new G(this, t)), this;
1889
- }
1890
- /** Is container out of world bounds */
1891
- OOB() {
1892
- return {
1893
- left: this.left < 0,
1894
- right: this.right > this.worldWidth,
1895
- top: this.top < 0,
1896
- bottom: this.bottom > this.worldHeight,
1897
- cornerPoint: new c(
1898
- this.worldWidth * this.scale.x - this.screenWidth,
1899
- this.worldHeight * this.scale.y - this.screenHeight
1900
- )
1901
- };
1902
- }
1903
- /** World coordinates of the right edge of the screen */
1904
- get right() {
1905
- return -this.x / this.scale.x + this.worldScreenWidth;
1906
- }
1907
- set right(t) {
1908
- this.x = -t * this.scale.x + this.screenWidth, this.plugins.reset();
1909
- }
1910
- /** World coordinates of the left edge of the screen */
1911
- get left() {
1912
- return -this.x / this.scale.x;
1913
- }
1914
- set left(t) {
1915
- this.x = -t * this.scale.x, this.plugins.reset();
1916
- }
1917
- /** World coordinates of the top edge of the screen */
1918
- get top() {
1919
- return -this.y / this.scale.y;
1920
- }
1921
- set top(t) {
1922
- this.y = -t * this.scale.y, this.plugins.reset();
1923
- }
1924
- /** World coordinates of the bottom edge of the screen */
1925
- get bottom() {
1926
- return -this.y / this.scale.y + this.worldScreenHeight;
1927
- }
1928
- set bottom(t) {
1929
- this.y = -t * this.scale.y + this.screenHeight, this.plugins.reset();
1930
- }
1931
- /**
1932
- * Determines whether the viewport is dirty (i.e., needs to be rendered to the screen because of a change)
1933
- */
1934
- get dirty() {
1935
- return !!this._dirty;
1936
- }
1937
- set dirty(t) {
1938
- this._dirty = t;
1939
- }
1940
- /**
1941
- * Permanently changes the Viewport's hitArea
1942
- *
1943
- * NOTE: if not set then hitArea = PIXI.Rectangle(Viewport.left, Viewport.top, Viewport.worldScreenWidth,
1944
- * Viewport.worldScreenHeight)
1945
- */
1946
- get forceHitArea() {
1947
- return this._forceHitArea;
1948
- }
1949
- set forceHitArea(t) {
1950
- t ? (this._forceHitArea = t, this.hitArea = t) : (this._forceHitArea = null, this.hitArea = new b(0, 0, this.worldWidth, this.worldHeight));
1951
- }
1952
- /**
1953
- * Enable one-finger touch to drag
1954
- *
1955
- * NOTE: if you expect users to use right-click dragging, you should enable `viewport.options.disableOnContextMenu`
1956
- * to avoid the context menu popping up on each right-click drag.
1957
- *
1958
- * @param {IDragOptions} [options]
1959
- * @param {string} [options.direction=all] direction to drag
1960
- * @param {boolean} [options.pressDrag=true] whether click to drag is active
1961
- * @param {boolean} [options.wheel=true] use wheel to scroll in direction (unless wheel plugin is active)
1962
- * @param {number} [options.wheelScroll=1] number of pixels to scroll with each wheel spin
1963
- * @param {boolean} [options.reverse] reverse the direction of the wheel scroll
1964
- * @param {(boolean|string)} [options.clampWheel=false] clamp wheel(to avoid weird bounce with mouse wheel)
1965
- * @param {string} [options.underflow=center] where to place world if too small for screen
1966
- * @param {number} [options.factor=1] factor to multiply drag to increase the speed of movement
1967
- * @param {string} [options.mouseButtons=all] changes which mouse buttons trigger drag, use: 'all', 'left',
1968
- * 'right' 'middle', or some combination, like, 'middle-right'; you may want to set
1969
- * viewport.options.disableOnContextMenu if you want to use right-click dragging
1970
- * @param {string[]} [options.keyToPress=null] - array containing
1971
- * {@link key|https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code} codes of keys that can be
1972
- * pressed for the drag to be triggered, e.g.: ['ShiftLeft', 'ShiftRight'}.
1973
- * @param {boolean} [options.ignoreKeyToPressOnTouch=false] - ignore keyToPress for touch events
1974
- * @param {number} [options.lineHeight=20] - scaling factor for non-DOM_DELTA_PIXEL scrolling events
1975
- * @returns {Viewport} this
1976
- */
1977
- drag(t) {
1978
- return this.plugins.add("drag", new S(this, t)), this;
1979
- }
1980
- /**
1981
- * Clamp to world boundaries or other provided boundaries
1982
- * There are three ways to clamp:
1983
- * 1. direction: 'all' = the world is clamped to its world boundaries, ie, you cannot drag any part of offscreen
1984
- * direction: 'x' | 'y' = only the x or y direction is clamped to its world boundary
1985
- * 2. left, right, top, bottom = true | number = the world is clamped to the world's pixel location for each side;
1986
- * if any of these are set to true, then the location is set to the boundary
1987
- * [0, viewport.worldWidth/viewport.worldHeight], eg: to allow the world to be completely dragged offscreen,
1988
- * set [-viewport.worldWidth, -viewport.worldHeight, viewport.worldWidth * 2, viewport.worldHeight * 2]
1989
- *
1990
- * Underflow determines what happens when the world is smaller than the viewport
1991
- * 1. none = the world is clamped but there is no special behavior
1992
- * 2. center = the world is centered on the viewport
1993
- * 3. combination of top/bottom/center and left/right/center (case insensitive) = the world is stuck to the
1994
- * appropriate boundaries
1995
- *
1996
- * NOTES:
1997
- * clamp is disabled if called with no options; use { direction: 'all' } for all edge clamping
1998
- * screenWidth, screenHeight, worldWidth, and worldHeight needs to be set for this to work properly
1999
- *
2000
- * @param {object} [options]
2001
- * @param {(number|boolean)} [options.left=false] - clamp left; true = 0
2002
- * @param {(number|boolean)} [options.right=false] - clamp right; true = viewport.worldWidth
2003
- * @param {(number|boolean)} [options.top=false] - clamp top; true = 0
2004
- * @param {(number|boolean)} [options.bottom=false] - clamp bottom; true = viewport.worldHeight
2005
- * @param {string} [direction] - (all, x, or y) using clamps of [0, viewport.worldWidth/viewport.worldHeight];
2006
- * replaces left/right/top/bottom if set
2007
- * @param {string} [underflow=center] - where to place world if too small for screen (e.g., top-right, center,
2008
- * none, bottomLeft) * @returns {Viewport} this
2009
- */
2010
- clamp(t) {
2011
- return this.plugins.add("clamp", new T(this, t)), this;
2012
- }
2013
- /**
2014
- * Decelerate after a move
2015
- *
2016
- * NOTE: this fires 'moved' event during deceleration
2017
- *
2018
- * @param {IDecelerateOptions} [options]
2019
- * @param {number} [options.friction=0.95] - percent to decelerate after movement
2020
- * @param {number} [options.bounce=0.8] - percent to decelerate when past boundaries (only applicable when
2021
- * viewport.bounce() is active)
2022
- * @param {number} [options.minSpeed=0.01] - minimum velocity before stopping/reversing acceleration
2023
- * @return {Viewport} this
2024
- */
2025
- decelerate(t) {
2026
- return this.plugins.add("decelerate", new U(this, t)), this;
2027
- }
2028
- /**
2029
- * Bounce on borders
2030
- * NOTES:
2031
- * screenWidth, screenHeight, worldWidth, and worldHeight needs to be set for this to work properly
2032
- * fires 'moved', 'bounce-x-start', 'bounce-y-start', 'bounce-x-end', and 'bounce-y-end' events
2033
- * @param {object} [options]
2034
- * @param {string} [options.sides=all] - all, horizontal, vertical, or combination of top, bottom, right, left
2035
- * (e.g., 'top-bottom-right')
2036
- * @param {number} [options.friction=0.5] - friction to apply to decelerate if active
2037
- * @param {number} [options.time=150] - time in ms to finish bounce
2038
- * @param {object} [options.bounceBox] - use this bounceBox instead of (0, 0, viewport.worldWidth, viewport.worldHeight)
2039
- * @param {number} [options.bounceBox.x=0]
2040
- * @param {number} [options.bounceBox.y=0]
2041
- * @param {number} [options.bounceBox.width=viewport.worldWidth]
2042
- * @param {number} [options.bounceBox.height=viewport.worldHeight]
2043
- * @param {string|function} [options.ease=easeInOutSine] - ease function or name
2044
- * (see http://easings.net/ for supported names)
2045
- * @param {string} [options.underflow=center] - (top/bottom/center and left/right/center, or center)
2046
- * where to place world if too small for screen
2047
- * @return {Viewport} this
2048
- */
2049
- bounce(t) {
2050
- return this.plugins.add("bounce", new z(this, t)), this;
2051
- }
2052
- /**
2053
- * Enable pinch to zoom and two-finger touch to drag
2054
- *
2055
- * @param {PinchOptions} [options]
2056
- * @param {boolean} [options.noDrag] - disable two-finger dragging
2057
- * @param {number} [options.percent=1] - percent to modify pinch speed
2058
- * @param {number} [options.factor=1] - factor to multiply two-finger drag to increase the speed of movement
2059
- * @param {PIXI.Point} [options.center] - place this point at center during zoom instead of center of two fingers
2060
- * @param {('all'|'x'|'y')} [options.axis=all] - axis to zoom
2061
- * @return {Viewport} this
2062
- */
2063
- pinch(t) {
2064
- return this.plugins.add("pinch", new w(this, t)), this;
2065
- }
2066
- /**
2067
- * Snap to a point
2068
- *
2069
- * @param {number} x
2070
- * @param {number} y
2071
- * @param {ISnapOptions} [options]
2072
- * @param {boolean} [options.topLeft] - snap to the top-left of viewport instead of center
2073
- * @param {number} [options.friction=0.8] - friction/frame to apply if decelerate is active
2074
- * @param {number} [options.time=1000] - time in ms to snap
2075
- * @param {string|function} [options.ease=easeInOutSine] - ease function or name (see http://easings.net/
2076
- * for supported names)
2077
- * @param {boolean} [options.interrupt=true] - pause snapping with any user input on the viewport
2078
- * @param {boolean} [options.removeOnComplete] - removes this plugin after snapping is complete
2079
- * @param {boolean} [options.removeOnInterrupt] - removes this plugin if interrupted by any user input
2080
- * @param {boolean} [options.forceStart] - starts the snap immediately regardless of whether the viewport is at
2081
- * the desired location
2082
- * @return {Viewport} this
2083
- */
2084
- snap(t, e, n) {
2085
- return this.plugins.add("snap", new q(this, t, e, n)), this;
2086
- }
2087
- /**
2088
- * Follow a target
2089
- *
2090
- * NOTES:
2091
- * uses the (x, y) as the center to follow; for PIXI.Sprite to work properly, use sprite.anchor.set(0.5)
2092
- * options.acceleration is not perfect as it doesn't know the velocity of the target. It adds acceleration
2093
- * to the start of movement and deceleration to the end of movement when the target is stopped.
2094
- * To cancel the follow, use: `viewport.plugins.remove('follow')`
2095
- *
2096
- * @fires 'moved' event
2097
- *
2098
- * @param {PIXI.DisplayObject} target to follow
2099
- * @param {IFollowOptions} [options]
2100
- * @param {number} [options.speed=0] - to follow in pixels/frame (0=teleport to location)
2101
- * @param {number} [options.acceleration] - set acceleration to accelerate and decelerate at this rate; speed
2102
- * cannot be 0 to use acceleration
2103
- * @param {number} [options.radius] - radius (in world coordinates) of center circle where movement is allowed
2104
- * without moving the viewport * @returns {Viewport} this
2105
- * @returns {Viewport} this
2106
- */
2107
- follow(t, e) {
2108
- return this.plugins.add("follow", new V(this, t, e)), this;
2109
- }
2110
- /**
2111
- * Zoom using mouse wheel
2112
- *
2113
- * NOTE: the default event listener for 'wheel' event is document.body. Use `Viewport.options.divWheel` to
2114
- * change this default
2115
- *
2116
- * @param {IWheelOptions} [options]
2117
- * @param {number} [options.percent=0.1] - percent to scroll with each spin
2118
- * @param {number} [options.smooth] - smooth the zooming by providing the number of frames to zoom between wheel spins
2119
- * @param {boolean} [options.interrupt=true] - stop smoothing with any user input on the viewport
2120
- * @param {boolean} [options.reverse] - reverse the direction of the scroll
2121
- * @param {PIXI.Point} [options.center] - place this point at center during zoom instead of current mouse position
2122
- * @param {number} [options.lineHeight=20] - scaling factor for non-DOM_DELTA_PIXEL scrolling events
2123
- * @param {('all'|'x'|'y')} [options.axis=all] - axis to zoom
2124
- * @return {Viewport} this
2125
- */
2126
- wheel(t) {
2127
- return this.plugins.add("wheel", new $(this, t)), this;
2128
- }
2129
- /**
2130
- * Animate the position and/or scale of the viewport
2131
- * To set the zoom level, use: (1) scale, (2) scaleX and scaleY, or (3) width and/or height
2132
- * @param {object} options
2133
- * @param {number} [options.time=1000] - time to animate
2134
- * @param {PIXI.Point} [options.position=viewport.center] - position to move viewport
2135
- * @param {number} [options.width] - desired viewport width in world pixels (use instead of scale;
2136
- * aspect ratio is maintained if height is not provided)
2137
- * @param {number} [options.height] - desired viewport height in world pixels (use instead of scale;
2138
- * aspect ratio is maintained if width is not provided)
2139
- * @param {number} [options.scale] - scale to change zoom (scale.x = scale.y)
2140
- * @param {number} [options.scaleX] - independently change zoom in x-direction
2141
- * @param {number} [options.scaleY] - independently change zoom in y-direction
2142
- * @param {(function|string)} [options.ease=linear] - easing function to use
2143
- * @param {function} [options.callbackOnComplete]
2144
- * @param {boolean} [options.removeOnInterrupt] removes this plugin if interrupted by any user input
2145
- * @returns {Viewport} this
2146
- */
2147
- animate(t) {
2148
- return this.plugins.add("animate", new d(this, t)), this;
2149
- }
2150
- /**
2151
- * Enable clamping of zoom to constraints
2152
- *
2153
- * The minWidth/Height settings are how small the world can get (as it would appear on the screen)
2154
- * before clamping. The maxWidth/maxHeight is how larger the world can scale (as it would appear on
2155
- * the screen) before clamping.
2156
- *
2157
- * For example, if you have a world size of 1000 x 1000 and a screen size of 100 x 100, if you set
2158
- * minWidth/Height = 100 then the world will not be able to zoom smaller than the screen size (ie,
2159
- * zooming out so it appears smaller than the screen). Similarly, if you set maxWidth/Height = 100
2160
- * the world will not be able to zoom larger than the screen size (ie, zooming in so it appears
2161
- * larger than the screen).
2162
- *
2163
- * @param {object} [options]
2164
- * @param {number} [options.minWidth] - minimum width
2165
- * @param {number} [options.minHeight] - minimum height
2166
- * @param {number} [options.maxWidth] - maximum width
2167
- * @param {number} [options.maxHeight] - maximum height
2168
- * @param {number} [options.minScale] - minimum scale
2169
- * @param {number} [options.maxScale] - minimum scale
2170
- * @return {Viewport} this
2171
- */
2172
- clampZoom(t) {
2173
- return this.plugins.add("clamp-zoom", new L(this, t)), this;
2174
- }
2175
- /**
2176
- * Scroll viewport when mouse hovers near one of the edges or radius-distance from center of screen.
2177
- *
2178
- * NOTES: fires 'moved' event; there's a known bug where the mouseEdges does not work properly with "windowed" viewports
2179
- *
2180
- * @param {IMouseEdgesOptions} [options]
2181
- * @param {number} [options.radius] - distance from center of screen in screen pixels
2182
- * @param {number} [options.distance] - distance from all sides in screen pixels
2183
- * @param {number} [options.top] - alternatively, set top distance (leave unset for no top scroll)
2184
- * @param {number} [options.bottom] - alternatively, set bottom distance (leave unset for no top scroll)
2185
- * @param {number} [options.left] - alternatively, set left distance (leave unset for no top scroll)
2186
- * @param {number} [options.right] - alternatively, set right distance (leave unset for no top scroll)
2187
- * @param {number} [options.speed=8] - speed in pixels/frame to scroll viewport
2188
- * @param {boolean} [options.reverse] - reverse direction of scroll
2189
- * @param {boolean} [options.noDecelerate] - don't use decelerate plugin even if it's installed
2190
- * @param {boolean} [options.linear] - if using radius, use linear movement (+/- 1, +/- 1) instead of angled
2191
- * movement (Math.cos(angle from center), Math.sin(angle from center))
2192
- * @param {boolean} [options.allowButtons] allows plugin to continue working even when there's a mousedown event
2193
- */
2194
- mouseEdges(t) {
2195
- return this.plugins.add("mouse-edges", new N(this, t)), this;
2196
- }
2197
- /** Pause viewport (including animation updates such as decelerate) */
2198
- get pause() {
2199
- return !!this._pause;
2200
- }
2201
- set pause(t) {
2202
- this._pause = t, this.lastViewport = null, this.moving = !1, this.zooming = !1, t && this.input.pause();
2203
- }
2204
- /**
2205
- * Move the viewport so the bounding box is visible
2206
- *
2207
- * @param x - left
2208
- * @param y - top
2209
- * @param width
2210
- * @param height
2211
- * @param resizeToFit - Resize the viewport so the box fits within the viewport
2212
- */
2213
- ensureVisible(t, e, n, i, s) {
2214
- s && (n > this.worldScreenWidth || i > this.worldScreenHeight) && (this.fit(!0, n, i), this.emit("zoomed", { viewport: this, type: "ensureVisible" }));
2215
- let h = !1;
2216
- 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" });
2217
- }
2218
- }
2219
- export {
2220
- d as Animate,
2221
- z as Bounce,
2222
- T as Clamp,
2223
- L as ClampZoom,
2224
- U as Decelerate,
2225
- S as Drag,
2226
- V as Follow,
2227
- J as InputManager,
2228
- N as MouseEdges,
2229
- w as Pinch,
2230
- u as Plugin,
2231
- tt as PluginManager,
2232
- q as Snap,
2233
- G as SnapZoom,
2234
- O as Viewport,
2235
- $ as Wheel
2236
- };
2237
- //# sourceMappingURL=viewport.es-3ce16114.mjs.map