react-zoom-pan-pinch 3.6.1 → 4.0.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.
- package/dist/index.cjs.js +770 -277
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +116 -22
- package/dist/index.esm.js +766 -269
- package/dist/index.esm.js.map +1 -1
- package/package.json +73 -60
- package/src/components/index.ts +5 -0
- package/src/components/keep-scale/keep-scale.tsx +28 -0
- package/src/components/mini-map/mini-map.tsx +292 -0
- package/src/components/mini-map/use-resize.hook.ts +74 -0
- package/src/components/transform-component/transform-component.module.css +43 -0
- package/src/components/transform-component/transform-component.tsx +96 -0
- package/src/components/transform-wrapper/transform-wrapper.tsx +39 -0
- package/src/components/virtualize/virtualize.tsx +133 -0
- package/src/components/virtualize/virtualize.utils.ts +104 -0
- package/src/constants/state.constants.ts +99 -0
- package/src/core/animations/animations.constants.ts +78 -0
- package/src/core/animations/animations.utils.ts +115 -0
- package/src/core/bounds/bounds.types.ts +8 -0
- package/src/core/bounds/bounds.utils.ts +226 -0
- package/src/core/double-click/double-click.logic.ts +127 -0
- package/src/core/handlers/handlers.logic.ts +122 -0
- package/src/core/handlers/handlers.utils.ts +243 -0
- package/src/core/instance.core.ts +704 -0
- package/src/core/pan/panning.logic.ts +122 -0
- package/src/core/pan/panning.utils.ts +216 -0
- package/src/core/pan/velocity.logic.ts +187 -0
- package/src/core/pan/velocity.utils.ts +83 -0
- package/src/core/pinch/pinch.logic.ts +139 -0
- package/src/core/pinch/pinch.utils.ts +95 -0
- package/src/core/wheel/wheel.logic.ts +161 -0
- package/src/core/wheel/wheel.utils.ts +157 -0
- package/src/core/zoom/zoom.logic.ts +71 -0
- package/src/core/zoom/zoom.utils.ts +62 -0
- package/src/hooks/index.ts +5 -0
- package/src/hooks/use-controls.tsx +9 -0
- package/src/hooks/use-transform-component.tsx +30 -0
- package/src/hooks/use-transform-context.tsx +13 -0
- package/src/hooks/use-transform-effect.tsx +22 -0
- package/src/hooks/use-transform-init.tsx +28 -0
- package/src/hooks/use-zoom-pan-pinch.tsx +48 -0
- package/src/index.ts +6 -0
- package/src/models/calculations.model.ts +34 -0
- package/src/models/context.model.ts +218 -0
- package/src/models/helpers.model.ts +15 -0
- package/src/models/index.ts +3 -0
- package/src/react-app-env.d.ts +1 -0
- package/src/stories/assets/big-image.jpeg +0 -0
- package/src/stories/assets/map.jpg +0 -0
- package/src/stories/assets/medium-image.jpg +0 -0
- package/src/stories/assets/pin.svg +1 -0
- package/src/stories/assets/small-image.jpg +0 -0
- package/src/stories/assets/svg-example.svg +14 -0
- package/src/stories/docs/DocTable.tsx +59 -0
- package/src/stories/docs/HandlerCards.tsx +102 -0
- package/src/stories/docs/Introduction.stories.mdx +135 -0
- package/src/stories/docs/PropTable.tsx +116 -0
- package/src/stories/docs/docs.module.css +370 -0
- package/src/stories/docs/handlers.stories.mdx +7 -0
- package/src/stories/docs/handlers.tsx +111 -0
- package/src/stories/docs/props.stories.mdx +11 -0
- package/src/stories/docs/props.tsx +571 -0
- package/src/stories/examples/axis-lock/axis-lock.stories.mdx +35 -0
- package/src/stories/examples/axis-lock/example.tsx +114 -0
- package/src/stories/examples/bounds/bounds.data.tsx +191 -0
- package/src/stories/examples/bounds/bounds.stories.mdx +99 -0
- package/src/stories/examples/center-zoomed-out/center-zoomed-out.stories.mdx +206 -0
- package/src/stories/examples/cinema/cinema-data.tsx +578 -0
- package/src/stories/examples/cinema/cinema.stories.mdx +30 -0
- package/src/stories/examples/cinema/example.tsx +378 -0
- package/src/stories/examples/cinema/image.png +0 -0
- package/src/stories/examples/content/content.stories.mdx +172 -0
- package/src/stories/examples/content/mixed-content.data.tsx +624 -0
- package/src/stories/examples/content-rerendering/content-updating.stories.mdx +34 -0
- package/src/stories/examples/content-rerendering/example.tsx +631 -0
- package/src/stories/examples/controls/controls.stories.mdx +120 -0
- package/src/stories/examples/image/example.tsx +149 -0
- package/src/stories/examples/image/image.stories.mdx +46 -0
- package/src/stories/examples/image-annotations/example.tsx +1442 -0
- package/src/stories/examples/image-annotations/image-annotations.stories.mdx +39 -0
- package/src/stories/examples/image-responsive/example.tsx +152 -0
- package/src/stories/examples/image-responsive/image-responsive.stories.mdx +51 -0
- package/src/stories/examples/image-zoomed-out/image-zoomed-out.stories.mdx +107 -0
- package/src/stories/examples/initial-transform/example.tsx +233 -0
- package/src/stories/examples/initial-transform/initial-transform.stories.mdx +37 -0
- package/src/stories/examples/keep-scale/example.tsx +882 -0
- package/src/stories/examples/keep-scale/keep-scale.stories.mdx +30 -0
- package/src/stories/examples/keep-scale/map.stories.mdx +28 -0
- package/src/stories/examples/medical-viewer/chest-xray.tsx +246 -0
- package/src/stories/examples/medical-viewer/example.tsx +690 -0
- package/src/stories/examples/medical-viewer/medical-viewer.stories.mdx +49 -0
- package/src/stories/examples/mini-map/example.tsx +122 -0
- package/src/stories/examples/mini-map/mini-map.stories.mdx +26 -0
- package/src/stories/examples/miro/example.tsx +1573 -0
- package/src/stories/examples/miro/miro.stories.mdx +31 -0
- package/src/stories/examples/padding/example.tsx +147 -0
- package/src/stories/examples/padding/padding.stories.mdx +35 -0
- package/src/stories/examples/product-card/example.tsx +594 -0
- package/src/stories/examples/product-card/product-card.stories.mdx +29 -0
- package/src/stories/examples/stadium/example.tsx +1040 -0
- package/src/stories/examples/stadium/stadium-data.ts +224 -0
- package/src/stories/examples/stadium/stadium.stories.mdx +32 -0
- package/src/stories/examples/stress/example.tsx +59 -0
- package/src/stories/examples/stress/stress-test.stories.mdx +28 -0
- package/src/stories/examples/svg-zoom-to-element/creativity.svg +143 -0
- package/src/stories/examples/svg-zoom-to-element/example.tsx +95 -0
- package/src/stories/examples/svg-zoom-to-element/svg-zoom-to-element.stories.mdx +28 -0
- package/src/stories/examples/text-selection/example.tsx +221 -0
- package/src/stories/examples/text-selection/text-selection.stories.mdx +31 -0
- package/src/stories/examples/velocity/example.tsx +908 -0
- package/src/stories/examples/velocity/velocity.stories.mdx +35 -0
- package/src/stories/examples/virtualize/example.tsx +239 -0
- package/src/stories/examples/virtualize/virtualize.stories.mdx +84 -0
- package/src/stories/examples/zoom-to-element/example.tsx +219 -0
- package/src/stories/examples/zoom-to-element/zoom-to-element.stories.mdx +31 -0
- package/src/stories/hooks/use-controls.stories.mdx +86 -0
- package/src/stories/hooks/use-transform-component.stories.mdx +108 -0
- package/src/stories/hooks/use-transform-context.stories.mdx +92 -0
- package/src/stories/hooks/use-transform-effect.stories.mdx +114 -0
- package/src/stories/hooks/use-transform-init.stories.mdx +105 -0
- package/src/stories/types/args.types.ts +192 -0
- package/src/stories/utils/args.utils.ts +35 -0
- package/src/stories/utils/bounds-overlay.tsx +168 -0
- package/src/stories/utils/code.utils.tsx +22 -0
- package/src/stories/utils/controls.utils.tsx +347 -0
- package/src/stories/utils/index.ts +5 -0
- package/src/stories/utils/styles.module.css +223 -0
- package/src/stories/utils/viewer.styles.ts +34 -0
- package/src/styles.css +8 -0
- package/src/typings.d.ts +21 -0
- package/src/utils/calculations.utils.ts +16 -0
- package/src/utils/callback.utils.ts +11 -0
- package/src/utils/context.utils.ts +49 -0
- package/src/utils/event.utils.ts +38 -0
- package/src/utils/helpers.utils.ts +22 -0
- package/src/utils/index.ts +8 -0
- package/src/utils/ref.utils.ts +32 -0
- package/src/utils/state.utils.ts +77 -0
- package/src/utils/styles.utils.ts +49 -0
package/dist/index.cjs.js
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var React = require('react');
|
|
6
|
-
|
|
7
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
-
|
|
9
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
4
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
10
5
|
|
|
11
6
|
/**
|
|
12
7
|
* Rounds number to given decimal
|
|
@@ -119,7 +114,7 @@ var handleCancelAnimation = function (contextInstance) {
|
|
|
119
114
|
return;
|
|
120
115
|
handleCancelAnimationFrame(contextInstance.animation);
|
|
121
116
|
// Clear animation state
|
|
122
|
-
contextInstance.
|
|
117
|
+
contextInstance.isAnimating = false;
|
|
123
118
|
contextInstance.animation = null;
|
|
124
119
|
contextInstance.velocity = null;
|
|
125
120
|
};
|
|
@@ -163,21 +158,27 @@ function animate(contextInstance, targetState, animationTime, animationName) {
|
|
|
163
158
|
var isValid = isValidTargetState(targetState);
|
|
164
159
|
if (!contextInstance.mounted || !isValid)
|
|
165
160
|
return;
|
|
166
|
-
var
|
|
167
|
-
var _a = contextInstance.
|
|
161
|
+
var setState = contextInstance.setState;
|
|
162
|
+
var _a = contextInstance.state, scale = _a.scale, positionX = _a.positionX, positionY = _a.positionY;
|
|
168
163
|
var scaleDiff = targetState.scale - scale;
|
|
169
164
|
var positionXDiff = targetState.positionX - positionX;
|
|
170
165
|
var positionYDiff = targetState.positionY - positionY;
|
|
171
166
|
if (animationTime === 0) {
|
|
172
|
-
|
|
167
|
+
setState(targetState.scale, targetState.positionX, targetState.positionY);
|
|
173
168
|
}
|
|
174
169
|
else {
|
|
175
170
|
// animation start timestamp
|
|
176
171
|
handleSetupAnimation(contextInstance, animationName, animationTime, function (step) {
|
|
172
|
+
if (step !== 1) {
|
|
173
|
+
contextInstance.isAnimating = true;
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
contextInstance.isAnimating = false;
|
|
177
|
+
}
|
|
177
178
|
var newScale = scale + scaleDiff * step;
|
|
178
179
|
var newPositionX = positionX + positionXDiff * step;
|
|
179
180
|
var newPositionY = positionY + positionYDiff * step;
|
|
180
|
-
|
|
181
|
+
setState(newScale, newPositionX, newPositionY);
|
|
181
182
|
});
|
|
182
183
|
}
|
|
183
184
|
}
|
|
@@ -203,25 +204,54 @@ function getComponentsSizes(wrapperComponent, contentComponent, newScale) {
|
|
|
203
204
|
}
|
|
204
205
|
var getBounds = function (wrapperWidth, newContentWidth, diffWidth, wrapperHeight, newContentHeight, diffHeight, centerZoomedOut) {
|
|
205
206
|
var scaleWidthFactor = wrapperWidth > newContentWidth
|
|
206
|
-
? diffWidth * (centerZoomedOut ?
|
|
207
|
+
? diffWidth * (centerZoomedOut ? 0.5 : 1)
|
|
207
208
|
: 0;
|
|
208
209
|
var scaleHeightFactor = wrapperHeight > newContentHeight
|
|
209
|
-
? diffHeight * (centerZoomedOut ?
|
|
210
|
+
? diffHeight * (centerZoomedOut ? 0.5 : 1)
|
|
210
211
|
: 0;
|
|
211
212
|
var minPositionX = wrapperWidth - newContentWidth - scaleWidthFactor;
|
|
212
213
|
var maxPositionX = scaleWidthFactor;
|
|
213
214
|
var minPositionY = wrapperHeight - newContentHeight - scaleHeightFactor;
|
|
214
215
|
var maxPositionY = scaleHeightFactor;
|
|
215
|
-
return {
|
|
216
|
+
return {
|
|
217
|
+
minPositionX: minPositionX,
|
|
218
|
+
maxPositionX: maxPositionX,
|
|
219
|
+
minPositionY: minPositionY,
|
|
220
|
+
maxPositionY: maxPositionY,
|
|
221
|
+
scaleWidthFactor: scaleWidthFactor,
|
|
222
|
+
scaleHeightFactor: scaleHeightFactor,
|
|
223
|
+
};
|
|
216
224
|
};
|
|
217
225
|
var calculateBounds = function (contextInstance, newScale) {
|
|
218
226
|
var wrapperComponent = contextInstance.wrapperComponent, contentComponent = contextInstance.contentComponent;
|
|
219
|
-
var
|
|
227
|
+
var _a = contextInstance.setup, centerZoomedOut = _a.centerZoomedOut, disablePadding = _a.disablePadding;
|
|
220
228
|
if (!wrapperComponent || !contentComponent) {
|
|
221
229
|
throw new Error("Components are not mounted");
|
|
222
230
|
}
|
|
223
|
-
var
|
|
231
|
+
var _b = getComponentsSizes(wrapperComponent, contentComponent, newScale), wrapperWidth = _b.wrapperWidth, wrapperHeight = _b.wrapperHeight, newContentWidth = _b.newContentWidth, newContentHeight = _b.newContentHeight, newDiffWidth = _b.newDiffWidth, newDiffHeight = _b.newDiffHeight;
|
|
224
232
|
var bounds = getBounds(wrapperWidth, newContentWidth, newDiffWidth, wrapperHeight, newContentHeight, newDiffHeight, Boolean(centerZoomedOut));
|
|
233
|
+
var contentFitsCompletely = wrapperWidth >= newContentWidth && wrapperHeight >= newContentHeight;
|
|
234
|
+
if (disablePadding && contentFitsCompletely && !centerZoomedOut) {
|
|
235
|
+
bounds.minPositionX = 0;
|
|
236
|
+
bounds.maxPositionX = 0;
|
|
237
|
+
bounds.minPositionY = 0;
|
|
238
|
+
bounds.maxPositionY = 0;
|
|
239
|
+
}
|
|
240
|
+
var _c = contextInstance.setup, propMinX = _c.minPositionX, propMaxX = _c.maxPositionX, propMinY = _c.minPositionY, propMaxY = _c.maxPositionY;
|
|
241
|
+
// Explicit position props define content-space boundaries at scale=1.
|
|
242
|
+
// Scale them so the same content region stays reachable at every zoom level.
|
|
243
|
+
if (propMinX != null) {
|
|
244
|
+
bounds.minPositionX = wrapperWidth * (1 - newScale) + propMinX * newScale;
|
|
245
|
+
}
|
|
246
|
+
if (propMaxX != null) {
|
|
247
|
+
bounds.maxPositionX = propMaxX * newScale;
|
|
248
|
+
}
|
|
249
|
+
if (propMinY != null) {
|
|
250
|
+
bounds.minPositionY = wrapperHeight * (1 - newScale) + propMinY * newScale;
|
|
251
|
+
}
|
|
252
|
+
if (propMaxY != null) {
|
|
253
|
+
bounds.maxPositionY = propMaxY * newScale;
|
|
254
|
+
}
|
|
225
255
|
return bounds;
|
|
226
256
|
};
|
|
227
257
|
/**
|
|
@@ -260,7 +290,7 @@ function getMouseBoundedPosition(positionX, positionY, bounds, limitToBounds, pa
|
|
|
260
290
|
}
|
|
261
291
|
|
|
262
292
|
function handleCalculateZoomPositions(contextInstance, mouseX, mouseY, newScale, bounds, limitToBounds) {
|
|
263
|
-
var _a = contextInstance.
|
|
293
|
+
var _a = contextInstance.state, scale = _a.scale, positionX = _a.positionX, positionY = _a.positionY;
|
|
264
294
|
var scaleDifference = newScale - scale;
|
|
265
295
|
if (typeof mouseX !== "number" || typeof mouseY !== "number") {
|
|
266
296
|
console.error("Mouse X and Y position were not provided!");
|
|
@@ -273,14 +303,16 @@ function handleCalculateZoomPositions(contextInstance, mouseX, mouseY, newScale,
|
|
|
273
303
|
var newPositions = getMouseBoundedPosition(calculatedPositionX, calculatedPositionY, bounds, limitToBounds, 0, 0, null);
|
|
274
304
|
return newPositions;
|
|
275
305
|
}
|
|
306
|
+
var MIN_SAFE_SCALE = 1e-7;
|
|
276
307
|
function checkZoomBounds(zoom, minScale, maxScale, zoomPadding, enablePadding) {
|
|
277
308
|
var scalePadding = enablePadding ? zoomPadding : 0;
|
|
278
|
-
var minScaleWithPadding = minScale - scalePadding;
|
|
279
|
-
|
|
280
|
-
|
|
309
|
+
var minScaleWithPadding = Math.max(minScale - scalePadding, MIN_SAFE_SCALE);
|
|
310
|
+
var maxScaleWithPadding = maxScale + scalePadding;
|
|
311
|
+
if (!Number.isNaN(maxScale) && zoom >= maxScaleWithPadding)
|
|
312
|
+
return maxScaleWithPadding;
|
|
281
313
|
if (!Number.isNaN(minScale) && zoom <= minScaleWithPadding)
|
|
282
314
|
return minScaleWithPadding;
|
|
283
|
-
return zoom;
|
|
315
|
+
return Math.max(zoom, MIN_SAFE_SCALE);
|
|
284
316
|
}
|
|
285
317
|
|
|
286
318
|
var isPanningStartAllowed = function (contextInstance, event) {
|
|
@@ -302,6 +334,11 @@ var isPanningStartAllowed = function (contextInstance, event) {
|
|
|
302
334
|
var isExcluded = isExcludedNode(target, excluded);
|
|
303
335
|
if (isExcluded)
|
|
304
336
|
return false;
|
|
337
|
+
if (target.getAttribute("draggable") === "true" ||
|
|
338
|
+
target.getAttribute("contenteditable") === "true" ||
|
|
339
|
+
target.isContentEditable) {
|
|
340
|
+
return false;
|
|
341
|
+
}
|
|
305
342
|
return true;
|
|
306
343
|
};
|
|
307
344
|
var isPanningAllowed = function (contextInstance) {
|
|
@@ -313,7 +350,7 @@ var isPanningAllowed = function (contextInstance) {
|
|
|
313
350
|
return true;
|
|
314
351
|
};
|
|
315
352
|
var handlePanningSetup = function (contextInstance, event) {
|
|
316
|
-
var _a = contextInstance.
|
|
353
|
+
var _a = contextInstance.state, positionX = _a.positionX, positionY = _a.positionY;
|
|
317
354
|
contextInstance.isPanning = true;
|
|
318
355
|
// Panning with mouse
|
|
319
356
|
var x = event.clientX;
|
|
@@ -322,7 +359,7 @@ var handlePanningSetup = function (contextInstance, event) {
|
|
|
322
359
|
};
|
|
323
360
|
var handleTouchPanningSetup = function (contextInstance, event) {
|
|
324
361
|
var touches = event.touches;
|
|
325
|
-
var _a = contextInstance.
|
|
362
|
+
var _a = contextInstance.state, positionX = _a.positionX, positionY = _a.positionY;
|
|
326
363
|
contextInstance.isPanning = true;
|
|
327
364
|
// Panning with touch
|
|
328
365
|
var oneFingerTouch = touches.length === 1;
|
|
@@ -333,7 +370,7 @@ var handleTouchPanningSetup = function (contextInstance, event) {
|
|
|
333
370
|
}
|
|
334
371
|
};
|
|
335
372
|
function handlePanToBounds(contextInstance) {
|
|
336
|
-
var _a = contextInstance.
|
|
373
|
+
var _a = contextInstance.state, positionX = _a.positionX, positionY = _a.positionY, scale = _a.scale;
|
|
337
374
|
var _b = contextInstance.setup, disabled = _b.disabled, limitToBounds = _b.limitToBounds, centerZoomedOut = _b.centerZoomedOut;
|
|
338
375
|
var wrapperComponent = contextInstance.wrapperComponent;
|
|
339
376
|
if (disabled || !wrapperComponent || !contextInstance.bounds)
|
|
@@ -357,20 +394,20 @@ function handlePanToBounds(contextInstance) {
|
|
|
357
394
|
function handleNewPosition(contextInstance, newPositionX, newPositionY, paddingValueX, paddingValueY) {
|
|
358
395
|
var limitToBounds = contextInstance.setup.limitToBounds;
|
|
359
396
|
var wrapperComponent = contextInstance.wrapperComponent, bounds = contextInstance.bounds;
|
|
360
|
-
var _a = contextInstance.
|
|
397
|
+
var _a = contextInstance.state, scale = _a.scale, positionX = _a.positionX, positionY = _a.positionY;
|
|
361
398
|
if (wrapperComponent === null ||
|
|
362
399
|
bounds === null ||
|
|
363
400
|
(newPositionX === positionX && newPositionY === positionY)) {
|
|
364
401
|
return;
|
|
365
402
|
}
|
|
366
403
|
var _b = getMouseBoundedPosition(newPositionX, newPositionY, bounds, limitToBounds, paddingValueX, paddingValueY, wrapperComponent), x = _b.x, y = _b.y;
|
|
367
|
-
contextInstance.
|
|
404
|
+
contextInstance.setState(scale, x, y);
|
|
368
405
|
}
|
|
369
406
|
var getPanningClientPosition = function (contextInstance, clientX, clientY) {
|
|
370
|
-
var startCoords = contextInstance.startCoords,
|
|
407
|
+
var startCoords = contextInstance.startCoords, state = contextInstance.state;
|
|
371
408
|
var panning = contextInstance.setup.panning;
|
|
372
409
|
var lockAxisX = panning.lockAxisX, lockAxisY = panning.lockAxisY;
|
|
373
|
-
var positionX =
|
|
410
|
+
var positionX = state.positionX, positionY = state.positionY;
|
|
374
411
|
if (!startCoords) {
|
|
375
412
|
return { x: positionX, y: positionY };
|
|
376
413
|
}
|
|
@@ -380,32 +417,43 @@ var getPanningClientPosition = function (contextInstance, clientX, clientY) {
|
|
|
380
417
|
var newPositionY = lockAxisY ? positionY : mouseY;
|
|
381
418
|
return { x: newPositionX, y: newPositionY };
|
|
382
419
|
};
|
|
383
|
-
var getPaddingValue = function (contextInstance, size) {
|
|
384
|
-
var setup = contextInstance.setup,
|
|
385
|
-
var
|
|
386
|
-
var
|
|
387
|
-
if (size > 0 && scale >= minScale && !disablePadding) {
|
|
420
|
+
var getPaddingValue = function (contextInstance, size, explicitScale) {
|
|
421
|
+
var setup = contextInstance.setup, state = contextInstance.state;
|
|
422
|
+
var minScale = setup.minScale, disablePadding = setup.disablePadding, centerZoomedOut = setup.centerZoomedOut;
|
|
423
|
+
var scale = explicitScale !== null && explicitScale !== void 0 ? explicitScale : state.scale;
|
|
424
|
+
if (size > 0 && scale >= minScale && !disablePadding && !centerZoomedOut) {
|
|
388
425
|
return size;
|
|
389
426
|
}
|
|
390
427
|
return 0;
|
|
391
428
|
};
|
|
392
429
|
|
|
430
|
+
exports.DeviceType = void 0;
|
|
431
|
+
(function (DeviceType) {
|
|
432
|
+
DeviceType["TRACK_PAD"] = "track_pad";
|
|
433
|
+
DeviceType["MOUSE"] = "mouse";
|
|
434
|
+
DeviceType["TOUCH"] = "touch";
|
|
435
|
+
})(exports.DeviceType || (exports.DeviceType = {}));
|
|
436
|
+
|
|
393
437
|
var isVelocityCalculationAllowed = function (contextInstance) {
|
|
394
|
-
var mounted = contextInstance.mounted;
|
|
395
|
-
var _a = contextInstance.setup, disabled = _a.disabled, velocityAnimation = _a.velocityAnimation;
|
|
396
|
-
var scale = contextInstance.
|
|
438
|
+
var mounted = contextInstance.mounted, wrapperComponent = contextInstance.wrapperComponent, contentComponent = contextInstance.contentComponent;
|
|
439
|
+
var _a = contextInstance.setup, disabled = _a.disabled, velocityAnimation = _a.velocityAnimation, limitToBounds = _a.limitToBounds;
|
|
440
|
+
var scale = contextInstance.state.scale;
|
|
397
441
|
var disabledVelocity = velocityAnimation.disabled;
|
|
398
|
-
|
|
399
|
-
if (!isAllowed)
|
|
442
|
+
if (disabledVelocity || disabled || !mounted)
|
|
400
443
|
return false;
|
|
401
|
-
|
|
444
|
+
if (!wrapperComponent || !contentComponent)
|
|
445
|
+
return false;
|
|
446
|
+
if (!limitToBounds)
|
|
447
|
+
return true;
|
|
448
|
+
var contentOverflows = wrapperComponent.offsetWidth < contentComponent.offsetWidth * scale ||
|
|
449
|
+
wrapperComponent.offsetHeight < contentComponent.offsetHeight * scale;
|
|
450
|
+
return contentOverflows;
|
|
402
451
|
};
|
|
403
452
|
var isVelocityAllowed = function (contextInstance) {
|
|
404
453
|
var mounted = contextInstance.mounted, velocity = contextInstance.velocity, bounds = contextInstance.bounds;
|
|
405
454
|
var _a = contextInstance.setup, disabled = _a.disabled, velocityAnimation = _a.velocityAnimation;
|
|
406
|
-
var scale = contextInstance.transformState.scale;
|
|
407
455
|
var disabledVelocity = velocityAnimation.disabled;
|
|
408
|
-
var isAllowed = !disabledVelocity
|
|
456
|
+
var isAllowed = !disabledVelocity && !disabled && mounted;
|
|
409
457
|
if (!isAllowed)
|
|
410
458
|
return false;
|
|
411
459
|
if (!velocity || !bounds)
|
|
@@ -414,11 +462,8 @@ var isVelocityAllowed = function (contextInstance) {
|
|
|
414
462
|
};
|
|
415
463
|
function getVelocityMoveTime(contextInstance, velocity) {
|
|
416
464
|
var velocityAnimation = contextInstance.setup.velocityAnimation;
|
|
417
|
-
var
|
|
418
|
-
|
|
419
|
-
return animationTime * velocity * sensitivity;
|
|
420
|
-
}
|
|
421
|
-
return animationTime;
|
|
465
|
+
var animationTime = velocityAnimation.animationTime, maxAnimationTime = velocityAnimation.maxAnimationTime, inertia = velocityAnimation.inertia;
|
|
466
|
+
return Math.min(animationTime * Math.max(1, Math.abs(velocity / inertia)), maxAnimationTime);
|
|
422
467
|
}
|
|
423
468
|
function getVelocityPosition(newPosition, startPosition, currentPosition, isLocked, limitToBounds, minPosition, maxPosition, minTarget, maxTarget, step) {
|
|
424
469
|
if (limitToBounds) {
|
|
@@ -444,31 +489,53 @@ function getVelocityPosition(newPosition, startPosition, currentPosition, isLock
|
|
|
444
489
|
return boundLimiter(newPosition, minPosition, maxPosition, limitToBounds);
|
|
445
490
|
}
|
|
446
491
|
|
|
447
|
-
|
|
492
|
+
/* eslint-disable no-param-reassign */
|
|
493
|
+
function getSizeMultiplier(wrapperComponent) {
|
|
448
494
|
var defaultMultiplier = 1;
|
|
449
|
-
|
|
450
|
-
|
|
495
|
+
var value = wrapperComponent.offsetWidth / window.innerWidth;
|
|
496
|
+
if (Number.isNaN(value)) {
|
|
497
|
+
return defaultMultiplier;
|
|
451
498
|
}
|
|
452
|
-
return defaultMultiplier;
|
|
499
|
+
return Math.min(defaultMultiplier, value);
|
|
453
500
|
}
|
|
454
|
-
function
|
|
501
|
+
var getMinMaxVelocity = function (velocity, maxStrength, sensitivity) {
|
|
502
|
+
var defaultMultiplier = 0;
|
|
503
|
+
var value = velocity * sensitivity;
|
|
504
|
+
if (Number.isNaN(value)) {
|
|
505
|
+
return defaultMultiplier;
|
|
506
|
+
}
|
|
507
|
+
if (velocity < 0) {
|
|
508
|
+
return Math.max(value, -maxStrength);
|
|
509
|
+
}
|
|
510
|
+
return Math.min(value, maxStrength);
|
|
511
|
+
};
|
|
512
|
+
function handleCalculateVelocity(contextInstance, position, device) {
|
|
513
|
+
var _a, _b;
|
|
455
514
|
var isAllowed = isVelocityCalculationAllowed(contextInstance);
|
|
456
515
|
if (!isAllowed) {
|
|
457
516
|
return;
|
|
458
517
|
}
|
|
459
518
|
var lastMousePosition = contextInstance.lastMousePosition, velocityTime = contextInstance.velocityTime, setup = contextInstance.setup;
|
|
460
519
|
var wrapperComponent = contextInstance.wrapperComponent;
|
|
461
|
-
var
|
|
520
|
+
var _c = setup.velocityAnimation, maxStrengthMouse = _c.maxStrengthMouse, maxStrengthTouch = _c.maxStrengthTouch, sensitivityTouch = _c.sensitivityTouch, sensitivityMouse = _c.sensitivityMouse;
|
|
462
521
|
var now = Date.now();
|
|
463
522
|
if (lastMousePosition && velocityTime && wrapperComponent) {
|
|
464
|
-
var sizeMultiplier = getSizeMultiplier(wrapperComponent
|
|
523
|
+
var sizeMultiplier = getSizeMultiplier(wrapperComponent);
|
|
524
|
+
var sensitivity = (_a = {},
|
|
525
|
+
_a[exports.DeviceType.TOUCH] = sensitivityTouch,
|
|
526
|
+
_a[exports.DeviceType.MOUSE] = sensitivityMouse,
|
|
527
|
+
_a)[device];
|
|
528
|
+
var maxStrength = (_b = {},
|
|
529
|
+
_b[exports.DeviceType.TOUCH] = maxStrengthTouch,
|
|
530
|
+
_b[exports.DeviceType.MOUSE] = maxStrengthMouse,
|
|
531
|
+
_b)[device];
|
|
465
532
|
var distanceX = position.x - lastMousePosition.x;
|
|
466
533
|
var distanceY = position.y - lastMousePosition.y;
|
|
467
|
-
var velocityX = distanceX / sizeMultiplier;
|
|
468
|
-
var velocityY = distanceY / sizeMultiplier;
|
|
534
|
+
var velocityX = getMinMaxVelocity(distanceX / sizeMultiplier, maxStrength, sensitivity);
|
|
535
|
+
var velocityY = getMinMaxVelocity(distanceY / sizeMultiplier, maxStrength, sensitivity);
|
|
469
536
|
var interval = now - velocityTime;
|
|
470
537
|
var speed = distanceX * distanceX + distanceY * distanceY;
|
|
471
|
-
var velocity = Math.sqrt(speed) / interval;
|
|
538
|
+
var velocity = getMinMaxVelocity(Math.sqrt(speed) / interval, maxStrength, sensitivity);
|
|
472
539
|
contextInstance.velocity = { velocityX: velocityX, velocityY: velocityY, total: velocity };
|
|
473
540
|
}
|
|
474
541
|
contextInstance.lastMousePosition = position;
|
|
@@ -482,11 +549,11 @@ function handleVelocityPanning(contextInstance) {
|
|
|
482
549
|
}
|
|
483
550
|
var velocityX = velocity.velocityX, velocityY = velocity.velocityY, total = velocity.total;
|
|
484
551
|
var maxPositionX = bounds.maxPositionX, minPositionX = bounds.minPositionX, maxPositionY = bounds.maxPositionY, minPositionY = bounds.minPositionY;
|
|
485
|
-
var limitToBounds = setup.limitToBounds,
|
|
552
|
+
var limitToBounds = setup.limitToBounds, autoAlignment = setup.autoAlignment;
|
|
486
553
|
var zoomAnimation = setup.zoomAnimation, panning = setup.panning;
|
|
487
554
|
var lockAxisY = panning.lockAxisY, lockAxisX = panning.lockAxisX;
|
|
488
555
|
var animationType = zoomAnimation.animationType;
|
|
489
|
-
var sizeX =
|
|
556
|
+
var sizeX = autoAlignment.sizeX, sizeY = autoAlignment.sizeY, velocityAlignmentTime = autoAlignment.velocityAlignmentTime;
|
|
490
557
|
var alignAnimationTime = velocityAlignmentTime;
|
|
491
558
|
var moveAnimationTime = getVelocityMoveTime(contextInstance, total);
|
|
492
559
|
var finalAnimationTime = Math.max(moveAnimationTime, alignAnimationTime);
|
|
@@ -498,13 +565,13 @@ function handleVelocityPanning(contextInstance) {
|
|
|
498
565
|
var minTargetX = minPositionX - paddingX;
|
|
499
566
|
var maxTargetY = maxPositionY + paddingY;
|
|
500
567
|
var minTargetY = minPositionY - paddingY;
|
|
501
|
-
var startState = contextInstance.
|
|
568
|
+
var startState = contextInstance.state;
|
|
502
569
|
var startTime = new Date().getTime();
|
|
503
570
|
handleSetupAnimation(contextInstance, animationType, finalAnimationTime, function (step) {
|
|
504
|
-
var _a = contextInstance.
|
|
571
|
+
var _a = contextInstance.state, scale = _a.scale, positionX = _a.positionX, positionY = _a.positionY;
|
|
505
572
|
var frameTime = new Date().getTime() - startTime;
|
|
506
573
|
var animationProgress = frameTime / alignAnimationTime;
|
|
507
|
-
var alignAnimation = animations[
|
|
574
|
+
var alignAnimation = animations[autoAlignment.animationType];
|
|
508
575
|
var alignStep = 1 - alignAnimation(Math.min(1, animationProgress));
|
|
509
576
|
var customStep = 1 - step;
|
|
510
577
|
var newPositionX = positionX + velocityX * customStep;
|
|
@@ -512,13 +579,18 @@ function handleVelocityPanning(contextInstance) {
|
|
|
512
579
|
var currentPositionX = getVelocityPosition(newPositionX, startState.positionX, positionX, lockAxisX, limitToBounds, minPositionX, maxPositionX, minTargetX, maxTargetX, alignStep);
|
|
513
580
|
var currentPositionY = getVelocityPosition(newPositionY, startState.positionY, positionY, lockAxisY, limitToBounds, minPositionY, maxPositionY, minTargetY, maxTargetY, alignStep);
|
|
514
581
|
if (positionX !== newPositionX || positionY !== newPositionY) {
|
|
515
|
-
contextInstance.
|
|
582
|
+
contextInstance.setState(scale, currentPositionX, currentPositionY);
|
|
583
|
+
var onPanning = contextInstance.props.onPanning;
|
|
584
|
+
if (onPanning) {
|
|
585
|
+
onPanning(getContext(contextInstance), {});
|
|
586
|
+
}
|
|
516
587
|
}
|
|
517
588
|
});
|
|
518
589
|
}
|
|
519
590
|
|
|
520
591
|
function handlePanningStart(contextInstance, event) {
|
|
521
|
-
var
|
|
592
|
+
var _a = contextInstance.state, scale = _a.scale, positionX = _a.positionX, positionY = _a.positionY;
|
|
593
|
+
contextInstance.panStartPosition = { x: positionX, y: positionY };
|
|
522
594
|
handleCancelAnimation(contextInstance);
|
|
523
595
|
handleCalculateBounds(contextInstance, scale);
|
|
524
596
|
if (window.TouchEvent !== undefined && event instanceof TouchEvent) {
|
|
@@ -528,44 +600,55 @@ function handlePanningStart(contextInstance, event) {
|
|
|
528
600
|
handlePanningSetup(contextInstance, event);
|
|
529
601
|
}
|
|
530
602
|
}
|
|
531
|
-
function handleAlignToBounds(contextInstance) {
|
|
532
|
-
var scale = contextInstance.
|
|
533
|
-
var _a = contextInstance.setup, minScale = _a.minScale,
|
|
534
|
-
var disabled =
|
|
603
|
+
function handleAlignToBounds(contextInstance, customAnimationTime) {
|
|
604
|
+
var scale = contextInstance.state.scale;
|
|
605
|
+
var _a = contextInstance.setup, minScale = _a.minScale, autoAlignment = _a.autoAlignment;
|
|
606
|
+
var disabled = autoAlignment.disabled, sizeX = autoAlignment.sizeX, sizeY = autoAlignment.sizeY, animationTime = autoAlignment.animationTime, animationType = autoAlignment.animationType;
|
|
535
607
|
var isDisabled = disabled || scale < minScale || (!sizeX && !sizeY);
|
|
536
608
|
if (isDisabled)
|
|
537
609
|
return;
|
|
538
610
|
var targetState = handlePanToBounds(contextInstance);
|
|
539
611
|
if (targetState) {
|
|
540
|
-
animate(contextInstance, targetState, animationTime, animationType);
|
|
612
|
+
animate(contextInstance, targetState, customAnimationTime !== null && customAnimationTime !== void 0 ? customAnimationTime : animationTime, animationType);
|
|
541
613
|
}
|
|
542
614
|
}
|
|
543
|
-
function handlePanning(contextInstance, clientX, clientY) {
|
|
615
|
+
function handlePanning(contextInstance, clientX, clientY, device) {
|
|
544
616
|
var startCoords = contextInstance.startCoords, setup = contextInstance.setup;
|
|
545
|
-
var _a = setup.
|
|
617
|
+
var _a = setup.autoAlignment, sizeX = _a.sizeX, sizeY = _a.sizeY;
|
|
546
618
|
if (!startCoords)
|
|
547
619
|
return;
|
|
548
620
|
var _b = getPanningClientPosition(contextInstance, clientX, clientY), x = _b.x, y = _b.y;
|
|
549
621
|
var paddingValueX = getPaddingValue(contextInstance, sizeX);
|
|
550
622
|
var paddingValueY = getPaddingValue(contextInstance, sizeY);
|
|
551
|
-
handleCalculateVelocity(contextInstance, { x: x, y: y });
|
|
623
|
+
handleCalculateVelocity(contextInstance, { x: x, y: y }, device);
|
|
552
624
|
handleNewPosition(contextInstance, x, y, paddingValueX, paddingValueY);
|
|
553
625
|
}
|
|
554
|
-
function handlePanningEnd(contextInstance) {
|
|
626
|
+
function handlePanningEnd(contextInstance, velocityDisabled) {
|
|
555
627
|
if (contextInstance.isPanning) {
|
|
556
|
-
var velocityDisabled = contextInstance.setup.panning.velocityDisabled;
|
|
557
628
|
var velocity = contextInstance.velocity, wrapperComponent = contextInstance.wrapperComponent, contentComponent = contextInstance.contentComponent;
|
|
558
629
|
contextInstance.isPanning = false;
|
|
559
|
-
contextInstance.
|
|
630
|
+
var _a = contextInstance.state, positionX = _a.positionX, positionY = _a.positionY, scale = _a.scale;
|
|
631
|
+
var start = contextInstance.panStartPosition;
|
|
632
|
+
contextInstance.panStartPosition = null;
|
|
633
|
+
if (start) {
|
|
634
|
+
var dx = positionX - start.x;
|
|
635
|
+
var dy = positionY - start.y;
|
|
636
|
+
if (dx * dx + dy * dy <= 25)
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
contextInstance.isAnimating = false;
|
|
560
640
|
contextInstance.animation = null;
|
|
561
|
-
var
|
|
562
|
-
var
|
|
563
|
-
var
|
|
564
|
-
var
|
|
565
|
-
var
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
var shouldAnimate = !velocityDisabled &&
|
|
641
|
+
var wrapperWidth = (wrapperComponent === null || wrapperComponent === void 0 ? void 0 : wrapperComponent.offsetWidth) || 0;
|
|
642
|
+
var wrapperHeight = (wrapperComponent === null || wrapperComponent === void 0 ? void 0 : wrapperComponent.offsetHeight) || 0;
|
|
643
|
+
var contentWidth = ((contentComponent === null || contentComponent === void 0 ? void 0 : contentComponent.offsetWidth) || 0) * scale;
|
|
644
|
+
var contentHeight = ((contentComponent === null || contentComponent === void 0 ? void 0 : contentComponent.offsetHeight) || 0) * scale;
|
|
645
|
+
var isContentOverflowing = !contextInstance.setup.limitToBounds ||
|
|
646
|
+
wrapperWidth < contentWidth ||
|
|
647
|
+
wrapperHeight < contentHeight;
|
|
648
|
+
var shouldAnimate = !velocityDisabled &&
|
|
649
|
+
velocity &&
|
|
650
|
+
velocity.total > 0.1 &&
|
|
651
|
+
isContentOverflowing;
|
|
569
652
|
if (shouldAnimate) {
|
|
570
653
|
handleVelocityPanning(contextInstance);
|
|
571
654
|
}
|
|
@@ -583,20 +666,21 @@ function handleZoomToPoint(contextInstance, scale, mouseX, mouseY) {
|
|
|
583
666
|
return { scale: newScale, positionX: x, positionY: y };
|
|
584
667
|
}
|
|
585
668
|
function handleAlignToScaleBounds(contextInstance, mousePositionX, mousePositionY) {
|
|
586
|
-
var scale = contextInstance.
|
|
669
|
+
var scale = contextInstance.state.scale;
|
|
587
670
|
var wrapperComponent = contextInstance.wrapperComponent;
|
|
588
|
-
var _a = contextInstance.setup, minScale = _a.minScale, limitToBounds = _a.limitToBounds, zoomAnimation = _a.zoomAnimation;
|
|
671
|
+
var _a = contextInstance.setup, minScale = _a.minScale, maxScale = _a.maxScale, limitToBounds = _a.limitToBounds, zoomAnimation = _a.zoomAnimation;
|
|
589
672
|
var disabled = zoomAnimation.disabled, animationTime = zoomAnimation.animationTime, animationType = zoomAnimation.animationType;
|
|
590
|
-
var
|
|
673
|
+
var isWithinBounds = scale >= minScale && scale <= maxScale;
|
|
674
|
+
var isDisabled = disabled || isWithinBounds;
|
|
591
675
|
if (scale >= 1 || limitToBounds) {
|
|
592
|
-
// fire fit to bounds animation
|
|
593
676
|
handleAlignToBounds(contextInstance);
|
|
594
677
|
}
|
|
595
678
|
if (isDisabled || !wrapperComponent || !contextInstance.mounted)
|
|
596
679
|
return;
|
|
597
680
|
var mouseX = mousePositionX || wrapperComponent.offsetWidth / 2;
|
|
598
681
|
var mouseY = mousePositionY || wrapperComponent.offsetHeight / 2;
|
|
599
|
-
var
|
|
682
|
+
var targetScale = scale < minScale ? minScale : maxScale;
|
|
683
|
+
var targetState = handleZoomToPoint(contextInstance, targetScale, mouseX, mouseY);
|
|
600
684
|
if (targetState) {
|
|
601
685
|
animate(contextInstance, targetState, animationTime, animationType);
|
|
602
686
|
}
|
|
@@ -616,6 +700,8 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
616
700
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
617
701
|
PERFORMANCE OF THIS SOFTWARE.
|
|
618
702
|
***************************************************************************** */
|
|
703
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
704
|
+
|
|
619
705
|
|
|
620
706
|
var __assign = function() {
|
|
621
707
|
__assign = Object.assign || function __assign(t) {
|
|
@@ -648,7 +734,12 @@ function __spreadArray(to, from, pack) {
|
|
|
648
734
|
}
|
|
649
735
|
}
|
|
650
736
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
651
|
-
}
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
740
|
+
var e = new Error(message);
|
|
741
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
742
|
+
};
|
|
652
743
|
|
|
653
744
|
var initialState = {
|
|
654
745
|
previousScale: 1,
|
|
@@ -669,15 +760,23 @@ var initialSetup = {
|
|
|
669
760
|
centerOnInit: false,
|
|
670
761
|
disablePadding: false,
|
|
671
762
|
smooth: true,
|
|
763
|
+
detached: false,
|
|
672
764
|
wheel: {
|
|
673
|
-
step: 0.
|
|
765
|
+
step: 0.015,
|
|
674
766
|
disabled: false,
|
|
675
|
-
smoothStep: 0.001,
|
|
676
767
|
wheelDisabled: false,
|
|
677
768
|
touchPadDisabled: false,
|
|
678
769
|
activationKeys: [],
|
|
679
770
|
excluded: [],
|
|
680
771
|
},
|
|
772
|
+
trackPadPanning: {
|
|
773
|
+
disabled: true,
|
|
774
|
+
velocityDisabled: false,
|
|
775
|
+
lockAxisX: false,
|
|
776
|
+
lockAxisY: false,
|
|
777
|
+
activationKeys: [],
|
|
778
|
+
excluded: [],
|
|
779
|
+
},
|
|
681
780
|
panning: {
|
|
682
781
|
disabled: false,
|
|
683
782
|
velocityDisabled: false,
|
|
@@ -686,13 +785,13 @@ var initialSetup = {
|
|
|
686
785
|
allowLeftClickPan: true,
|
|
687
786
|
allowMiddleClickPan: true,
|
|
688
787
|
allowRightClickPan: true,
|
|
689
|
-
wheelPanning: false,
|
|
690
788
|
activationKeys: [],
|
|
691
789
|
excluded: [],
|
|
692
790
|
},
|
|
693
791
|
pinch: {
|
|
694
792
|
step: 5,
|
|
695
793
|
disabled: false,
|
|
794
|
+
allowPanning: true,
|
|
696
795
|
excluded: [],
|
|
697
796
|
},
|
|
698
797
|
doubleClick: {
|
|
@@ -709,7 +808,7 @@ var initialSetup = {
|
|
|
709
808
|
animationTime: 200,
|
|
710
809
|
animationType: "easeOut",
|
|
711
810
|
},
|
|
712
|
-
|
|
811
|
+
autoAlignment: {
|
|
713
812
|
disabled: false,
|
|
714
813
|
sizeX: 100,
|
|
715
814
|
sizeY: 100,
|
|
@@ -719,10 +818,14 @@ var initialSetup = {
|
|
|
719
818
|
},
|
|
720
819
|
velocityAnimation: {
|
|
721
820
|
disabled: false,
|
|
722
|
-
|
|
723
|
-
|
|
821
|
+
sensitivityMouse: 1,
|
|
822
|
+
sensitivityTouch: 1.2,
|
|
823
|
+
maxStrengthMouse: 20,
|
|
824
|
+
maxStrengthTouch: 40,
|
|
825
|
+
inertia: 1,
|
|
826
|
+
animationTime: 300,
|
|
827
|
+
maxAnimationTime: 800,
|
|
724
828
|
animationType: "easeOut",
|
|
725
|
-
equalToMove: true,
|
|
726
829
|
},
|
|
727
830
|
};
|
|
728
831
|
var baseClasses = {
|
|
@@ -731,39 +834,49 @@ var baseClasses = {
|
|
|
731
834
|
};
|
|
732
835
|
|
|
733
836
|
var createState = function (props) {
|
|
734
|
-
var _a, _b, _c, _d;
|
|
837
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
838
|
+
var minScale = Math.max((_a = props.minScale) !== null && _a !== void 0 ? _a : initialSetup.minScale, 1e-7);
|
|
839
|
+
var maxScale = (_b = props.maxScale) !== null && _b !== void 0 ? _b : initialSetup.maxScale;
|
|
840
|
+
var rawScale = (_c = props.initialScale) !== null && _c !== void 0 ? _c : initialState.scale;
|
|
841
|
+
var scale = Math.min(Math.max(rawScale, minScale), maxScale);
|
|
842
|
+
var positionX = boundLimiter((_d = props.initialPositionX) !== null && _d !== void 0 ? _d : initialState.positionX, (_e = props.minPositionX) !== null && _e !== void 0 ? _e : -Infinity, (_f = props.maxPositionX) !== null && _f !== void 0 ? _f : Infinity, props.minPositionX != null || props.maxPositionX != null);
|
|
843
|
+
var positionY = boundLimiter((_g = props.initialPositionY) !== null && _g !== void 0 ? _g : initialState.positionY, (_h = props.minPositionY) !== null && _h !== void 0 ? _h : -Infinity, (_j = props.maxPositionY) !== null && _j !== void 0 ? _j : Infinity, props.minPositionY != null || props.maxPositionY != null);
|
|
735
844
|
return {
|
|
736
|
-
previousScale:
|
|
737
|
-
scale:
|
|
738
|
-
positionX:
|
|
739
|
-
positionY:
|
|
845
|
+
previousScale: scale,
|
|
846
|
+
scale: scale,
|
|
847
|
+
positionX: positionX,
|
|
848
|
+
positionY: positionY,
|
|
740
849
|
};
|
|
741
850
|
};
|
|
742
851
|
var createSetup = function (props) {
|
|
743
852
|
var newSetup = __assign({}, initialSetup);
|
|
744
853
|
Object.keys(props).forEach(function (key) {
|
|
745
|
-
var
|
|
746
|
-
var
|
|
854
|
+
var k = key;
|
|
855
|
+
var validValue = typeof props[k] !== "undefined";
|
|
856
|
+
var validParameter = typeof initialSetup[k] !== "undefined";
|
|
747
857
|
if (validParameter && validValue) {
|
|
748
|
-
var dataType = Object.prototype.toString.call(initialSetup[
|
|
858
|
+
var dataType = Object.prototype.toString.call(initialSetup[k]);
|
|
749
859
|
var isObject = dataType === "[object Object]";
|
|
750
860
|
var isArray = dataType === "[object Array]";
|
|
751
861
|
if (isObject) {
|
|
752
|
-
newSetup[
|
|
862
|
+
newSetup[k] = __assign(__assign({}, initialSetup[k]), props[k]);
|
|
753
863
|
}
|
|
754
864
|
else if (isArray) {
|
|
755
|
-
newSetup[
|
|
865
|
+
newSetup[k] = __spreadArray(__spreadArray([], initialSetup[k], true), props[k], true);
|
|
756
866
|
}
|
|
757
867
|
else {
|
|
758
|
-
newSetup[
|
|
868
|
+
newSetup[k] = props[k];
|
|
759
869
|
}
|
|
760
870
|
}
|
|
761
871
|
});
|
|
872
|
+
if (newSetup.minScale <= 0) {
|
|
873
|
+
newSetup.minScale = 1e-7;
|
|
874
|
+
}
|
|
762
875
|
return newSetup;
|
|
763
876
|
};
|
|
764
877
|
|
|
765
878
|
var handleCalculateButtonZoom = function (contextInstance, delta, step) {
|
|
766
|
-
var scale = contextInstance.
|
|
879
|
+
var scale = contextInstance.state.scale;
|
|
767
880
|
var wrapperComponent = contextInstance.wrapperComponent, setup = contextInstance.setup;
|
|
768
881
|
var maxScale = setup.maxScale, minScale = setup.minScale, zoomAnimation = setup.zoomAnimation, smooth = setup.smooth;
|
|
769
882
|
var size = zoomAnimation.size;
|
|
@@ -777,10 +890,13 @@ var handleCalculateButtonZoom = function (contextInstance, delta, step) {
|
|
|
777
890
|
return newScale;
|
|
778
891
|
};
|
|
779
892
|
function handleZoomToViewCenter(contextInstance, delta, step, animationTime, animationType) {
|
|
893
|
+
var _a, _b;
|
|
780
894
|
var wrapperComponent = contextInstance.wrapperComponent;
|
|
781
|
-
var
|
|
895
|
+
var _c = contextInstance.state, scale = _c.scale, positionX = _c.positionX, positionY = _c.positionY;
|
|
896
|
+
var zoomAnimation = contextInstance.setup.zoomAnimation;
|
|
782
897
|
if (!wrapperComponent)
|
|
783
898
|
return console.error("No WrapperComponent found");
|
|
899
|
+
var effectiveAnimationTime = zoomAnimation.disabled ? 0 : animationTime;
|
|
784
900
|
var wrapperWidth = wrapperComponent.offsetWidth;
|
|
785
901
|
var wrapperHeight = wrapperComponent.offsetHeight;
|
|
786
902
|
var mouseX = (wrapperWidth / 2 - positionX) / scale;
|
|
@@ -790,17 +906,38 @@ function handleZoomToViewCenter(contextInstance, delta, step, animationTime, ani
|
|
|
790
906
|
if (!targetState) {
|
|
791
907
|
return console.error("Error during zoom event. New transformation state was not calculated.");
|
|
792
908
|
}
|
|
793
|
-
|
|
909
|
+
var _d = contextInstance.props, onZoomStart = _d.onZoomStart, onZoom = _d.onZoom, onZoomStop = _d.onZoomStop;
|
|
910
|
+
var event = new MouseEvent("mousemove", { bubbles: true });
|
|
911
|
+
var ctx = getContext(contextInstance);
|
|
912
|
+
handleCallback(ctx, event, onZoomStart);
|
|
913
|
+
handleCallback(ctx, event, onZoom);
|
|
914
|
+
animate(contextInstance, targetState, effectiveAnimationTime, animationType);
|
|
915
|
+
var win = (_b = (_a = wrapperComponent.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView) !== null && _b !== void 0 ? _b : (typeof window !== "undefined" ? window : null);
|
|
916
|
+
if (win) {
|
|
917
|
+
win.setTimeout(function () {
|
|
918
|
+
if (!contextInstance.mounted)
|
|
919
|
+
return;
|
|
920
|
+
handleCallback(getContext(contextInstance), event, onZoomStop);
|
|
921
|
+
}, effectiveAnimationTime);
|
|
922
|
+
}
|
|
794
923
|
}
|
|
795
924
|
function resetTransformations(contextInstance, animationTime, animationType, onResetTransformation) {
|
|
796
|
-
var
|
|
797
|
-
var
|
|
925
|
+
var _a, _b;
|
|
926
|
+
var setup = contextInstance.setup, wrapperComponent = contextInstance.wrapperComponent, contentComponent = contextInstance.contentComponent;
|
|
927
|
+
var limitToBounds = setup.limitToBounds, centerOnInit = setup.centerOnInit;
|
|
798
928
|
var initialTransformation = createState(contextInstance.props);
|
|
799
|
-
var
|
|
929
|
+
var _c = contextInstance.state, scale = _c.scale, positionX = _c.positionX, positionY = _c.positionY;
|
|
800
930
|
if (!wrapperComponent)
|
|
801
931
|
return;
|
|
932
|
+
var targetPositionX = initialTransformation.positionX;
|
|
933
|
+
var targetPositionY = initialTransformation.positionY;
|
|
934
|
+
if (centerOnInit && contentComponent) {
|
|
935
|
+
var centered = getCenterPosition(initialTransformation.scale, wrapperComponent, contentComponent);
|
|
936
|
+
targetPositionX = centered.positionX;
|
|
937
|
+
targetPositionY = centered.positionY;
|
|
938
|
+
}
|
|
802
939
|
var newBounds = calculateBounds(contextInstance, initialTransformation.scale);
|
|
803
|
-
var boundedPositions = getMouseBoundedPosition(
|
|
940
|
+
var boundedPositions = getMouseBoundedPosition(targetPositionX, targetPositionY, newBounds, limitToBounds, 0, 0, wrapperComponent);
|
|
804
941
|
var newState = {
|
|
805
942
|
scale: initialTransformation.scale,
|
|
806
943
|
positionX: boundedPositions.x,
|
|
@@ -812,7 +949,20 @@ function resetTransformations(contextInstance, animationTime, animationType, onR
|
|
|
812
949
|
return;
|
|
813
950
|
}
|
|
814
951
|
onResetTransformation === null || onResetTransformation === void 0 ? void 0 : onResetTransformation();
|
|
952
|
+
var _d = contextInstance.props, onZoomStart = _d.onZoomStart, onZoom = _d.onZoom, onZoomStop = _d.onZoomStop;
|
|
953
|
+
var event = new MouseEvent("mousemove", { bubbles: true });
|
|
954
|
+
var ctx = getContext(contextInstance);
|
|
955
|
+
handleCallback(ctx, event, onZoomStart);
|
|
956
|
+
handleCallback(ctx, event, onZoom);
|
|
815
957
|
animate(contextInstance, newState, animationTime, animationType);
|
|
958
|
+
var win = (_b = (_a = wrapperComponent.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView) !== null && _b !== void 0 ? _b : (typeof window !== "undefined" ? window : null);
|
|
959
|
+
if (win) {
|
|
960
|
+
win.setTimeout(function () {
|
|
961
|
+
if (!contextInstance.mounted)
|
|
962
|
+
return;
|
|
963
|
+
handleCallback(getContext(contextInstance), event, onZoomStop);
|
|
964
|
+
}, animationTime);
|
|
965
|
+
}
|
|
816
966
|
}
|
|
817
967
|
function getOffset(element, wrapper, content, state) {
|
|
818
968
|
var offset = element.getBoundingClientRect();
|
|
@@ -825,25 +975,27 @@ function getOffset(element, wrapper, content, state) {
|
|
|
825
975
|
y: (offset.y - contentOffset.y + yOff) / state.scale,
|
|
826
976
|
};
|
|
827
977
|
}
|
|
828
|
-
function calculateZoomToNode(contextInstance, node, customZoom) {
|
|
829
|
-
|
|
978
|
+
function calculateZoomToNode(contextInstance, node, customZoom, customOffsetX, customOffsetY) {
|
|
979
|
+
if (customOffsetX === void 0) { customOffsetX = 0; }
|
|
980
|
+
if (customOffsetY === void 0) { customOffsetY = 0; }
|
|
981
|
+
var wrapperComponent = contextInstance.wrapperComponent, contentComponent = contextInstance.contentComponent, state = contextInstance.state;
|
|
830
982
|
var _a = contextInstance.setup, limitToBounds = _a.limitToBounds, minScale = _a.minScale, maxScale = _a.maxScale;
|
|
831
983
|
if (!wrapperComponent || !contentComponent)
|
|
832
|
-
return
|
|
984
|
+
return state;
|
|
833
985
|
var wrapperRect = wrapperComponent.getBoundingClientRect();
|
|
834
986
|
var nodeRect = node.getBoundingClientRect();
|
|
835
|
-
var nodeOffset = getOffset(node, wrapperComponent, contentComponent,
|
|
987
|
+
var nodeOffset = getOffset(node, wrapperComponent, contentComponent, state);
|
|
836
988
|
var nodeLeft = nodeOffset.x;
|
|
837
989
|
var nodeTop = nodeOffset.y;
|
|
838
|
-
var nodeWidth = nodeRect.width /
|
|
839
|
-
var nodeHeight = nodeRect.height /
|
|
990
|
+
var nodeWidth = nodeRect.width / state.scale;
|
|
991
|
+
var nodeHeight = nodeRect.height / state.scale;
|
|
840
992
|
var scaleX = wrapperComponent.offsetWidth / nodeWidth;
|
|
841
993
|
var scaleY = wrapperComponent.offsetHeight / nodeHeight;
|
|
842
994
|
var newScale = checkZoomBounds(customZoom || Math.min(scaleX, scaleY), minScale, maxScale, 0, false);
|
|
843
995
|
var offsetX = (wrapperRect.width - nodeWidth * newScale) / 2;
|
|
844
996
|
var offsetY = (wrapperRect.height - nodeHeight * newScale) / 2;
|
|
845
|
-
var newPositionX = (wrapperRect.left - nodeLeft) * newScale + offsetX;
|
|
846
|
-
var newPositionY = (wrapperRect.top - nodeTop) * newScale + offsetY;
|
|
997
|
+
var newPositionX = (wrapperRect.left - nodeLeft) * newScale + offsetX + customOffsetX;
|
|
998
|
+
var newPositionY = (wrapperRect.top - nodeTop) * newScale + offsetY + customOffsetY;
|
|
847
999
|
var bounds = calculateBounds(contextInstance, newScale);
|
|
848
1000
|
var _b = getMouseBoundedPosition(newPositionX, newPositionY, bounds, limitToBounds, 0, 0, wrapperComponent), x = _b.x, y = _b.y;
|
|
849
1001
|
return { positionX: x, positionY: y, scale: newScale };
|
|
@@ -869,7 +1021,7 @@ var setTransform = function (contextInstance) {
|
|
|
869
1021
|
return function (newPositionX, newPositionY, newScale, animationTime, animationType) {
|
|
870
1022
|
if (animationTime === void 0) { animationTime = 300; }
|
|
871
1023
|
if (animationType === void 0) { animationType = "easeOut"; }
|
|
872
|
-
var _a = contextInstance.
|
|
1024
|
+
var _a = contextInstance.state, positionX = _a.positionX, positionY = _a.positionY, scale = _a.scale;
|
|
873
1025
|
var wrapperComponent = contextInstance.wrapperComponent, contentComponent = contextInstance.contentComponent;
|
|
874
1026
|
var disabled = contextInstance.setup.disabled;
|
|
875
1027
|
if (disabled || !wrapperComponent || !contentComponent)
|
|
@@ -893,22 +1045,24 @@ var centerView = function (contextInstance) {
|
|
|
893
1045
|
return function (scale, animationTime, animationType) {
|
|
894
1046
|
if (animationTime === void 0) { animationTime = 200; }
|
|
895
1047
|
if (animationType === void 0) { animationType = "easeOut"; }
|
|
896
|
-
var
|
|
1048
|
+
var state = contextInstance.state, wrapperComponent = contextInstance.wrapperComponent, contentComponent = contextInstance.contentComponent;
|
|
897
1049
|
if (wrapperComponent && contentComponent) {
|
|
898
|
-
var targetState = getCenterPosition(scale ||
|
|
1050
|
+
var targetState = getCenterPosition(scale || state.scale, wrapperComponent, contentComponent);
|
|
899
1051
|
animate(contextInstance, targetState, animationTime, animationType);
|
|
900
1052
|
}
|
|
901
1053
|
};
|
|
902
1054
|
};
|
|
903
1055
|
var zoomToElement = function (contextInstance) {
|
|
904
|
-
return function (node, scale, animationTime, animationType) {
|
|
1056
|
+
return function (node, scale, animationTime, animationType, offsetX, offsetY) {
|
|
905
1057
|
if (animationTime === void 0) { animationTime = 600; }
|
|
906
1058
|
if (animationType === void 0) { animationType = "easeOut"; }
|
|
1059
|
+
if (offsetX === void 0) { offsetX = 0; }
|
|
1060
|
+
if (offsetY === void 0) { offsetY = 0; }
|
|
907
1061
|
handleCancelAnimation(contextInstance);
|
|
908
1062
|
var wrapperComponent = contextInstance.wrapperComponent;
|
|
909
1063
|
var target = typeof node === "string" ? document.getElementById(node) : node;
|
|
910
1064
|
if (wrapperComponent && target && wrapperComponent.contains(target)) {
|
|
911
|
-
var targetState = calculateZoomToNode(contextInstance, target, scale);
|
|
1065
|
+
var targetState = calculateZoomToNode(contextInstance, target, scale, offsetX, offsetY);
|
|
912
1066
|
animate(contextInstance, targetState, animationTime, animationType);
|
|
913
1067
|
}
|
|
914
1068
|
};
|
|
@@ -917,6 +1071,7 @@ var zoomToElement = function (contextInstance) {
|
|
|
917
1071
|
var getControls = function (contextInstance) {
|
|
918
1072
|
return {
|
|
919
1073
|
instance: contextInstance,
|
|
1074
|
+
state: contextInstance.state,
|
|
920
1075
|
zoomIn: zoomIn(contextInstance),
|
|
921
1076
|
zoomOut: zoomOut(contextInstance),
|
|
922
1077
|
setTransform: setTransform(contextInstance),
|
|
@@ -928,7 +1083,7 @@ var getControls = function (contextInstance) {
|
|
|
928
1083
|
var getState = function (contextInstance) {
|
|
929
1084
|
return {
|
|
930
1085
|
instance: contextInstance,
|
|
931
|
-
state: contextInstance.
|
|
1086
|
+
state: contextInstance.state,
|
|
932
1087
|
};
|
|
933
1088
|
};
|
|
934
1089
|
var getContext = function (contextInstance) {
|
|
@@ -972,9 +1127,14 @@ var cancelTimeout = function (timeout) {
|
|
|
972
1127
|
}
|
|
973
1128
|
};
|
|
974
1129
|
|
|
1130
|
+
/** Drop binary float noise on scale (e.g. 1.5000000000000002) without clipping real zoom values. */
|
|
1131
|
+
var roundScaleForTransform = function (scale) {
|
|
1132
|
+
return Number.parseFloat(scale.toFixed(8));
|
|
1133
|
+
};
|
|
975
1134
|
var getTransformStyles = function (x, y, scale) {
|
|
976
1135
|
// Standard translate prevents blurry svg on the safari
|
|
977
|
-
|
|
1136
|
+
var s = roundScaleForTransform(scale);
|
|
1137
|
+
return "translate(".concat(x, "px, ").concat(y, "px) scale(").concat(s, ")");
|
|
978
1138
|
};
|
|
979
1139
|
var getMatrixTransformStyles = function (x, y, scale) {
|
|
980
1140
|
// The shorthand for matrix does not work for Safari hence the need to explicitly use matrix3d
|
|
@@ -999,6 +1159,16 @@ var getCenterPosition = function (scale, wrapperComponent, contentComponent) {
|
|
|
999
1159
|
};
|
|
1000
1160
|
};
|
|
1001
1161
|
|
|
1162
|
+
function assignRef(ref, value) {
|
|
1163
|
+
if (ref == null)
|
|
1164
|
+
return;
|
|
1165
|
+
if (typeof ref === "function") {
|
|
1166
|
+
ref(value);
|
|
1167
|
+
}
|
|
1168
|
+
else {
|
|
1169
|
+
ref.current = value;
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1002
1172
|
function mergeRefs(refs) {
|
|
1003
1173
|
return function (value) {
|
|
1004
1174
|
refs.forEach(function (ref) {
|
|
@@ -1027,6 +1197,31 @@ var isWheelAllowed = function (contextInstance, event) {
|
|
|
1027
1197
|
var isExcluded = isExcludedNode(target, excluded);
|
|
1028
1198
|
if (isExcluded)
|
|
1029
1199
|
return false;
|
|
1200
|
+
var keysPressed = contextInstance.isPressingKeys(contextInstance.setup.wheel.activationKeys);
|
|
1201
|
+
if (!keysPressed)
|
|
1202
|
+
return false;
|
|
1203
|
+
return true;
|
|
1204
|
+
};
|
|
1205
|
+
var isWheelPanningAllowed = function (contextInstance, event) {
|
|
1206
|
+
var _a = contextInstance.setup, disabled = _a.disabled, trackPadPanning = _a.trackPadPanning;
|
|
1207
|
+
var activationKeys = trackPadPanning.activationKeys, excluded = trackPadPanning.excluded;
|
|
1208
|
+
if (!contextInstance.wrapperComponent || !contextInstance.contentComponent) {
|
|
1209
|
+
return false;
|
|
1210
|
+
}
|
|
1211
|
+
if (disabled || trackPadPanning.disabled || event.ctrlKey) {
|
|
1212
|
+
return false;
|
|
1213
|
+
}
|
|
1214
|
+
var isAllowed = isWheelAllowed(contextInstance, event);
|
|
1215
|
+
// Cannot execute at the same time as wheel zoom
|
|
1216
|
+
if (isAllowed)
|
|
1217
|
+
return false;
|
|
1218
|
+
var target = event.target;
|
|
1219
|
+
var isExcluded = isExcludedNode(target, excluded);
|
|
1220
|
+
if (isExcluded)
|
|
1221
|
+
return false;
|
|
1222
|
+
var keysPressed = contextInstance.isPressingKeys(activationKeys);
|
|
1223
|
+
if (!keysPressed)
|
|
1224
|
+
return false;
|
|
1030
1225
|
return true;
|
|
1031
1226
|
};
|
|
1032
1227
|
var getDeltaY = function (event) {
|
|
@@ -1062,7 +1257,7 @@ function getMousePosition(event, contentComponent, scale) {
|
|
|
1062
1257
|
};
|
|
1063
1258
|
}
|
|
1064
1259
|
var handleCalculateWheelZoom = function (contextInstance, delta, step, disable, getTarget) {
|
|
1065
|
-
var scale = contextInstance.
|
|
1260
|
+
var scale = contextInstance.state.scale;
|
|
1066
1261
|
var wrapperComponent = contextInstance.wrapperComponent, setup = contextInstance.setup;
|
|
1067
1262
|
var maxScale = setup.maxScale, minScale = setup.minScale, zoomAnimation = setup.zoomAnimation, disablePadding = setup.disablePadding;
|
|
1068
1263
|
var size = zoomAnimation.size, disabled = zoomAnimation.disabled;
|
|
@@ -1073,12 +1268,12 @@ var handleCalculateWheelZoom = function (contextInstance, delta, step, disable,
|
|
|
1073
1268
|
if (getTarget)
|
|
1074
1269
|
return targetScale;
|
|
1075
1270
|
var paddingEnabled = disable ? false : !disabled;
|
|
1076
|
-
var newScale = checkZoomBounds(
|
|
1271
|
+
var newScale = checkZoomBounds(targetScale, minScale, maxScale, size, paddingEnabled && !disablePadding);
|
|
1077
1272
|
return newScale;
|
|
1078
1273
|
};
|
|
1079
1274
|
var handleWheelZoomStop = function (contextInstance, event) {
|
|
1080
1275
|
var previousWheelEvent = contextInstance.previousWheelEvent;
|
|
1081
|
-
var scale = contextInstance.
|
|
1276
|
+
var scale = contextInstance.state.scale;
|
|
1082
1277
|
var _a = contextInstance.setup, maxScale = _a.maxScale, minScale = _a.minScale;
|
|
1083
1278
|
if (!previousWheelEvent)
|
|
1084
1279
|
return false;
|
|
@@ -1110,7 +1305,7 @@ var isPinchStartAllowed = function (contextInstance, event) {
|
|
|
1110
1305
|
var isPinchAllowed = function (contextInstance) {
|
|
1111
1306
|
var disabled = contextInstance.setup.pinch.disabled;
|
|
1112
1307
|
var isInitialized = contextInstance.isInitialized, pinchStartDistance = contextInstance.pinchStartDistance;
|
|
1113
|
-
var isAllowed = isInitialized && !disabled && pinchStartDistance;
|
|
1308
|
+
var isAllowed = isInitialized && !disabled && pinchStartDistance !== null;
|
|
1114
1309
|
if (!isAllowed)
|
|
1115
1310
|
return false;
|
|
1116
1311
|
return true;
|
|
@@ -1118,10 +1313,10 @@ var isPinchAllowed = function (contextInstance) {
|
|
|
1118
1313
|
var calculateTouchMidPoint = function (event, scale, contentComponent) {
|
|
1119
1314
|
var contentRect = contentComponent.getBoundingClientRect();
|
|
1120
1315
|
var touches = event.touches;
|
|
1121
|
-
var firstPointX =
|
|
1122
|
-
var firstPointY =
|
|
1123
|
-
var secondPointX =
|
|
1124
|
-
var secondPointY =
|
|
1316
|
+
var firstPointX = touches[0].clientX - contentRect.left;
|
|
1317
|
+
var firstPointY = touches[0].clientY - contentRect.top;
|
|
1318
|
+
var secondPointX = touches[1].clientX - contentRect.left;
|
|
1319
|
+
var secondPointY = touches[1].clientY - contentRect.top;
|
|
1125
1320
|
return {
|
|
1126
1321
|
x: (firstPointX + secondPointX) / 2 / scale,
|
|
1127
1322
|
y: (firstPointY + secondPointY) / 2 / scale,
|
|
@@ -1131,19 +1326,24 @@ var getTouchDistance = function (event) {
|
|
|
1131
1326
|
return Math.sqrt(Math.pow((event.touches[0].pageX - event.touches[1].pageX), 2) +
|
|
1132
1327
|
Math.pow((event.touches[0].pageY - event.touches[1].pageY), 2));
|
|
1133
1328
|
};
|
|
1329
|
+
var DEFAULT_PINCH_STEP = 5;
|
|
1134
1330
|
var calculatePinchZoom = function (contextInstance, currentDistance) {
|
|
1135
1331
|
var pinchStartScale = contextInstance.pinchStartScale, pinchStartDistance = contextInstance.pinchStartDistance, setup = contextInstance.setup;
|
|
1136
|
-
var maxScale = setup.maxScale, minScale = setup.minScale, zoomAnimation = setup.zoomAnimation, disablePadding = setup.disablePadding;
|
|
1332
|
+
var maxScale = setup.maxScale, minScale = setup.minScale, zoomAnimation = setup.zoomAnimation, disablePadding = setup.disablePadding, pinch = setup.pinch;
|
|
1137
1333
|
var size = zoomAnimation.size, disabled = zoomAnimation.disabled;
|
|
1138
|
-
|
|
1334
|
+
var step = pinch.step;
|
|
1335
|
+
if (!pinchStartScale || pinchStartDistance === null) {
|
|
1139
1336
|
throw new Error("Pinch touches distance was not provided");
|
|
1140
1337
|
}
|
|
1141
1338
|
if (currentDistance < 0) {
|
|
1142
|
-
return contextInstance.
|
|
1339
|
+
return contextInstance.state.scale;
|
|
1143
1340
|
}
|
|
1144
1341
|
var touchProportion = currentDistance / pinchStartDistance;
|
|
1145
|
-
var
|
|
1146
|
-
|
|
1342
|
+
var rawScale = touchProportion * pinchStartScale;
|
|
1343
|
+
var scaleDelta = (rawScale - pinchStartScale) * (step / DEFAULT_PINCH_STEP);
|
|
1344
|
+
var computed = pinchStartScale + scaleDelta;
|
|
1345
|
+
var scale = computed === Infinity ? 0 : roundNumber(computed, 10);
|
|
1346
|
+
return checkZoomBounds(scale, minScale, maxScale, size, !disabled && !disablePadding);
|
|
1147
1347
|
};
|
|
1148
1348
|
|
|
1149
1349
|
var wheelStopEventTime = 160;
|
|
@@ -1158,18 +1358,18 @@ var handleWheelStart = function (contextInstance, event) {
|
|
|
1158
1358
|
};
|
|
1159
1359
|
var handleWheelZoom = function (contextInstance, event) {
|
|
1160
1360
|
var _a = contextInstance.props, onWheel = _a.onWheel, onZoom = _a.onZoom;
|
|
1161
|
-
var contentComponent = contextInstance.contentComponent, setup = contextInstance.setup,
|
|
1162
|
-
var scale =
|
|
1361
|
+
var contentComponent = contextInstance.contentComponent, setup = contextInstance.setup, state = contextInstance.state;
|
|
1362
|
+
var scale = state.scale;
|
|
1163
1363
|
var limitToBounds = setup.limitToBounds, centerZoomedOut = setup.centerZoomedOut, zoomAnimation = setup.zoomAnimation, wheel = setup.wheel, disablePadding = setup.disablePadding, smooth = setup.smooth;
|
|
1164
1364
|
var size = zoomAnimation.size, disabled = zoomAnimation.disabled;
|
|
1165
|
-
var step = wheel.step
|
|
1365
|
+
var step = wheel.step;
|
|
1166
1366
|
if (!contentComponent) {
|
|
1167
1367
|
throw new Error("Component not mounted");
|
|
1168
1368
|
}
|
|
1169
1369
|
event.preventDefault();
|
|
1170
1370
|
event.stopPropagation();
|
|
1171
1371
|
var delta = getDelta(event, null);
|
|
1172
|
-
var zoomStep = smooth ?
|
|
1372
|
+
var zoomStep = smooth ? step * Math.abs(event.deltaY) : step;
|
|
1173
1373
|
var newScale = handleCalculateWheelZoom(contextInstance, delta, zoomStep, !event.ctrlKey);
|
|
1174
1374
|
// if scale not change
|
|
1175
1375
|
if (scale === newScale)
|
|
@@ -1180,7 +1380,7 @@ var handleWheelZoom = function (contextInstance, event) {
|
|
|
1180
1380
|
var isLimitedToBounds = limitToBounds && isPaddingDisabled;
|
|
1181
1381
|
var _b = handleCalculateZoomPositions(contextInstance, mousePosition.x, mousePosition.y, newScale, bounds, isLimitedToBounds), x = _b.x, y = _b.y;
|
|
1182
1382
|
contextInstance.previousWheelEvent = event;
|
|
1183
|
-
contextInstance.
|
|
1383
|
+
contextInstance.setState(newScale, x, y);
|
|
1184
1384
|
handleCallback(getContext(contextInstance), event, onWheel);
|
|
1185
1385
|
handleCallback(getContext(contextInstance), event, onZoom);
|
|
1186
1386
|
};
|
|
@@ -1207,6 +1407,37 @@ var handleWheelStop = function (contextInstance, event) {
|
|
|
1207
1407
|
}, wheelStopEventTime);
|
|
1208
1408
|
}
|
|
1209
1409
|
};
|
|
1410
|
+
var handleWheelPanningStart = function (contextInstance, event) {
|
|
1411
|
+
var _a = contextInstance.props, onWheelStart = _a.onWheelStart, onPanningStart = _a.onPanningStart;
|
|
1412
|
+
if (!contextInstance.wheelStopEventTimer) {
|
|
1413
|
+
handleCancelAnimation(contextInstance);
|
|
1414
|
+
handleCallback(getContext(contextInstance), event, onWheelStart);
|
|
1415
|
+
handleCallback(getContext(contextInstance), event, onPanningStart);
|
|
1416
|
+
}
|
|
1417
|
+
};
|
|
1418
|
+
var handleWheelPanningStop = function (contextInstance, event) {
|
|
1419
|
+
var _a = contextInstance.props, onWheelStop = _a.onWheelStop, onPanningStop = _a.onPanningStop;
|
|
1420
|
+
// fire animation
|
|
1421
|
+
cancelTimeout(contextInstance.wheelAnimationTimer);
|
|
1422
|
+
contextInstance.wheelAnimationTimer = setTimeout(function () {
|
|
1423
|
+
if (!contextInstance.mounted)
|
|
1424
|
+
return;
|
|
1425
|
+
handleAlignToScaleBounds(contextInstance, event.x, event.y);
|
|
1426
|
+
contextInstance.wheelAnimationTimer = null;
|
|
1427
|
+
}, wheelAnimationTime);
|
|
1428
|
+
// Wheel stop event
|
|
1429
|
+
var hasStoppedZooming = handleWheelZoomStop(contextInstance, event);
|
|
1430
|
+
if (hasStoppedZooming) {
|
|
1431
|
+
cancelTimeout(contextInstance.wheelStopEventTimer);
|
|
1432
|
+
contextInstance.wheelStopEventTimer = setTimeout(function () {
|
|
1433
|
+
if (!contextInstance.mounted)
|
|
1434
|
+
return;
|
|
1435
|
+
contextInstance.wheelStopEventTimer = null;
|
|
1436
|
+
handleCallback(getContext(contextInstance), event, onWheelStop);
|
|
1437
|
+
handleCallback(getContext(contextInstance), event, onPanningStop);
|
|
1438
|
+
}, wheelStopEventTime);
|
|
1439
|
+
}
|
|
1440
|
+
};
|
|
1210
1441
|
|
|
1211
1442
|
var getTouchCenter = function (event) {
|
|
1212
1443
|
var totalX = 0;
|
|
@@ -1225,18 +1456,18 @@ var handlePinchStart = function (contextInstance, event) {
|
|
|
1225
1456
|
var distance = getTouchDistance(event);
|
|
1226
1457
|
contextInstance.pinchStartDistance = distance;
|
|
1227
1458
|
contextInstance.lastDistance = distance;
|
|
1228
|
-
contextInstance.pinchStartScale = contextInstance.
|
|
1459
|
+
contextInstance.pinchStartScale = contextInstance.state.scale;
|
|
1229
1460
|
contextInstance.isPanning = false;
|
|
1230
|
-
|
|
1231
|
-
contextInstance.
|
|
1232
|
-
contextInstance.pinchLastCenterY = center.y;
|
|
1461
|
+
contextInstance.isPinching = true;
|
|
1462
|
+
contextInstance.pinchPreviousCenter = getTouchCenter(event);
|
|
1233
1463
|
handleCancelAnimation(contextInstance);
|
|
1234
1464
|
};
|
|
1235
1465
|
var handlePinchZoom = function (contextInstance, event) {
|
|
1236
|
-
var contentComponent = contextInstance.contentComponent, pinchStartDistance = contextInstance.pinchStartDistance, wrapperComponent = contextInstance.wrapperComponent;
|
|
1237
|
-
var scale = contextInstance.
|
|
1238
|
-
var _a = contextInstance.setup, limitToBounds = _a.limitToBounds, centerZoomedOut = _a.centerZoomedOut, zoomAnimation = _a.zoomAnimation,
|
|
1466
|
+
var contentComponent = contextInstance.contentComponent, pinchStartDistance = contextInstance.pinchStartDistance, wrapperComponent = contextInstance.wrapperComponent, pinchPreviousCenter = contextInstance.pinchPreviousCenter;
|
|
1467
|
+
var scale = contextInstance.state.scale;
|
|
1468
|
+
var _a = contextInstance.setup, limitToBounds = _a.limitToBounds, centerZoomedOut = _a.centerZoomedOut, zoomAnimation = _a.zoomAnimation, autoAlignment = _a.autoAlignment, pinch = _a.pinch, panning = _a.panning;
|
|
1239
1469
|
var disabled = zoomAnimation.disabled, size = zoomAnimation.size;
|
|
1470
|
+
var allowPanning = pinch.allowPanning;
|
|
1240
1471
|
// if one finger starts from outside of wrapper
|
|
1241
1472
|
if (pinchStartDistance === null || !contentComponent)
|
|
1242
1473
|
return;
|
|
@@ -1248,25 +1479,30 @@ var handlePinchZoom = function (contextInstance, event) {
|
|
|
1248
1479
|
var newScale = calculatePinchZoom(contextInstance, currentDistance);
|
|
1249
1480
|
var center = getTouchCenter(event);
|
|
1250
1481
|
// pan should be scale invariant.
|
|
1251
|
-
var
|
|
1252
|
-
var
|
|
1482
|
+
var scaleDiff = scale / newScale;
|
|
1483
|
+
var panX = (center.x - ((pinchPreviousCenter === null || pinchPreviousCenter === void 0 ? void 0 : pinchPreviousCenter.x) || 0)) * scaleDiff;
|
|
1484
|
+
var panY = (center.y - ((pinchPreviousCenter === null || pinchPreviousCenter === void 0 ? void 0 : pinchPreviousCenter.y) || 0)) * scaleDiff;
|
|
1253
1485
|
if (newScale === scale && panX === 0 && panY === 0)
|
|
1254
1486
|
return;
|
|
1255
|
-
contextInstance.
|
|
1256
|
-
contextInstance.pinchLastCenterY = center.y;
|
|
1487
|
+
contextInstance.pinchPreviousCenter = center;
|
|
1257
1488
|
var bounds = handleCalculateBounds(contextInstance, newScale);
|
|
1258
1489
|
var isPaddingDisabled = disabled || size === 0 || centerZoomedOut;
|
|
1259
1490
|
var isLimitedToBounds = limitToBounds && isPaddingDisabled;
|
|
1260
1491
|
var _b = handleCalculateZoomPositions(contextInstance, midPoint.x, midPoint.y, newScale, bounds, isLimitedToBounds), x = _b.x, y = _b.y;
|
|
1261
1492
|
contextInstance.pinchMidpoint = midPoint;
|
|
1262
1493
|
contextInstance.lastDistance = currentDistance;
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1494
|
+
if (panning.disabled || !allowPanning) {
|
|
1495
|
+
contextInstance.setState(newScale, x, y);
|
|
1496
|
+
}
|
|
1497
|
+
else {
|
|
1498
|
+
var sizeX = autoAlignment.sizeX, sizeY = autoAlignment.sizeY;
|
|
1499
|
+
var paddingValueX = getPaddingValue(contextInstance, sizeX, newScale);
|
|
1500
|
+
var paddingValueY = getPaddingValue(contextInstance, sizeY, newScale);
|
|
1501
|
+
var newPositionX = x + panX;
|
|
1502
|
+
var newPositionY = y + panY;
|
|
1503
|
+
var _c = getMouseBoundedPosition(newPositionX, newPositionY, bounds, limitToBounds, paddingValueX, paddingValueY, wrapperComponent), finalX = _c.x, finalY = _c.y;
|
|
1504
|
+
contextInstance.setState(newScale, finalX, finalY);
|
|
1505
|
+
}
|
|
1270
1506
|
};
|
|
1271
1507
|
var handlePinchStop = function (contextInstance) {
|
|
1272
1508
|
var pinchMidpoint = contextInstance.pinchMidpoint;
|
|
@@ -1275,6 +1511,7 @@ var handlePinchStop = function (contextInstance) {
|
|
|
1275
1511
|
contextInstance.pinchMidpoint = null;
|
|
1276
1512
|
contextInstance.pinchStartScale = null;
|
|
1277
1513
|
contextInstance.pinchStartDistance = null;
|
|
1514
|
+
contextInstance.isPinching = false;
|
|
1278
1515
|
handleAlignToScaleBounds(contextInstance, pinchMidpoint === null || pinchMidpoint === void 0 ? void 0 : pinchMidpoint.x, pinchMidpoint === null || pinchMidpoint === void 0 ? void 0 : pinchMidpoint.y);
|
|
1279
1516
|
};
|
|
1280
1517
|
|
|
@@ -1303,8 +1540,8 @@ function getDoubleClickScale(mode, scale) {
|
|
|
1303
1540
|
return mode === "zoomOut" ? -1 : 1;
|
|
1304
1541
|
}
|
|
1305
1542
|
function handleDoubleClick(contextInstance, event) {
|
|
1306
|
-
var setup = contextInstance.setup, doubleClickStopEventTimer = contextInstance.doubleClickStopEventTimer,
|
|
1307
|
-
var scale =
|
|
1543
|
+
var setup = contextInstance.setup, doubleClickStopEventTimer = contextInstance.doubleClickStopEventTimer, state = contextInstance.state, contentComponent = contextInstance.contentComponent;
|
|
1544
|
+
var scale = state.scale;
|
|
1308
1545
|
var _a = contextInstance.props, onZoomStart = _a.onZoomStart, onZoom = _a.onZoom;
|
|
1309
1546
|
var _b = setup.doubleClick, disabled = _b.disabled, mode = _b.mode, step = _b.step, animationTime = _b.animationTime, animationType = _b.animationType;
|
|
1310
1547
|
if (disabled)
|
|
@@ -1316,7 +1553,7 @@ function handleDoubleClick(contextInstance, event) {
|
|
|
1316
1553
|
}
|
|
1317
1554
|
if (!contentComponent)
|
|
1318
1555
|
return console.error("No ContentComponent found");
|
|
1319
|
-
var delta = getDoubleClickScale(mode, contextInstance.
|
|
1556
|
+
var delta = getDoubleClickScale(mode, contextInstance.state.scale);
|
|
1320
1557
|
var newScale = handleCalculateButtonZoom(contextInstance, delta, step);
|
|
1321
1558
|
// stop execution when scale didn't change
|
|
1322
1559
|
if (scale === newScale)
|
|
@@ -1349,10 +1586,9 @@ var ZoomPanPinch = /** @class */ (function () {
|
|
|
1349
1586
|
function ZoomPanPinch(props) {
|
|
1350
1587
|
var _this = this;
|
|
1351
1588
|
this.mounted = true;
|
|
1352
|
-
this.pinchLastCenterX = null;
|
|
1353
|
-
this.pinchLastCenterY = null;
|
|
1354
1589
|
this.onChangeCallbacks = new Set();
|
|
1355
1590
|
this.onInitCallbacks = new Set();
|
|
1591
|
+
this.onTransformCallbacks = new Set();
|
|
1356
1592
|
// Components
|
|
1357
1593
|
this.wrapperComponent = null;
|
|
1358
1594
|
this.contentComponent = null;
|
|
@@ -1367,13 +1603,16 @@ var ZoomPanPinch = /** @class */ (function () {
|
|
|
1367
1603
|
this.isPanning = false;
|
|
1368
1604
|
this.isWheelPanning = false;
|
|
1369
1605
|
this.startCoords = null;
|
|
1606
|
+
this.panStartPosition = null;
|
|
1370
1607
|
this.lastTouch = null;
|
|
1371
1608
|
// pinch helpers
|
|
1609
|
+
this.isPinching = false;
|
|
1372
1610
|
this.distance = null;
|
|
1373
1611
|
this.lastDistance = null;
|
|
1374
1612
|
this.pinchStartDistance = null;
|
|
1375
1613
|
this.pinchStartScale = null;
|
|
1376
1614
|
this.pinchMidpoint = null;
|
|
1615
|
+
this.pinchPreviousCenter = null;
|
|
1377
1616
|
// double click helpers
|
|
1378
1617
|
this.doubleClickStopEventTimer = null;
|
|
1379
1618
|
// velocity helpers
|
|
@@ -1381,9 +1620,8 @@ var ZoomPanPinch = /** @class */ (function () {
|
|
|
1381
1620
|
this.velocityTime = null;
|
|
1382
1621
|
this.lastMousePosition = null;
|
|
1383
1622
|
// animations helpers
|
|
1384
|
-
this.
|
|
1623
|
+
this.isAnimating = false;
|
|
1385
1624
|
this.animation = null;
|
|
1386
|
-
this.maxBounds = null;
|
|
1387
1625
|
// key press
|
|
1388
1626
|
this.pressedKeys = {};
|
|
1389
1627
|
this.mount = function () {
|
|
@@ -1394,15 +1632,19 @@ var ZoomPanPinch = /** @class */ (function () {
|
|
|
1394
1632
|
};
|
|
1395
1633
|
this.update = function (newProps) {
|
|
1396
1634
|
_this.props = newProps;
|
|
1397
|
-
|
|
1635
|
+
if (_this.wrapperComponent && _this.contentComponent) {
|
|
1636
|
+
handleCalculateBounds(_this, _this.state.scale);
|
|
1637
|
+
}
|
|
1398
1638
|
_this.setup = createSetup(newProps);
|
|
1399
1639
|
};
|
|
1400
1640
|
this.initializeWindowEvents = function () {
|
|
1401
|
-
var _a, _b;
|
|
1641
|
+
var _a, _b, _c, _d;
|
|
1402
1642
|
var passive = makePassiveEventOption();
|
|
1403
1643
|
var currentDocument = (_a = _this.wrapperComponent) === null || _a === void 0 ? void 0 : _a.ownerDocument;
|
|
1404
1644
|
var currentWindow = currentDocument === null || currentDocument === void 0 ? void 0 : currentDocument.defaultView;
|
|
1405
1645
|
(_b = _this.wrapperComponent) === null || _b === void 0 ? void 0 : _b.addEventListener("wheel", _this.onWheelPanning, passive);
|
|
1646
|
+
(_c = _this.wrapperComponent) === null || _c === void 0 ? void 0 : _c.addEventListener("keyup", _this.setKeyUnPressed, passive);
|
|
1647
|
+
(_d = _this.wrapperComponent) === null || _d === void 0 ? void 0 : _d.addEventListener("keydown", _this.setKeyPressed, passive);
|
|
1406
1648
|
// Panning on window to allow panning when mouse is out of component wrapper
|
|
1407
1649
|
currentWindow === null || currentWindow === void 0 ? void 0 : currentWindow.addEventListener("mousedown", _this.onPanningStart, passive);
|
|
1408
1650
|
currentWindow === null || currentWindow === void 0 ? void 0 : currentWindow.addEventListener("mousemove", _this.onPanning, passive);
|
|
@@ -1410,9 +1652,10 @@ var ZoomPanPinch = /** @class */ (function () {
|
|
|
1410
1652
|
currentDocument === null || currentDocument === void 0 ? void 0 : currentDocument.addEventListener("mouseleave", _this.clearPanning, passive);
|
|
1411
1653
|
currentWindow === null || currentWindow === void 0 ? void 0 : currentWindow.addEventListener("keyup", _this.setKeyUnPressed, passive);
|
|
1412
1654
|
currentWindow === null || currentWindow === void 0 ? void 0 : currentWindow.addEventListener("keydown", _this.setKeyPressed, passive);
|
|
1655
|
+
currentWindow === null || currentWindow === void 0 ? void 0 : currentWindow.addEventListener("blur", _this.handleWindowBlur);
|
|
1413
1656
|
};
|
|
1414
1657
|
this.cleanupWindowEvents = function () {
|
|
1415
|
-
var _a, _b;
|
|
1658
|
+
var _a, _b, _c, _d, _e;
|
|
1416
1659
|
var passive = makePassiveEventOption();
|
|
1417
1660
|
var currentDocument = (_a = _this.wrapperComponent) === null || _a === void 0 ? void 0 : _a.ownerDocument;
|
|
1418
1661
|
var currentWindow = currentDocument === null || currentDocument === void 0 ? void 0 : currentDocument.defaultView;
|
|
@@ -1422,9 +1665,13 @@ var ZoomPanPinch = /** @class */ (function () {
|
|
|
1422
1665
|
currentDocument === null || currentDocument === void 0 ? void 0 : currentDocument.removeEventListener("mouseleave", _this.clearPanning, passive);
|
|
1423
1666
|
currentWindow === null || currentWindow === void 0 ? void 0 : currentWindow.removeEventListener("keyup", _this.setKeyUnPressed, passive);
|
|
1424
1667
|
currentWindow === null || currentWindow === void 0 ? void 0 : currentWindow.removeEventListener("keydown", _this.setKeyPressed, passive);
|
|
1668
|
+
currentWindow === null || currentWindow === void 0 ? void 0 : currentWindow.removeEventListener("blur", _this.handleWindowBlur);
|
|
1425
1669
|
document.removeEventListener("mouseleave", _this.clearPanning, passive);
|
|
1670
|
+
(_b = _this.wrapperComponent) === null || _b === void 0 ? void 0 : _b.removeEventListener("wheel", _this.onWheelPanning, passive);
|
|
1671
|
+
(_c = _this.wrapperComponent) === null || _c === void 0 ? void 0 : _c.removeEventListener("keyup", _this.setKeyUnPressed, passive);
|
|
1672
|
+
(_d = _this.wrapperComponent) === null || _d === void 0 ? void 0 : _d.removeEventListener("keydown", _this.setKeyPressed, passive);
|
|
1426
1673
|
handleCancelAnimation(_this);
|
|
1427
|
-
(
|
|
1674
|
+
(_e = _this.observer) === null || _e === void 0 ? void 0 : _e.disconnect();
|
|
1428
1675
|
};
|
|
1429
1676
|
this.handleInitializeWrapperEvents = function (wrapper) {
|
|
1430
1677
|
// Zooming events on wrapper
|
|
@@ -1453,6 +1700,7 @@ var ZoomPanPinch = /** @class */ (function () {
|
|
|
1453
1700
|
(_a = _this.observer) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
1454
1701
|
}
|
|
1455
1702
|
});
|
|
1703
|
+
// TODO: CHANGE to first interaction?
|
|
1456
1704
|
// if nothing about the contentComponent has changed after 5 seconds, disconnect the observer
|
|
1457
1705
|
setTimeout(function () {
|
|
1458
1706
|
var _a;
|
|
@@ -1469,49 +1717,51 @@ var ZoomPanPinch = /** @class */ (function () {
|
|
|
1469
1717
|
var disabled = _this.setup.disabled;
|
|
1470
1718
|
if (disabled)
|
|
1471
1719
|
return;
|
|
1720
|
+
_this.syncModifierKeys(event);
|
|
1472
1721
|
var isAllowed = isWheelAllowed(_this, event);
|
|
1473
1722
|
if (!isAllowed)
|
|
1474
1723
|
return;
|
|
1475
|
-
var keysPressed = _this.isPressingKeys(_this.setup.wheel.activationKeys);
|
|
1476
|
-
if (!keysPressed)
|
|
1477
|
-
return;
|
|
1478
1724
|
handleWheelStart(_this, event);
|
|
1479
1725
|
handleWheelZoom(_this, event);
|
|
1480
1726
|
handleWheelStop(_this, event);
|
|
1481
1727
|
};
|
|
1482
1728
|
/// ///////
|
|
1483
|
-
//
|
|
1729
|
+
// Track Pad Panning
|
|
1484
1730
|
/// ///////
|
|
1485
1731
|
this.onWheelPanning = function (event) {
|
|
1486
|
-
var
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
!panning.wheelPanning ||
|
|
1493
|
-
event.ctrlKey) {
|
|
1732
|
+
var onPanning = _this.props.onPanning;
|
|
1733
|
+
var trackPadPanning = _this.setup.trackPadPanning;
|
|
1734
|
+
var lockAxisX = trackPadPanning.lockAxisX, lockAxisY = trackPadPanning.lockAxisY;
|
|
1735
|
+
_this.syncModifierKeys(event);
|
|
1736
|
+
var isAllowed = isWheelPanningAllowed(_this, event);
|
|
1737
|
+
if (!isAllowed)
|
|
1494
1738
|
return;
|
|
1495
|
-
}
|
|
1496
1739
|
event.preventDefault();
|
|
1497
1740
|
event.stopPropagation();
|
|
1498
|
-
var
|
|
1741
|
+
var _a = _this.state, positionX = _a.positionX, positionY = _a.positionY;
|
|
1499
1742
|
var mouseX = positionX - event.deltaX;
|
|
1500
1743
|
var mouseY = positionY - event.deltaY;
|
|
1501
|
-
var newPositionX =
|
|
1502
|
-
var newPositionY =
|
|
1503
|
-
var
|
|
1744
|
+
var newPositionX = lockAxisX ? positionX : mouseX;
|
|
1745
|
+
var newPositionY = lockAxisY ? positionY : mouseY;
|
|
1746
|
+
var _b = _this.setup.autoAlignment, sizeX = _b.sizeX, sizeY = _b.sizeY;
|
|
1504
1747
|
var paddingValueX = getPaddingValue(_this, sizeX);
|
|
1505
1748
|
var paddingValueY = getPaddingValue(_this, sizeY);
|
|
1506
1749
|
if (newPositionX === positionX && newPositionY === positionY)
|
|
1507
1750
|
return;
|
|
1751
|
+
handleWheelPanningStart(_this, event);
|
|
1508
1752
|
handleNewPosition(_this, newPositionX, newPositionY, paddingValueX, paddingValueY);
|
|
1753
|
+
handleCallback(getContext(_this), event, onPanning);
|
|
1754
|
+
handleWheelPanningStop(_this, event);
|
|
1509
1755
|
};
|
|
1756
|
+
/// ///////
|
|
1757
|
+
// Pan
|
|
1758
|
+
/// ///////
|
|
1510
1759
|
this.onPanningStart = function (event) {
|
|
1511
1760
|
var disabled = _this.setup.disabled;
|
|
1512
1761
|
var onPanningStart = _this.props.onPanningStart;
|
|
1513
1762
|
if (disabled)
|
|
1514
1763
|
return;
|
|
1764
|
+
_this.syncModifierKeys(event);
|
|
1515
1765
|
var isAllowed = isPanningStartAllowed(_this, event);
|
|
1516
1766
|
if (!isAllowed)
|
|
1517
1767
|
return;
|
|
@@ -1535,6 +1785,13 @@ var ZoomPanPinch = /** @class */ (function () {
|
|
|
1535
1785
|
var onPanning = _this.props.onPanning;
|
|
1536
1786
|
if (disabled)
|
|
1537
1787
|
return;
|
|
1788
|
+
_this.syncModifierKeys(event);
|
|
1789
|
+
// Detect missed mouseup — e.g. when the mouse was released outside an
|
|
1790
|
+
// iframe boundary where the host frame swallows the mouseup event.
|
|
1791
|
+
if (_this.isPanning && event.buttons === 0) {
|
|
1792
|
+
_this.clearPanning(event);
|
|
1793
|
+
return;
|
|
1794
|
+
}
|
|
1538
1795
|
var isAllowed = isPanningAllowed(_this);
|
|
1539
1796
|
if (!isAllowed)
|
|
1540
1797
|
return;
|
|
@@ -1543,13 +1800,14 @@ var ZoomPanPinch = /** @class */ (function () {
|
|
|
1543
1800
|
return;
|
|
1544
1801
|
event.preventDefault();
|
|
1545
1802
|
event.stopPropagation();
|
|
1546
|
-
handlePanning(_this, event.clientX, event.clientY);
|
|
1803
|
+
handlePanning(_this, event.clientX, event.clientY, exports.DeviceType.MOUSE);
|
|
1547
1804
|
handleCallback(getContext(_this), event, onPanning);
|
|
1548
1805
|
};
|
|
1549
1806
|
this.onPanningStop = function (event) {
|
|
1807
|
+
var velocityDisabled = _this.setup.panning.velocityDisabled;
|
|
1550
1808
|
var onPanningStop = _this.props.onPanningStop;
|
|
1551
1809
|
if (_this.isPanning) {
|
|
1552
|
-
handlePanningEnd(_this);
|
|
1810
|
+
handlePanningEnd(_this, velocityDisabled);
|
|
1553
1811
|
handleCallback(getContext(_this), event, onPanningStop);
|
|
1554
1812
|
}
|
|
1555
1813
|
};
|
|
@@ -1558,7 +1816,7 @@ var ZoomPanPinch = /** @class */ (function () {
|
|
|
1558
1816
|
/// ///////
|
|
1559
1817
|
this.onPinchStart = function (event) {
|
|
1560
1818
|
var disabled = _this.setup.disabled;
|
|
1561
|
-
var
|
|
1819
|
+
var onPinchStart = _this.props.onPinchStart;
|
|
1562
1820
|
if (disabled)
|
|
1563
1821
|
return;
|
|
1564
1822
|
var isAllowed = isPinchStartAllowed(_this, event);
|
|
@@ -1566,12 +1824,11 @@ var ZoomPanPinch = /** @class */ (function () {
|
|
|
1566
1824
|
return;
|
|
1567
1825
|
handlePinchStart(_this, event);
|
|
1568
1826
|
handleCancelAnimation(_this);
|
|
1569
|
-
handleCallback(getContext(_this), event,
|
|
1570
|
-
handleCallback(getContext(_this), event, onZoomStart);
|
|
1827
|
+
handleCallback(getContext(_this), event, onPinchStart);
|
|
1571
1828
|
};
|
|
1572
1829
|
this.onPinch = function (event) {
|
|
1573
1830
|
var disabled = _this.setup.disabled;
|
|
1574
|
-
var
|
|
1831
|
+
var onPinch = _this.props.onPinch;
|
|
1575
1832
|
if (disabled)
|
|
1576
1833
|
return;
|
|
1577
1834
|
var isAllowed = isPinchAllowed(_this);
|
|
@@ -1580,36 +1837,38 @@ var ZoomPanPinch = /** @class */ (function () {
|
|
|
1580
1837
|
event.preventDefault();
|
|
1581
1838
|
event.stopPropagation();
|
|
1582
1839
|
handlePinchZoom(_this, event);
|
|
1583
|
-
handleCallback(getContext(_this), event,
|
|
1584
|
-
handleCallback(getContext(_this), event, onZoom);
|
|
1840
|
+
handleCallback(getContext(_this), event, onPinch);
|
|
1585
1841
|
};
|
|
1586
1842
|
this.onPinchStop = function (event) {
|
|
1587
|
-
var
|
|
1843
|
+
var onPinchStop = _this.props.onPinchStop;
|
|
1588
1844
|
if (_this.pinchStartScale) {
|
|
1589
1845
|
handlePinchStop(_this);
|
|
1590
|
-
handleCallback(getContext(_this), event,
|
|
1591
|
-
handleCallback(getContext(_this), event, onZoomStop);
|
|
1846
|
+
handleCallback(getContext(_this), event, onPinchStop);
|
|
1592
1847
|
}
|
|
1593
1848
|
};
|
|
1594
1849
|
/// ///////
|
|
1595
1850
|
// Touch
|
|
1596
1851
|
/// ///////
|
|
1597
1852
|
this.onTouchPanningStart = function (event) {
|
|
1598
|
-
var
|
|
1853
|
+
var _a = _this.setup, disabled = _a.disabled, doubleClick = _a.doubleClick;
|
|
1599
1854
|
var onPanningStart = _this.props.onPanningStart;
|
|
1600
1855
|
if (disabled)
|
|
1601
1856
|
return;
|
|
1602
|
-
var
|
|
1603
|
-
if (!isAllowed)
|
|
1604
|
-
return;
|
|
1857
|
+
var isDoubleTapAllowed = !(doubleClick === null || doubleClick === void 0 ? void 0 : doubleClick.disabled);
|
|
1605
1858
|
var isDoubleTap = _this.lastTouch && +new Date() - _this.lastTouch < 200;
|
|
1606
|
-
if (
|
|
1859
|
+
if (isDoubleTapAllowed && isDoubleTap && event.touches.length === 1) {
|
|
1860
|
+
_this.onDoubleClick(event);
|
|
1861
|
+
}
|
|
1862
|
+
else {
|
|
1607
1863
|
_this.lastTouch = +new Date();
|
|
1608
1864
|
handleCancelAnimation(_this);
|
|
1609
1865
|
var touches = event.touches;
|
|
1610
1866
|
var isPanningAction = touches.length === 1;
|
|
1611
1867
|
var isPinchAction = touches.length === 2;
|
|
1868
|
+
var isAllowed = isPanningStartAllowed(_this, event);
|
|
1612
1869
|
if (isPanningAction) {
|
|
1870
|
+
if (!isAllowed)
|
|
1871
|
+
return;
|
|
1613
1872
|
handleCancelAnimation(_this);
|
|
1614
1873
|
handlePanningStart(_this, event);
|
|
1615
1874
|
handleCallback(getContext(_this), event, onPanningStart);
|
|
@@ -1628,10 +1887,12 @@ var ZoomPanPinch = /** @class */ (function () {
|
|
|
1628
1887
|
var isAllowed = isPanningAllowed(_this);
|
|
1629
1888
|
if (!isAllowed)
|
|
1630
1889
|
return;
|
|
1631
|
-
event.
|
|
1890
|
+
if (event.cancelable) {
|
|
1891
|
+
event.preventDefault();
|
|
1892
|
+
}
|
|
1632
1893
|
event.stopPropagation();
|
|
1633
1894
|
var touch = event.touches[0];
|
|
1634
|
-
handlePanning(_this, touch.clientX, touch.clientY);
|
|
1895
|
+
handlePanning(_this, touch.clientX, touch.clientY, exports.DeviceType.TOUCH);
|
|
1635
1896
|
handleCallback(getContext(_this), event, onPanning);
|
|
1636
1897
|
}
|
|
1637
1898
|
else if (event.touches.length > 1) {
|
|
@@ -1662,6 +1923,44 @@ var ZoomPanPinch = /** @class */ (function () {
|
|
|
1662
1923
|
_this.onPanningStop(event);
|
|
1663
1924
|
}
|
|
1664
1925
|
};
|
|
1926
|
+
// When the window loses focus (e.g. user clicks outside an iframe),
|
|
1927
|
+
// keyup and mouseup events are swallowed by the parent frame. Clear all
|
|
1928
|
+
// tracked state to prevent stale activation keys or ghost panning.
|
|
1929
|
+
this.handleWindowBlur = function () {
|
|
1930
|
+
_this.pressedKeys = {};
|
|
1931
|
+
if (_this.isPanning) {
|
|
1932
|
+
_this.isPanning = false;
|
|
1933
|
+
_this.startCoords = null;
|
|
1934
|
+
}
|
|
1935
|
+
};
|
|
1936
|
+
// Iframe focus problem (e.g. Storybook):
|
|
1937
|
+
//
|
|
1938
|
+
// When the library runs inside an iframe, keyboard events (keydown/keyup)
|
|
1939
|
+
// only reach the iframe's window when it has focus. If the user navigates
|
|
1940
|
+
// via the host UI (e.g. Storybook sidebar) the iframe never receives
|
|
1941
|
+
// focus, so keydown never fires and activationKeys like Cmd/Ctrl are
|
|
1942
|
+
// invisible to pressedKeys.
|
|
1943
|
+
//
|
|
1944
|
+
// Mouse and wheel events, however, DO reach the iframe regardless of
|
|
1945
|
+
// focus — and they carry modifier flags (ctrlKey, metaKey, shiftKey,
|
|
1946
|
+
// altKey) that always reflect the real physical key state at event time.
|
|
1947
|
+
//
|
|
1948
|
+
// We sync those flags into pressedKeys on every interaction event so
|
|
1949
|
+
// that activationKeys checks work without requiring iframe focus.
|
|
1950
|
+
// Both pressed (true) AND released (false) states must be written;
|
|
1951
|
+
// writing only `true` would leave stale keys after release because
|
|
1952
|
+
// keyup never fires in an unfocused iframe.
|
|
1953
|
+
this.syncModifierKeys = function (event) {
|
|
1954
|
+
var ctrlKey = event.ctrlKey, metaKey = event.metaKey, shiftKey = event.shiftKey, altKey = event.altKey;
|
|
1955
|
+
if (typeof ctrlKey === "boolean")
|
|
1956
|
+
_this.pressedKeys.Control = ctrlKey;
|
|
1957
|
+
if (typeof metaKey === "boolean")
|
|
1958
|
+
_this.pressedKeys.Meta = metaKey;
|
|
1959
|
+
if (typeof shiftKey === "boolean")
|
|
1960
|
+
_this.pressedKeys.Shift = shiftKey;
|
|
1961
|
+
if (typeof altKey === "boolean")
|
|
1962
|
+
_this.pressedKeys.Alt = altKey;
|
|
1963
|
+
};
|
|
1665
1964
|
this.setKeyPressed = function (e) {
|
|
1666
1965
|
_this.pressedKeys[e.key] = true;
|
|
1667
1966
|
};
|
|
@@ -1669,35 +1968,26 @@ var ZoomPanPinch = /** @class */ (function () {
|
|
|
1669
1968
|
_this.pressedKeys[e.key] = false;
|
|
1670
1969
|
};
|
|
1671
1970
|
this.isPressingKeys = function (keys) {
|
|
1971
|
+
if (typeof keys === "function") {
|
|
1972
|
+
return keys(Object.entries(_this.pressedKeys)
|
|
1973
|
+
.filter(function (_a) {
|
|
1974
|
+
var pressed = _a[1];
|
|
1975
|
+
return pressed;
|
|
1976
|
+
})
|
|
1977
|
+
.map(function (_a) {
|
|
1978
|
+
var key = _a[0];
|
|
1979
|
+
return key;
|
|
1980
|
+
}));
|
|
1981
|
+
}
|
|
1672
1982
|
if (!keys.length) {
|
|
1673
1983
|
return true;
|
|
1674
1984
|
}
|
|
1675
|
-
return Boolean(keys.
|
|
1676
|
-
};
|
|
1677
|
-
this.setTransformState = function (scale, positionX, positionY) {
|
|
1678
|
-
var onTransformed = _this.props.onTransformed;
|
|
1679
|
-
if (!Number.isNaN(scale) &&
|
|
1680
|
-
!Number.isNaN(positionX) &&
|
|
1681
|
-
!Number.isNaN(positionY)) {
|
|
1682
|
-
if (scale !== _this.transformState.scale) {
|
|
1683
|
-
_this.transformState.previousScale = _this.transformState.scale;
|
|
1684
|
-
_this.transformState.scale = scale;
|
|
1685
|
-
}
|
|
1686
|
-
_this.transformState.positionX = positionX;
|
|
1687
|
-
_this.transformState.positionY = positionY;
|
|
1688
|
-
_this.applyTransformation();
|
|
1689
|
-
var ctx_1 = getContext(_this);
|
|
1690
|
-
_this.onChangeCallbacks.forEach(function (callback) { return callback(ctx_1); });
|
|
1691
|
-
handleCallback(ctx_1, { scale: scale, positionX: positionX, positionY: positionY }, onTransformed);
|
|
1692
|
-
}
|
|
1693
|
-
else {
|
|
1694
|
-
console.error("Detected NaN set state values");
|
|
1695
|
-
}
|
|
1985
|
+
return Boolean(keys.every(function (key) { return _this.pressedKeys[key]; }));
|
|
1696
1986
|
};
|
|
1697
1987
|
this.setCenter = function () {
|
|
1698
1988
|
if (_this.wrapperComponent && _this.contentComponent) {
|
|
1699
|
-
var targetState = getCenterPosition(_this.
|
|
1700
|
-
_this.
|
|
1989
|
+
var targetState = getCenterPosition(_this.state.scale, _this.wrapperComponent, _this.contentComponent);
|
|
1990
|
+
_this.setState(targetState.scale, targetState.positionX, targetState.positionY);
|
|
1701
1991
|
}
|
|
1702
1992
|
};
|
|
1703
1993
|
this.handleTransformStyles = function (x, y, scale) {
|
|
@@ -1706,19 +1996,60 @@ var ZoomPanPinch = /** @class */ (function () {
|
|
|
1706
1996
|
}
|
|
1707
1997
|
return getTransformStyles(x, y, scale);
|
|
1708
1998
|
};
|
|
1999
|
+
this.getContext = function () {
|
|
2000
|
+
return getContext(_this);
|
|
2001
|
+
};
|
|
1709
2002
|
this.applyTransformation = function () {
|
|
1710
2003
|
if (!_this.mounted || !_this.contentComponent)
|
|
1711
2004
|
return;
|
|
1712
|
-
var _a = _this.
|
|
2005
|
+
var _a = _this.state, scale = _a.scale, positionX = _a.positionX, positionY = _a.positionY;
|
|
1713
2006
|
var transform = _this.handleTransformStyles(positionX, positionY, scale);
|
|
1714
|
-
|
|
2007
|
+
// Detached mode do not apply transformation directly to content component
|
|
2008
|
+
if (!_this.props.detached) {
|
|
2009
|
+
_this.contentComponent.style.transform = transform;
|
|
2010
|
+
}
|
|
2011
|
+
_this.onTransformCallbacks.forEach(function (callback) {
|
|
2012
|
+
return callback({
|
|
2013
|
+
scale: scale,
|
|
2014
|
+
positionX: positionX,
|
|
2015
|
+
positionY: positionY,
|
|
2016
|
+
previousScale: _this.state.previousScale,
|
|
2017
|
+
ref: getContext(_this),
|
|
2018
|
+
});
|
|
2019
|
+
});
|
|
1715
2020
|
};
|
|
1716
|
-
this.
|
|
1717
|
-
|
|
2021
|
+
this.setState = function (scale, positionX, positionY) {
|
|
2022
|
+
var onTransform = _this.props.onTransform;
|
|
2023
|
+
if (!Number.isNaN(scale) &&
|
|
2024
|
+
!Number.isNaN(positionX) &&
|
|
2025
|
+
!Number.isNaN(positionY)) {
|
|
2026
|
+
var safeScale = Math.max(scale, 1e-7);
|
|
2027
|
+
if (safeScale !== _this.state.scale) {
|
|
2028
|
+
_this.state.previousScale = _this.state.scale;
|
|
2029
|
+
_this.state.scale = safeScale;
|
|
2030
|
+
}
|
|
2031
|
+
_this.state.positionX = positionX;
|
|
2032
|
+
_this.state.positionY = positionY;
|
|
2033
|
+
_this.applyTransformation();
|
|
2034
|
+
var ctx_1 = getContext(_this);
|
|
2035
|
+
_this.onChangeCallbacks.forEach(function (callback) { return callback(ctx_1); });
|
|
2036
|
+
handleCallback(ctx_1, { scale: _this.state.scale, positionX: positionX, positionY: positionY }, onTransform);
|
|
2037
|
+
}
|
|
2038
|
+
else {
|
|
2039
|
+
console.error("Detected NaN set state values");
|
|
2040
|
+
}
|
|
1718
2041
|
};
|
|
1719
2042
|
/**
|
|
1720
2043
|
* Hooks
|
|
1721
2044
|
*/
|
|
2045
|
+
this.onTransform = function (callback) {
|
|
2046
|
+
if (!_this.onTransformCallbacks.has(callback)) {
|
|
2047
|
+
_this.onTransformCallbacks.add(callback);
|
|
2048
|
+
}
|
|
2049
|
+
return function () {
|
|
2050
|
+
_this.onTransformCallbacks.delete(callback);
|
|
2051
|
+
};
|
|
2052
|
+
};
|
|
1722
2053
|
this.onChange = function (callback) {
|
|
1723
2054
|
if (!_this.onChangeCallbacks.has(callback)) {
|
|
1724
2055
|
_this.onChangeCallbacks.add(callback);
|
|
@@ -1742,39 +2073,40 @@ var ZoomPanPinch = /** @class */ (function () {
|
|
|
1742
2073
|
_this.cleanupWindowEvents();
|
|
1743
2074
|
_this.wrapperComponent = wrapperComponent;
|
|
1744
2075
|
_this.contentComponent = contentComponent;
|
|
1745
|
-
handleCalculateBounds(_this, _this.
|
|
2076
|
+
handleCalculateBounds(_this, _this.state.scale);
|
|
1746
2077
|
_this.handleInitializeWrapperEvents(wrapperComponent);
|
|
1747
2078
|
_this.handleInitialize(contentComponent);
|
|
1748
2079
|
_this.initializeWindowEvents();
|
|
1749
2080
|
_this.isInitialized = true;
|
|
1750
2081
|
var ctx = getContext(_this);
|
|
1751
2082
|
handleCallback(ctx, undefined, _this.props.onInit);
|
|
2083
|
+
assignRef(_this.props.ref, ctx);
|
|
1752
2084
|
};
|
|
1753
2085
|
this.props = props;
|
|
1754
2086
|
this.setup = createSetup(this.props);
|
|
1755
|
-
this.
|
|
2087
|
+
this.state = createState(this.props);
|
|
1756
2088
|
}
|
|
1757
2089
|
return ZoomPanPinch;
|
|
1758
2090
|
}());
|
|
1759
2091
|
|
|
1760
|
-
var Context =
|
|
2092
|
+
var Context = React.createContext(null);
|
|
1761
2093
|
var getContent = function (children, ctx) {
|
|
1762
2094
|
if (typeof children === "function") {
|
|
1763
2095
|
return children(ctx);
|
|
1764
2096
|
}
|
|
1765
2097
|
return children;
|
|
1766
2098
|
};
|
|
1767
|
-
var TransformWrapper =
|
|
2099
|
+
var TransformWrapper = React.forwardRef(function (props, ref) {
|
|
1768
2100
|
var instance = React.useRef(new ZoomPanPinch(props)).current;
|
|
1769
2101
|
var content = getContent(props.children, getControls(instance));
|
|
1770
2102
|
React.useImperativeHandle(ref, function () { return getControls(instance); }, [instance]);
|
|
1771
2103
|
React.useEffect(function () {
|
|
1772
2104
|
instance.update(props);
|
|
1773
2105
|
}, [instance, props]);
|
|
1774
|
-
return
|
|
2106
|
+
return jsxRuntime.jsx(Context.Provider, __assign({ value: instance }, { children: content }));
|
|
1775
2107
|
});
|
|
1776
2108
|
|
|
1777
|
-
var KeepScale =
|
|
2109
|
+
var KeepScale = React.forwardRef(function (props, ref) {
|
|
1778
2110
|
var localRef = React.useRef(null);
|
|
1779
2111
|
var instance = React.useContext(Context);
|
|
1780
2112
|
React.useEffect(function () {
|
|
@@ -1782,11 +2114,11 @@ var KeepScale = React__default["default"].forwardRef(function (props, ref) {
|
|
|
1782
2114
|
if (localRef.current) {
|
|
1783
2115
|
var positionX = 0;
|
|
1784
2116
|
var positionY = 0;
|
|
1785
|
-
localRef.current.style.transform = instance.handleTransformStyles(positionX, positionY, 1 / ctx.instance.
|
|
2117
|
+
localRef.current.style.transform = instance.handleTransformStyles(positionX, positionY, 1 / ctx.instance.state.scale);
|
|
1786
2118
|
}
|
|
1787
2119
|
});
|
|
1788
2120
|
}, [instance]);
|
|
1789
|
-
return
|
|
2121
|
+
return jsxRuntime.jsx("div", __assign({}, props, { ref: mergeRefs([localRef, ref]) }));
|
|
1790
2122
|
});
|
|
1791
2123
|
|
|
1792
2124
|
var initialElementRect = {
|
|
@@ -1843,11 +2175,13 @@ var previewStyles = {
|
|
|
1843
2175
|
border: "3px solid red",
|
|
1844
2176
|
transformOrigin: "0% 0%",
|
|
1845
2177
|
boxShadow: "rgba(0,0,0,0.2) 0 0 0 10000000px",
|
|
2178
|
+
pointerEvents: "none",
|
|
1846
2179
|
};
|
|
1847
2180
|
var MiniMap = function (_a) {
|
|
1848
|
-
var _b = _a.width, width = _b === void 0 ? 200 : _b, _c = _a.height, height = _c === void 0 ? 200 : _c, _d = _a.borderColor, borderColor = _d === void 0 ? "red" : _d, children = _a.children, rest = __rest(_a, ["width", "height", "borderColor", "children"]);
|
|
1849
|
-
var
|
|
2181
|
+
var _b = _a.width, width = _b === void 0 ? 200 : _b, _c = _a.height, height = _c === void 0 ? 200 : _c, _d = _a.borderColor, borderColor = _d === void 0 ? "red" : _d, previewStyle = _a.previewStyle, wrapperClassName = _a.wrapperClassName, previewClassName = _a.previewClassName, children = _a.children, _e = _a.panning, panning = _e === void 0 ? true : _e, rest = __rest(_a, ["width", "height", "borderColor", "previewStyle", "wrapperClassName", "previewClassName", "children", "panning"]);
|
|
2182
|
+
var _f = React.useState(false), initialized = _f[0], setInitialized = _f[1];
|
|
1850
2183
|
var instance = useTransformContext();
|
|
2184
|
+
var _g = React.useState(false), isDown = _g[0], setIsDown = _g[1];
|
|
1851
2185
|
var miniMapInstance = React.useRef(null);
|
|
1852
2186
|
var mainRef = React.useRef(null);
|
|
1853
2187
|
var wrapperRef = React.useRef(null);
|
|
@@ -1857,27 +2191,27 @@ var MiniMap = function (_a) {
|
|
|
1857
2191
|
var rect = instance.wrapperComponent.getBoundingClientRect();
|
|
1858
2192
|
return {
|
|
1859
2193
|
width: rect.width,
|
|
1860
|
-
height: rect.height
|
|
2194
|
+
height: rect.height,
|
|
1861
2195
|
};
|
|
1862
2196
|
}
|
|
1863
2197
|
return {
|
|
1864
2198
|
width: 0,
|
|
1865
|
-
height: 0
|
|
2199
|
+
height: 0,
|
|
1866
2200
|
};
|
|
1867
2201
|
}, [instance.wrapperComponent]);
|
|
1868
2202
|
var getContentSize = React.useCallback(function () {
|
|
1869
2203
|
if (instance.contentComponent) {
|
|
1870
2204
|
var rect = instance.contentComponent.getBoundingClientRect();
|
|
1871
2205
|
return {
|
|
1872
|
-
width: rect.width / instance.
|
|
1873
|
-
height: rect.height / instance.
|
|
2206
|
+
width: rect.width / instance.state.scale,
|
|
2207
|
+
height: rect.height / instance.state.scale,
|
|
1874
2208
|
};
|
|
1875
2209
|
}
|
|
1876
2210
|
return {
|
|
1877
2211
|
width: 0,
|
|
1878
2212
|
height: 0,
|
|
1879
2213
|
};
|
|
1880
|
-
}, [instance.contentComponent, instance.
|
|
2214
|
+
}, [instance.contentComponent, instance.state.scale]);
|
|
1881
2215
|
var computeMiniMapScale = React.useCallback(function () {
|
|
1882
2216
|
var contentSize = getContentSize();
|
|
1883
2217
|
var scaleX = width / contentSize.width;
|
|
@@ -1902,13 +2236,16 @@ var MiniMap = function (_a) {
|
|
|
1902
2236
|
position: "absolute",
|
|
1903
2237
|
boxSizing: "border-box",
|
|
1904
2238
|
zIndex: 1,
|
|
1905
|
-
overflow: "hidden",
|
|
2239
|
+
// overflow: "hidden",
|
|
1906
2240
|
};
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
2241
|
+
if (wrapperRef.current) {
|
|
2242
|
+
var el = wrapperRef.current.style;
|
|
2243
|
+
el.transform = style.transform;
|
|
2244
|
+
el.transformOrigin = style.transformOrigin;
|
|
2245
|
+
el.position = style.position;
|
|
2246
|
+
el.boxSizing = style.boxSizing;
|
|
2247
|
+
el.zIndex = String(style.zIndex);
|
|
2248
|
+
}
|
|
1912
2249
|
};
|
|
1913
2250
|
var transformMiniMap = function () {
|
|
1914
2251
|
computeMiniMapStyle();
|
|
@@ -1925,8 +2262,8 @@ var MiniMap = function (_a) {
|
|
|
1925
2262
|
if (previewRef.current) {
|
|
1926
2263
|
var size = getViewportSize();
|
|
1927
2264
|
var scale = computeMiniMapScale();
|
|
1928
|
-
var previewScale = scale * (1 / instance.
|
|
1929
|
-
var transform = instance.handleTransformStyles(-instance.
|
|
2265
|
+
var previewScale = scale * (1 / instance.state.scale);
|
|
2266
|
+
var transform = instance.handleTransformStyles(-instance.state.positionX * previewScale, -instance.state.positionY * previewScale, 1);
|
|
1930
2267
|
previewRef.current.style.transform = transform;
|
|
1931
2268
|
previewRef.current.style.width = "".concat(size.width * previewScale, "px");
|
|
1932
2269
|
previewRef.current.style.height = "".concat(size.height * previewScale, "px");
|
|
@@ -1947,25 +2284,66 @@ var MiniMap = function (_a) {
|
|
|
1947
2284
|
return instance.onChange(function (zpp) {
|
|
1948
2285
|
var scale = computeMiniMapScale();
|
|
1949
2286
|
if (miniMapInstance.current) {
|
|
1950
|
-
miniMapInstance.current.instance.
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
zpp.instance.transformState.positionY * scale;
|
|
2287
|
+
miniMapInstance.current.instance.state.scale = zpp.instance.state.scale;
|
|
2288
|
+
miniMapInstance.current.instance.state.positionX =
|
|
2289
|
+
zpp.instance.state.positionX * scale;
|
|
2290
|
+
miniMapInstance.current.instance.state.positionY =
|
|
2291
|
+
zpp.instance.state.positionY * scale;
|
|
1956
2292
|
}
|
|
1957
2293
|
});
|
|
1958
2294
|
}, [computeMiniMapScale, instance, miniMapInstance]);
|
|
2295
|
+
React.useEffect(function () {
|
|
2296
|
+
var move = function (e) {
|
|
2297
|
+
var _a, _b;
|
|
2298
|
+
if (panning &&
|
|
2299
|
+
isDown &&
|
|
2300
|
+
instance.contentComponent &&
|
|
2301
|
+
previewRef.current &&
|
|
2302
|
+
mainRef.current) {
|
|
2303
|
+
var scale = computeMiniMapScale();
|
|
2304
|
+
var previewRect = previewRef.current.getBoundingClientRect();
|
|
2305
|
+
var mainRect = mainRef.current.getBoundingClientRect();
|
|
2306
|
+
var relativeX = (e.clientX - mainRect.left) / scale;
|
|
2307
|
+
var relativeY = (e.clientY - mainRect.top) / scale;
|
|
2308
|
+
var x = relativeX - previewRect.width / 2;
|
|
2309
|
+
var y = relativeY - previewRect.height / 2;
|
|
2310
|
+
var instanceWidth = (((_a = instance.wrapperComponent) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 0) * instance.state.scale;
|
|
2311
|
+
var instanceHeight = (((_b = instance.wrapperComponent) === null || _b === void 0 ? void 0 : _b.offsetHeight) || 0) * instance.state.scale;
|
|
2312
|
+
var limitWidth = instanceWidth - previewRect.width * 2 * instance.state.scale;
|
|
2313
|
+
var limitHeight = instanceHeight - previewRect.height * 2 * instance.state.scale;
|
|
2314
|
+
var boundedX = boundLimiter(x * instance.state.scale, 0, limitWidth, true);
|
|
2315
|
+
var boundedY = boundLimiter(y * instance.state.scale, 0, limitHeight, true);
|
|
2316
|
+
instance.setState(instance.state.scale, -boundedX, -boundedY);
|
|
2317
|
+
}
|
|
2318
|
+
};
|
|
2319
|
+
var setDown = function (e) {
|
|
2320
|
+
var _a;
|
|
2321
|
+
if (((_a = mainRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.target)) ||
|
|
2322
|
+
e.target === mainRef.current) {
|
|
2323
|
+
move(e);
|
|
2324
|
+
setIsDown(true);
|
|
2325
|
+
}
|
|
2326
|
+
};
|
|
2327
|
+
var setUp = function () {
|
|
2328
|
+
setIsDown(false);
|
|
2329
|
+
};
|
|
2330
|
+
document.addEventListener("mousedown", setDown);
|
|
2331
|
+
document.addEventListener("mouseup", setUp);
|
|
2332
|
+
document.addEventListener("mousemove", move);
|
|
2333
|
+
return function () {
|
|
2334
|
+
document.removeEventListener("mousemove", move);
|
|
2335
|
+
document.removeEventListener("mouseup", setUp);
|
|
2336
|
+
};
|
|
2337
|
+
});
|
|
1959
2338
|
var wrapperStyle = React.useMemo(function () {
|
|
1960
2339
|
return {
|
|
1961
2340
|
position: "relative",
|
|
1962
2341
|
zIndex: 2,
|
|
1963
|
-
overflow: "hidden",
|
|
2342
|
+
// overflow: "hidden",
|
|
2343
|
+
userSelect: "none",
|
|
1964
2344
|
};
|
|
1965
2345
|
}, []);
|
|
1966
|
-
return (
|
|
1967
|
-
React__default["default"].createElement("div", __assign({}, rest, { ref: wrapperRef, className: "rzpp-wrapper" }), children),
|
|
1968
|
-
React__default["default"].createElement("div", { className: "rzpp-preview", ref: previewRef, style: __assign(__assign({}, previewStyles), { borderColor: borderColor }) })));
|
|
2346
|
+
return (jsxRuntime.jsxs("div", __assign({}, rest, { ref: mainRef, style: wrapperStyle, className: "rzpp-mini-map ".concat(rest.className || "").trim() }, { children: [jsxRuntime.jsx("div", __assign({ style: { pointerEvents: "none" }, ref: wrapperRef, className: "rzpp-minimap-wrapper ".concat(wrapperClassName || "").trim() }, { children: children })), jsxRuntime.jsx("div", { className: "rzpp-minimap-preview ".concat(previewClassName || "").trim(), ref: previewRef, style: __assign(__assign(__assign({}, previewStyles), { borderColor: borderColor }), previewStyle) })] })));
|
|
1969
2347
|
};
|
|
1970
2348
|
|
|
1971
2349
|
function styleInject(css, ref) {
|
|
@@ -1995,30 +2373,142 @@ function styleInject(css, ref) {
|
|
|
1995
2373
|
}
|
|
1996
2374
|
}
|
|
1997
2375
|
|
|
1998
|
-
var css_248z = ".transform-component-module_wrapper__SPB86 {\n position: relative;\n width: -moz-fit-content;\n width: fit-content;\n height: -moz-fit-content;\n height: fit-content;\n overflow: hidden;\n -webkit-touch-callout: none; /* iOS Safari */\n -webkit-user-select: none; /* Safari */\n -khtml-user-select: none; /* Konqueror HTML */\n -moz-user-select: none; /* Firefox */\n -ms-user-select: none; /* Internet Explorer/Edge */\n user-select: none;\n margin: 0;\n padding: 0;\n}\n.transform-component-module_content__FBWxo {\n display: flex;\n flex-wrap: wrap;\n width: -moz-fit-content;\n width: fit-content;\n height: -moz-fit-content;\n height: fit-content;\n margin: 0;\n padding: 0;\n transform-origin: 0% 0%;\n}\n.transform-component-module_content__FBWxo img {\n pointer-events: none;\n}\n";
|
|
1999
|
-
var styles = {"wrapper":"transform-component-module_wrapper__SPB86","content":"transform-component-module_content__FBWxo"};
|
|
2376
|
+
var css_248z = ".transform-component-module_wrapper__SPB86 {\n position: relative;\n width: -moz-fit-content;\n width: fit-content;\n height: -moz-fit-content;\n height: fit-content;\n overflow: hidden;\n -webkit-touch-callout: none; /* iOS Safari */\n -webkit-user-select: none; /* Safari */\n -khtml-user-select: none; /* Konqueror HTML */\n -moz-user-select: none; /* Firefox */\n -ms-user-select: none; /* Internet Explorer/Edge */\n user-select: none;\n margin: 0;\n padding: 0;\n transform: translate3d(0, 0, 0);\n}\n.transform-component-module_content__FBWxo {\n display: flex;\n flex-wrap: wrap;\n width: -moz-fit-content;\n width: fit-content;\n height: -moz-fit-content;\n height: fit-content;\n margin: 0;\n padding: 0;\n transform-origin: 0% 0%;\n}\n.transform-component-module_content__FBWxo img {\n pointer-events: none;\n}\n.transform-component-module_infiniteGrid__Z-aP3 {\n position: absolute;\n inset: 0;\n pointer-events: none;\n background-image: radial-gradient(\n circle,\n rgba(0, 0, 0, 0.12) 1px,\n transparent 1px\n );\n background-size: 20px 20px;\n background-position: 0 0;\n}\n";
|
|
2377
|
+
var styles = {"wrapper":"transform-component-module_wrapper__SPB86","content":"transform-component-module_content__FBWxo","infiniteGrid":"transform-component-module_infiniteGrid__Z-aP3"};
|
|
2000
2378
|
styleInject(css_248z);
|
|
2001
2379
|
|
|
2002
2380
|
var TransformComponent = function (_a) {
|
|
2003
|
-
var children = _a.children, _b = _a.wrapperClass, wrapperClass = _b === void 0 ? "" : _b, _c = _a.contentClass, contentClass = _c === void 0 ? "" : _c, wrapperStyle = _a.wrapperStyle, contentStyle = _a.contentStyle, _d = _a.wrapperProps, wrapperProps = _d === void 0 ? {} : _d, _e = _a.contentProps, contentProps = _e === void 0 ? {} : _e;
|
|
2004
|
-
var
|
|
2381
|
+
var children = _a.children, _b = _a.wrapperClass, wrapperClass = _b === void 0 ? "" : _b, _c = _a.contentClass, contentClass = _c === void 0 ? "" : _c, wrapperStyle = _a.wrapperStyle, contentStyle = _a.contentStyle, _d = _a.wrapperProps, wrapperProps = _d === void 0 ? {} : _d, _e = _a.contentProps, contentProps = _e === void 0 ? {} : _e, _f = _a.infinite, infinite = _f === void 0 ? false : _f;
|
|
2382
|
+
var instance = React.useContext(Context);
|
|
2383
|
+
var init = instance.init, cleanupWindowEvents = instance.cleanupWindowEvents;
|
|
2005
2384
|
var wrapperRef = React.useRef(null);
|
|
2006
2385
|
var contentRef = React.useRef(null);
|
|
2386
|
+
var gridRef = React.useRef(null);
|
|
2007
2387
|
React.useEffect(function () {
|
|
2008
2388
|
var wrapper = wrapperRef.current;
|
|
2009
2389
|
var content = contentRef.current;
|
|
2010
2390
|
if (wrapper !== null && content !== null && init) {
|
|
2011
2391
|
init === null || init === void 0 ? void 0 : init(wrapper, content);
|
|
2012
2392
|
}
|
|
2013
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2014
2393
|
return function () {
|
|
2015
2394
|
cleanupWindowEvents === null || cleanupWindowEvents === void 0 ? void 0 : cleanupWindowEvents();
|
|
2016
2395
|
};
|
|
2396
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2017
2397
|
}, []);
|
|
2018
|
-
|
|
2019
|
-
|
|
2398
|
+
React.useEffect(function () {
|
|
2399
|
+
if (!infinite)
|
|
2400
|
+
return;
|
|
2401
|
+
var grid = gridRef.current;
|
|
2402
|
+
if (!grid)
|
|
2403
|
+
return;
|
|
2404
|
+
var sync = function () {
|
|
2405
|
+
var _a = instance.state, positionX = _a.positionX, positionY = _a.positionY;
|
|
2406
|
+
grid.style.backgroundPosition = "".concat(positionX, "px ").concat(positionY, "px");
|
|
2407
|
+
};
|
|
2408
|
+
sync();
|
|
2409
|
+
return instance.onChange(sync);
|
|
2410
|
+
}, [infinite, instance]);
|
|
2411
|
+
return (jsxRuntime.jsxs("div", __assign({}, wrapperProps, { ref: wrapperRef, className: "".concat(baseClasses.wrapperClass, " ").concat(styles.wrapper, " ").concat(wrapperClass), style: wrapperStyle }, { children: [infinite && (jsxRuntime.jsx("div", { ref: gridRef, className: styles.infiniteGrid, "aria-hidden": true })), jsxRuntime.jsx("div", __assign({}, contentProps, { ref: contentRef, className: "".concat(baseClasses.contentClass, " ").concat(styles.content, " ").concat(contentClass), style: __assign(__assign({}, contentStyle), { transform: getTransformStyles(instance.state.positionX, instance.state.positionY, instance.state.scale) }) }, { children: children }))] })));
|
|
2020
2412
|
};
|
|
2021
2413
|
|
|
2414
|
+
/**
|
|
2415
|
+
* Compute the overlap area between two axis-aligned rectangles.
|
|
2416
|
+
* Returns 0 when the rectangles do not intersect.
|
|
2417
|
+
*/
|
|
2418
|
+
function getOverlapArea(a, b) {
|
|
2419
|
+
var overlapX = Math.max(0, Math.min(a.x + a.width, b.x + b.width) - Math.max(a.x, b.x));
|
|
2420
|
+
var overlapY = Math.max(0, Math.min(a.y + a.height, b.y + b.height) - Math.max(a.y, b.y));
|
|
2421
|
+
return overlapX * overlapY;
|
|
2422
|
+
}
|
|
2423
|
+
/**
|
|
2424
|
+
* Determine whether an element's content-space bounding box is visible
|
|
2425
|
+
* in the current viewport, accounting for transform, margin, and threshold.
|
|
2426
|
+
*/
|
|
2427
|
+
function isElementVisible(opts) {
|
|
2428
|
+
var elementX = opts.elementX, elementY = opts.elementY, elementWidth = opts.elementWidth, elementHeight = opts.elementHeight, scale = opts.scale, positionX = opts.positionX, positionY = opts.positionY, viewportWidth = opts.viewportWidth, viewportHeight = opts.viewportHeight, _a = opts.margin, margin = _a === void 0 ? 0 : _a, _b = opts.threshold, threshold = _b === void 0 ? 0 : _b;
|
|
2429
|
+
var viewport = {
|
|
2430
|
+
x: -margin,
|
|
2431
|
+
y: -margin,
|
|
2432
|
+
width: viewportWidth + 2 * margin,
|
|
2433
|
+
height: viewportHeight + 2 * margin,
|
|
2434
|
+
};
|
|
2435
|
+
var element = {
|
|
2436
|
+
x: elementX * scale + positionX,
|
|
2437
|
+
y: elementY * scale + positionY,
|
|
2438
|
+
width: elementWidth * scale,
|
|
2439
|
+
height: elementHeight * scale,
|
|
2440
|
+
};
|
|
2441
|
+
if (threshold <= 0) {
|
|
2442
|
+
var intersectsX = element.x < viewport.x + viewport.width &&
|
|
2443
|
+
element.x + element.width > viewport.x;
|
|
2444
|
+
var intersectsY = element.y < viewport.y + viewport.height &&
|
|
2445
|
+
element.y + element.height > viewport.y;
|
|
2446
|
+
return intersectsX && intersectsY;
|
|
2447
|
+
}
|
|
2448
|
+
var elementArea = element.width * element.height;
|
|
2449
|
+
if (elementArea <= 0)
|
|
2450
|
+
return false;
|
|
2451
|
+
var overlap = getOverlapArea(viewport, element);
|
|
2452
|
+
return overlap / elementArea >= threshold;
|
|
2453
|
+
}
|
|
2454
|
+
|
|
2455
|
+
var Virtualize = React.forwardRef(function (_a, ref) {
|
|
2456
|
+
var x = _a.x, y = _a.y, width = _a.width, height = _a.height, _b = _a.margin, margin = _b === void 0 ? 0 : _b, _c = _a.threshold, threshold = _c === void 0 ? 0 : _c, _d = _a.placeholder, placeholder = _d === void 0 ? null : _d, onShow = _a.onShow, onHide = _a.onHide, children = _a.children, className = _a.className, style = _a.style;
|
|
2457
|
+
var instance = React.useContext(Context);
|
|
2458
|
+
var _e = React.useState(false), visible = _e[0], setVisible = _e[1];
|
|
2459
|
+
var visibleRef = React.useRef(false);
|
|
2460
|
+
var onShowRef = React.useRef(onShow);
|
|
2461
|
+
var onHideRef = React.useRef(onHide);
|
|
2462
|
+
onShowRef.current = onShow;
|
|
2463
|
+
onHideRef.current = onHide;
|
|
2464
|
+
React.useEffect(function () {
|
|
2465
|
+
var check = function () {
|
|
2466
|
+
var _a, _b;
|
|
2467
|
+
var wrapper = instance.wrapperComponent;
|
|
2468
|
+
if (!wrapper)
|
|
2469
|
+
return;
|
|
2470
|
+
var nowVisible = isElementVisible({
|
|
2471
|
+
elementX: x,
|
|
2472
|
+
elementY: y,
|
|
2473
|
+
elementWidth: width,
|
|
2474
|
+
elementHeight: height,
|
|
2475
|
+
scale: instance.state.scale,
|
|
2476
|
+
positionX: instance.state.positionX,
|
|
2477
|
+
positionY: instance.state.positionY,
|
|
2478
|
+
viewportWidth: wrapper.offsetWidth,
|
|
2479
|
+
viewportHeight: wrapper.offsetHeight,
|
|
2480
|
+
margin: margin,
|
|
2481
|
+
threshold: threshold,
|
|
2482
|
+
});
|
|
2483
|
+
if (nowVisible !== visibleRef.current) {
|
|
2484
|
+
visibleRef.current = nowVisible;
|
|
2485
|
+
setVisible(nowVisible);
|
|
2486
|
+
if (nowVisible) {
|
|
2487
|
+
(_a = onShowRef.current) === null || _a === void 0 ? void 0 : _a.call(onShowRef);
|
|
2488
|
+
}
|
|
2489
|
+
else {
|
|
2490
|
+
(_b = onHideRef.current) === null || _b === void 0 ? void 0 : _b.call(onHideRef);
|
|
2491
|
+
}
|
|
2492
|
+
}
|
|
2493
|
+
};
|
|
2494
|
+
check();
|
|
2495
|
+
var unsubChange = instance.onChange(check);
|
|
2496
|
+
var unsubInit;
|
|
2497
|
+
if (!instance.wrapperComponent) {
|
|
2498
|
+
unsubInit = instance.onInit(function () { return check(); });
|
|
2499
|
+
}
|
|
2500
|
+
return function () {
|
|
2501
|
+
unsubChange();
|
|
2502
|
+
unsubInit === null || unsubInit === void 0 ? void 0 : unsubInit();
|
|
2503
|
+
};
|
|
2504
|
+
}, [instance, x, y, width, height, margin, threshold]);
|
|
2505
|
+
if (!visible) {
|
|
2506
|
+
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
2507
|
+
return placeholder ? jsxRuntime.jsx(jsxRuntime.Fragment, { children: placeholder }) : null;
|
|
2508
|
+
}
|
|
2509
|
+
return (jsxRuntime.jsx("div", __assign({ ref: ref, className: className, style: style }, { children: children })));
|
|
2510
|
+
});
|
|
2511
|
+
|
|
2022
2512
|
var useTransformContext = function () {
|
|
2023
2513
|
var libraryContext = React.useContext(Context);
|
|
2024
2514
|
if (!libraryContext) {
|
|
@@ -2049,6 +2539,7 @@ var useTransformInit = function (callback) {
|
|
|
2049
2539
|
unmount === null || unmount === void 0 ? void 0 : unmount();
|
|
2050
2540
|
unmountCallback === null || unmountCallback === void 0 ? void 0 : unmountCallback();
|
|
2051
2541
|
};
|
|
2542
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2052
2543
|
}, []);
|
|
2053
2544
|
};
|
|
2054
2545
|
|
|
@@ -2089,9 +2580,11 @@ exports.KeepScale = KeepScale;
|
|
|
2089
2580
|
exports.MiniMap = MiniMap;
|
|
2090
2581
|
exports.TransformComponent = TransformComponent;
|
|
2091
2582
|
exports.TransformWrapper = TransformWrapper;
|
|
2583
|
+
exports.Virtualize = Virtualize;
|
|
2092
2584
|
exports.getCenterPosition = getCenterPosition;
|
|
2093
2585
|
exports.getMatrixTransformStyles = getMatrixTransformStyles;
|
|
2094
2586
|
exports.getTransformStyles = getTransformStyles;
|
|
2587
|
+
exports.roundScaleForTransform = roundScaleForTransform;
|
|
2095
2588
|
exports.useControls = useControls;
|
|
2096
2589
|
exports.useTransformComponent = useTransformComponent;
|
|
2097
2590
|
exports.useTransformContext = useTransformContext;
|