react-zoom-pan-pinch 2.2.1 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/dist/components/transform-component.d.ts +10 -0
  2. package/dist/components/transform-wrapper.d.ts +8 -0
  3. package/dist/constants/state.constants.d.ts +6 -0
  4. package/dist/core/animations/animations.constants.d.ts +16 -0
  5. package/dist/core/animations/animations.utils.d.ts +4 -0
  6. package/dist/core/bounds/bounds.types.d.ts +8 -0
  7. package/dist/core/bounds/bounds.utils.d.ts +15 -0
  8. package/dist/core/double-click/double-click.logic.d.ts +3 -0
  9. package/dist/core/handlers/handlers.logic.d.ts +8 -0
  10. package/dist/core/handlers/handlers.utils.d.ts +13 -0
  11. package/dist/core/instance.core.d.ts +68 -0
  12. package/dist/core/pan/panning.logic.d.ts +5 -0
  13. package/dist/core/pan/panning.utils.d.ts +10 -0
  14. package/dist/core/pan/velocity.logic.d.ts +5 -0
  15. package/dist/core/pan/velocity.utils.d.ts +5 -0
  16. package/dist/core/pinch/pinch.logic.d.ts +4 -0
  17. package/dist/core/pinch/pinch.utils.d.ts +6 -0
  18. package/dist/core/wheel/wheel.logic.d.ts +4 -0
  19. package/dist/core/wheel/wheel.utils.d.ts +7 -0
  20. package/dist/core/zoom/zoom.logic.d.ts +3 -0
  21. package/dist/core/zoom/zoom.utils.d.ts +3 -0
  22. package/dist/hooks/use-transform-context.d.ts +3 -0
  23. package/dist/index.cjs.js +273 -267
  24. package/dist/index.cjs.js.map +1 -1
  25. package/dist/index.d.ts +63 -57
  26. package/dist/index.esm.js +273 -267
  27. package/dist/index.esm.js.map +1 -1
  28. package/dist/models/calculations.model.d.ts +25 -0
  29. package/dist/models/context.model.d.ts +117 -0
  30. package/dist/models/helpers.model.d.ts +5 -0
  31. package/dist/models/index.d.ts +3 -0
  32. package/dist/stories/docs/handlers.d.ts +12 -0
  33. package/dist/stories/docs/props.d.ts +14 -0
  34. package/dist/stories/examples/content-rerendering/example.d.ts +2 -0
  35. package/dist/stories/examples/stress/example.d.ts +2 -0
  36. package/dist/stories/examples/zoom-to-element/example.d.ts +2 -0
  37. package/dist/stories/types/args.types.d.ts +268 -0
  38. package/dist/stories/utils/args.utils.d.ts +3 -0
  39. package/dist/stories/utils/code.utils.d.ts +6 -0
  40. package/dist/stories/utils/controls.utils.d.ts +3 -0
  41. package/dist/stories/utils/index.d.ts +3 -0
  42. package/dist/utils/calculations.utils.d.ts +11 -0
  43. package/dist/utils/callback.utils.d.ts +2 -0
  44. package/dist/utils/context.utils.d.ts +2 -0
  45. package/dist/utils/event.utils.d.ts +1 -0
  46. package/dist/utils/helpers.utils.d.ts +2 -0
  47. package/dist/utils/index.d.ts +7 -0
  48. package/dist/utils/state.utils.d.ts +3 -0
  49. package/dist/utils/styles.utils.d.ts +3 -0
  50. package/package.json +30 -25
  51. package/src/.eslintrc.json +90 -0
  52. package/src/components/transform-component.tsx +2 -1
  53. package/src/components/transform-wrapper.tsx +31 -5
  54. package/src/constants/state.constants.ts +0 -2
  55. package/src/core/animations/animations.constants.ts +14 -12
  56. package/src/core/animations/animations.utils.ts +15 -11
  57. package/src/core/bounds/bounds.utils.ts +20 -20
  58. package/src/core/double-click/double-click.logic.ts +6 -12
  59. package/src/core/handlers/handlers.logic.ts +98 -89
  60. package/src/core/handlers/handlers.utils.ts +22 -24
  61. package/src/{components/transform-context.tsx → core/instance.core.ts} +87 -117
  62. package/src/core/pan/panning.logic.ts +20 -19
  63. package/src/core/pan/panning.utils.ts +4 -7
  64. package/src/core/pan/velocity.logic.ts +1 -0
  65. package/src/core/pinch/pinch.logic.ts +4 -6
  66. package/src/core/pinch/pinch.utils.ts +2 -2
  67. package/src/core/wheel/wheel.logic.ts +1 -0
  68. package/src/core/wheel/wheel.utils.ts +12 -11
  69. package/src/core/zoom/zoom.logic.ts +29 -29
  70. package/src/core/zoom/zoom.utils.ts +2 -2
  71. package/src/hooks/use-transform-context.tsx +3 -2
  72. package/src/models/context.model.ts +6 -2
  73. package/src/stories/docs/handlers.tsx +30 -30
  74. package/src/stories/examples/content-rerendering/content-updating.stories.mdx +3 -0
  75. package/src/stories/examples/stress/example.tsx +24 -0
  76. package/src/stories/examples/stress/stress-test.stories.mdx +28 -0
  77. package/src/stories/examples/zoom-to-element/example.tsx +4 -0
  78. package/src/stories/utils/code.utils.tsx +1 -0
  79. package/src/stories/utils/controls.utils.tsx +21 -4
  80. package/src/stories/utils/styles.module.css +5 -0
  81. package/src/.eslintrc.js +0 -36
package/dist/index.esm.js CHANGED
@@ -1,6 +1,6 @@
1
- import React, { Component, useState, useImperativeHandle, useContext, useRef, useEffect } from 'react';
1
+ import React, { useRef, useMemo, useImperativeHandle, useEffect, useContext } from 'react';
2
2
 
3
- /*! *****************************************************************************
3
+ /******************************************************************************
4
4
  Copyright (c) Microsoft Corporation.
5
5
 
6
6
  Permission to use, copy, modify, and/or distribute this software for any
@@ -14,22 +14,6 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
14
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
15
  PERFORMANCE OF THIS SOFTWARE.
16
16
  ***************************************************************************** */
17
- /* global Reflect, Promise */
18
-
19
- var extendStatics = function(d, b) {
20
- extendStatics = Object.setPrototypeOf ||
21
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
22
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
23
- return extendStatics(d, b);
24
- };
25
-
26
- function __extends(d, b) {
27
- if (typeof b !== "function" && b !== null)
28
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
29
- extendStatics(d, b);
30
- function __() { this.constructor = d; }
31
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
32
- }
33
17
 
34
18
  var __assign = function() {
35
19
  __assign = Object.assign || function __assign(t) {
@@ -49,7 +33,7 @@ function __spreadArray(to, from, pack) {
49
33
  ar[i] = from[i];
50
34
  }
51
35
  }
52
- return to.concat(ar || from);
36
+ return to.concat(ar || Array.prototype.slice.call(from));
53
37
  }
54
38
 
55
39
  /**
@@ -74,6 +58,8 @@ var handleCallback = function (context, event, callback) {
74
58
  }
75
59
  };
76
60
 
61
+ /* eslint-disable no-plusplus */
62
+ /* eslint-disable no-param-reassign */
77
63
  /**
78
64
  * Functions should return denominator of the target value, which is the next animation step.
79
65
  * t is a value from 0 to 1, reflecting the percentage of animation status.
@@ -150,6 +136,7 @@ var animations = {
150
136
  easeInOutQuint: easeInOutQuint,
151
137
  };
152
138
 
139
+ /* eslint-disable no-param-reassign */
153
140
  var handleCancelAnimationFrame = function (animation) {
154
141
  if (typeof animation === "number") {
155
142
  cancelAnimationFrame(animation);
@@ -191,6 +178,15 @@ function handleSetupAnimation(contextInstance, animationName, animationTime, cal
191
178
  };
192
179
  requestAnimationFrame(contextInstance.animation);
193
180
  }
181
+ function isValidTargetState(targetState) {
182
+ var scale = targetState.scale, positionX = targetState.positionX, positionY = targetState.positionY;
183
+ if (Number.isNaN(scale) ||
184
+ Number.isNaN(positionX) ||
185
+ Number.isNaN(positionY)) {
186
+ return false;
187
+ }
188
+ return true;
189
+ }
194
190
  function animate(contextInstance, targetState, animationTime, animationName) {
195
191
  var isValid = isValidTargetState(targetState);
196
192
  if (!contextInstance.mounted || !isValid)
@@ -213,14 +209,8 @@ function animate(contextInstance, targetState, animationTime, animationName) {
213
209
  });
214
210
  }
215
211
  }
216
- function isValidTargetState(targetState) {
217
- var scale = targetState.scale, positionX = targetState.positionX, positionY = targetState.positionY;
218
- if (isNaN(scale) || isNaN(positionX) || isNaN(positionY)) {
219
- return false;
220
- }
221
- return true;
222
- }
223
212
 
213
+ /* eslint-disable no-param-reassign */
224
214
  function getComponentsSizes(wrapperComponent, contentComponent, newScale) {
225
215
  var wrapperWidth = wrapperComponent.offsetWidth;
226
216
  var wrapperHeight = wrapperComponent.offsetHeight;
@@ -262,6 +252,22 @@ var calculateBounds = function (contextInstance, newScale) {
262
252
  var bounds = getBounds(wrapperWidth, newContentWidth, newDiffWidth, wrapperHeight, newContentHeight, newDiffHeight, Boolean(centerZoomedOut));
263
253
  return bounds;
264
254
  };
255
+ /**
256
+ * Keeps value between given bounds, used for limiting view to given boundaries
257
+ * 1# eg. boundLimiter(2, 0, 3, true) => 2
258
+ * 2# eg. boundLimiter(4, 0, 3, true) => 3
259
+ * 3# eg. boundLimiter(-2, 0, 3, true) => 0
260
+ * 4# eg. boundLimiter(10, 0, 3, false) => 10
261
+ */
262
+ var boundLimiter = function (value, minBound, maxBound, isActive) {
263
+ if (!isActive)
264
+ return roundNumber(value, 2);
265
+ if (value < minBound)
266
+ return roundNumber(minBound, 2);
267
+ if (value > maxBound)
268
+ return roundNumber(maxBound, 2);
269
+ return roundNumber(value, 2);
270
+ };
265
271
  var handleCalculateBounds = function (contextInstance, newScale) {
266
272
  var bounds = calculateBounds(contextInstance, newScale);
267
273
  // Save bounds
@@ -280,22 +286,6 @@ function getMouseBoundedPosition(positionX, positionY, bounds, limitToBounds, pa
280
286
  var y = boundLimiter(positionY, minPositionY - paddingY, maxPositionY + paddingY, limitToBounds);
281
287
  return { x: x, y: y };
282
288
  }
283
- /**
284
- * Keeps value between given bounds, used for limiting view to given boundaries
285
- * 1# eg. boundLimiter(2, 0, 3, true) => 2
286
- * 2# eg. boundLimiter(4, 0, 3, true) => 3
287
- * 3# eg. boundLimiter(-2, 0, 3, true) => 0
288
- * 4# eg. boundLimiter(10, 0, 3, false) => 10
289
- */
290
- var boundLimiter = function (value, minBound, maxBound, isActive) {
291
- if (!isActive)
292
- return roundNumber(value, 2);
293
- if (value < minBound)
294
- return roundNumber(minBound, 2);
295
- if (value > maxBound)
296
- return roundNumber(maxBound, 2);
297
- return roundNumber(value, 2);
298
- };
299
289
 
300
290
  function handleCalculateZoomPositions(contextInstance, mouseX, mouseY, newScale, bounds, limitToBounds) {
301
291
  var _a = contextInstance.transformState, scale = _a.scale, positionX = _a.positionX, positionY = _a.positionY;
@@ -314,9 +304,9 @@ function handleCalculateZoomPositions(contextInstance, mouseX, mouseY, newScale,
314
304
  function checkZoomBounds(zoom, minScale, maxScale, zoomPadding, enablePadding) {
315
305
  var scalePadding = enablePadding ? zoomPadding : 0;
316
306
  var minScaleWithPadding = minScale - scalePadding;
317
- if (!isNaN(maxScale) && zoom >= maxScale)
307
+ if (!Number.isNaN(maxScale) && zoom >= maxScale)
318
308
  return maxScale;
319
- if (!isNaN(minScale) && zoom <= minScaleWithPadding)
309
+ if (!Number.isNaN(minScale) && zoom <= minScaleWithPadding)
320
310
  return minScaleWithPadding;
321
311
  return zoom;
322
312
  }
@@ -558,6 +548,18 @@ function handlePanningStart(contextInstance, event) {
558
548
  handlePanningSetup(contextInstance, event);
559
549
  }
560
550
  }
551
+ function handleAlignToBounds(contextInstance) {
552
+ var scale = contextInstance.transformState.scale;
553
+ var _a = contextInstance.setup, minScale = _a.minScale, alignmentAnimation = _a.alignmentAnimation;
554
+ var disabled = alignmentAnimation.disabled, sizeX = alignmentAnimation.sizeX, sizeY = alignmentAnimation.sizeY, animationTime = alignmentAnimation.animationTime, animationType = alignmentAnimation.animationType;
555
+ var isDisabled = disabled || scale < minScale || (!sizeX && !sizeY);
556
+ if (isDisabled)
557
+ return;
558
+ var targetState = handlePanToBounds(contextInstance);
559
+ if (targetState) {
560
+ animate(contextInstance, targetState, animationTime, animationType);
561
+ }
562
+ }
561
563
  function handlePanning(contextInstance, clientX, clientY) {
562
564
  var startCoords = contextInstance.startCoords, setup = contextInstance.setup;
563
565
  var _a = setup.alignmentAnimation, sizeX = _a.sizeX, sizeY = _a.sizeY;
@@ -592,19 +594,14 @@ function handlePanningEnd(contextInstance) {
592
594
  }
593
595
  }
594
596
  }
595
- function handleAlignToBounds(contextInstance) {
596
- var scale = contextInstance.transformState.scale;
597
- var _a = contextInstance.setup, minScale = _a.minScale, alignmentAnimation = _a.alignmentAnimation;
598
- var disabled = alignmentAnimation.disabled, sizeX = alignmentAnimation.sizeX, sizeY = alignmentAnimation.sizeY, animationTime = alignmentAnimation.animationTime, animationType = alignmentAnimation.animationType;
599
- var isDisabled = disabled || scale < minScale || (!sizeX && !sizeY);
600
- if (isDisabled)
601
- return;
602
- var targetState = handlePanToBounds(contextInstance);
603
- if (targetState) {
604
- animate(contextInstance, targetState, animationTime, animationType);
605
- }
606
- }
607
597
 
598
+ function handleZoomToPoint(contextInstance, scale, mouseX, mouseY) {
599
+ var _a = contextInstance.setup, minScale = _a.minScale, maxScale = _a.maxScale, limitToBounds = _a.limitToBounds;
600
+ var newScale = checkZoomBounds(roundNumber(scale, 2), minScale, maxScale, 0, false);
601
+ var bounds = handleCalculateBounds(contextInstance, newScale);
602
+ var _b = handleCalculateZoomPositions(contextInstance, mouseX, mouseY, newScale, bounds, limitToBounds), x = _b.x, y = _b.y;
603
+ return { scale: newScale, positionX: x, positionY: y };
604
+ }
608
605
  function handleAlignToScaleBounds(contextInstance, mousePositionX, mousePositionY) {
609
606
  var scale = contextInstance.transformState.scale;
610
607
  var wrapperComponent = contextInstance.wrapperComponent;
@@ -624,13 +621,6 @@ function handleAlignToScaleBounds(contextInstance, mousePositionX, mousePosition
624
621
  animate(contextInstance, targetState, animationTime, animationType);
625
622
  }
626
623
  }
627
- function handleZoomToPoint(contextInstance, scale, mouseX, mouseY) {
628
- var _a = contextInstance.setup, minScale = _a.minScale, maxScale = _a.maxScale, limitToBounds = _a.limitToBounds;
629
- var newScale = checkZoomBounds(roundNumber(scale, 2), minScale, maxScale, 0, false);
630
- var bounds = handleCalculateBounds(contextInstance, newScale);
631
- var _b = handleCalculateZoomPositions(contextInstance, mouseX, mouseY, newScale, bounds, limitToBounds), x = _b.x, y = _b.y;
632
- return { scale: newScale, positionX: x, positionY: y };
633
- }
634
624
 
635
625
  var initialState = {
636
626
  previousScale: 1,
@@ -725,7 +715,7 @@ var createSetup = function (props) {
725
715
  newSetup[key] = __assign(__assign({}, initialSetup[key]), props[key]);
726
716
  }
727
717
  else if (isArray) {
728
- newSetup[key] = __spreadArray(__spreadArray([], initialSetup[key]), props[key]);
718
+ newSetup[key] = __spreadArray(__spreadArray([], initialSetup[key], true), props[key], true);
729
719
  }
730
720
  else {
731
721
  newSetup[key] = props[key];
@@ -784,6 +774,20 @@ function resetTransformations(contextInstance, animationTime, animationType) {
784
774
  }
785
775
  animate(contextInstance, newState, animationTime, animationType);
786
776
  }
777
+ function getOffset(element) {
778
+ var el = element;
779
+ var offsetLeft = 0;
780
+ var offsetTop = 0;
781
+ while (el) {
782
+ offsetLeft += el.offsetLeft;
783
+ offsetTop += el.offsetTop;
784
+ el = el.offsetParent;
785
+ }
786
+ return {
787
+ x: offsetLeft - window.scrollX,
788
+ y: offsetTop - window.scrollY,
789
+ };
790
+ }
787
791
  function calculateZoomToNode(contextInstance, node, customZoom) {
788
792
  var wrapperComponent = contextInstance.wrapperComponent;
789
793
  var _a = contextInstance.setup, limitToBounds = _a.limitToBounds, minScale = _a.minScale, maxScale = _a.maxScale;
@@ -806,88 +810,85 @@ function calculateZoomToNode(contextInstance, node, customZoom) {
806
810
  var _b = getMouseBoundedPosition(newPositionX, newPositionY, bounds, limitToBounds, 0, 0, wrapperComponent), x = _b.x, y = _b.y;
807
811
  return { positionX: x, positionY: y, scale: newScale };
808
812
  }
809
- function getOffset(element) {
810
- var el = element;
811
- var offsetLeft = 0;
812
- var offsetTop = 0;
813
- while (el) {
814
- offsetLeft += el.offsetLeft;
815
- offsetTop += el.offsetTop;
816
- el = el.offsetParent;
817
- }
818
- return {
819
- x: offsetLeft - window.scrollX,
820
- y: offsetTop - window.scrollY,
821
- };
822
- }
823
813
  function isValidZoomNode(node) {
824
814
  if (!node) {
825
815
  console.error("Zoom node not found");
826
816
  return false;
827
817
  }
828
- else if ((node === null || node === void 0 ? void 0 : node.offsetWidth) === undefined ||
829
- (node === null || node === void 0 ? void 0 : node.offsetHeight) === undefined) {
818
+ if ((node === null || node === void 0 ? void 0 : node.offsetWidth) === undefined || (node === null || node === void 0 ? void 0 : node.offsetHeight) === undefined) {
830
819
  console.error("Zoom node is not valid - it must contain offsetWidth and offsetHeight");
831
820
  return false;
832
821
  }
833
822
  return true;
834
823
  }
835
824
 
836
- var zoomIn = function (contextInstance) { return function (step, animationTime, animationType) {
837
- if (step === void 0) { step = 0.5; }
838
- if (animationTime === void 0) { animationTime = 300; }
839
- if (animationType === void 0) { animationType = "easeOut"; }
840
- handleZoomToViewCenter(contextInstance, 1, step, animationTime, animationType);
841
- }; };
842
- var zoomOut = function (contextInstance) { return function (step, animationTime, animationType) {
843
- if (step === void 0) { step = 0.5; }
844
- if (animationTime === void 0) { animationTime = 300; }
845
- if (animationType === void 0) { animationType = "easeOut"; }
846
- handleZoomToViewCenter(contextInstance, -1, step, animationTime, animationType);
847
- }; };
848
- var setTransform = function (contextInstance) { return function (newPositionX, newPositionY, newScale, animationTime, animationType) {
849
- if (animationTime === void 0) { animationTime = 300; }
850
- if (animationType === void 0) { animationType = "easeOut"; }
851
- var _a = contextInstance.transformState, positionX = _a.positionX, positionY = _a.positionY, scale = _a.scale;
852
- var wrapperComponent = contextInstance.wrapperComponent, contentComponent = contextInstance.contentComponent;
853
- var disabled = contextInstance.setup.disabled;
854
- if (disabled || !wrapperComponent || !contentComponent)
855
- return;
856
- var targetState = {
857
- positionX: isNaN(newPositionX) ? positionX : newPositionX,
858
- positionY: isNaN(newPositionY) ? positionY : newPositionY,
859
- scale: isNaN(newScale) ? scale : newScale,
825
+ var zoomIn = function (contextInstance) {
826
+ return function (step, animationTime, animationType) {
827
+ if (step === void 0) { step = 0.5; }
828
+ if (animationTime === void 0) { animationTime = 300; }
829
+ if (animationType === void 0) { animationType = "easeOut"; }
830
+ handleZoomToViewCenter(contextInstance, 1, step, animationTime, animationType);
860
831
  };
861
- animate(contextInstance, targetState, animationTime, animationType);
862
- }; };
863
- var resetTransform = function (contextInstance) { return function (animationTime, animationType) {
864
- if (animationTime === void 0) { animationTime = 200; }
865
- if (animationType === void 0) { animationType = "easeOut"; }
866
- resetTransformations(contextInstance, animationTime, animationType);
867
- }; };
868
- var centerView = function (contextInstance) { return function (scale, animationTime, animationType) {
869
- if (animationTime === void 0) { animationTime = 200; }
870
- if (animationType === void 0) { animationType = "easeOut"; }
871
- var transformState = contextInstance.transformState, wrapperComponent = contextInstance.wrapperComponent, contentComponent = contextInstance.contentComponent;
872
- if (wrapperComponent && contentComponent) {
873
- var targetState = getCenterPosition(scale || transformState.scale, wrapperComponent, contentComponent);
874
- animate(contextInstance, targetState, animationTime, animationType);
875
- }
876
- }; };
877
- var zoomToElement = function (contextInstance) { return function (node, scale, animationTime, animationType) {
878
- if (animationTime === void 0) { animationTime = 600; }
879
- if (animationType === void 0) { animationType = "easeOut"; }
880
- handleCancelAnimation(contextInstance);
881
- var wrapperComponent = contextInstance.wrapperComponent;
882
- var target = typeof node === "string" ? document.getElementById(node) : node;
883
- if (wrapperComponent &&
884
- isValidZoomNode(target) &&
885
- target &&
886
- wrapperComponent.contains(target)) {
887
- var targetState = calculateZoomToNode(contextInstance, target, scale);
832
+ };
833
+ var zoomOut = function (contextInstance) {
834
+ return function (step, animationTime, animationType) {
835
+ if (step === void 0) { step = 0.5; }
836
+ if (animationTime === void 0) { animationTime = 300; }
837
+ if (animationType === void 0) { animationType = "easeOut"; }
838
+ handleZoomToViewCenter(contextInstance, -1, step, animationTime, animationType);
839
+ };
840
+ };
841
+ var setTransform = function (contextInstance) {
842
+ return function (newPositionX, newPositionY, newScale, animationTime, animationType) {
843
+ if (animationTime === void 0) { animationTime = 300; }
844
+ if (animationType === void 0) { animationType = "easeOut"; }
845
+ var _a = contextInstance.transformState, positionX = _a.positionX, positionY = _a.positionY, scale = _a.scale;
846
+ var wrapperComponent = contextInstance.wrapperComponent, contentComponent = contextInstance.contentComponent;
847
+ var disabled = contextInstance.setup.disabled;
848
+ if (disabled || !wrapperComponent || !contentComponent)
849
+ return;
850
+ var targetState = {
851
+ positionX: Number.isNaN(newPositionX) ? positionX : newPositionX,
852
+ positionY: Number.isNaN(newPositionY) ? positionY : newPositionY,
853
+ scale: Number.isNaN(newScale) ? scale : newScale,
854
+ };
888
855
  animate(contextInstance, targetState, animationTime, animationType);
889
- }
890
- }; };
856
+ };
857
+ };
858
+ var resetTransform = function (contextInstance) {
859
+ return function (animationTime, animationType) {
860
+ if (animationTime === void 0) { animationTime = 200; }
861
+ if (animationType === void 0) { animationType = "easeOut"; }
862
+ resetTransformations(contextInstance, animationTime, animationType);
863
+ };
864
+ };
865
+ var centerView = function (contextInstance) {
866
+ return function (scale, animationTime, animationType) {
867
+ if (animationTime === void 0) { animationTime = 200; }
868
+ if (animationType === void 0) { animationType = "easeOut"; }
869
+ var transformState = contextInstance.transformState, wrapperComponent = contextInstance.wrapperComponent, contentComponent = contextInstance.contentComponent;
870
+ if (wrapperComponent && contentComponent) {
871
+ var targetState = getCenterPosition(scale || transformState.scale, wrapperComponent, contentComponent);
872
+ animate(contextInstance, targetState, animationTime, animationType);
873
+ }
874
+ };
875
+ };
876
+ var zoomToElement = function (contextInstance) {
877
+ return function (node, scale, animationTime, animationType) {
878
+ if (animationTime === void 0) { animationTime = 600; }
879
+ if (animationType === void 0) { animationType = "easeOut"; }
880
+ handleCancelAnimation(contextInstance);
881
+ var wrapperComponent = contextInstance.wrapperComponent;
882
+ var target = typeof node === "string" ? document.getElementById(node) : node;
883
+ if (wrapperComponent &&
884
+ isValidZoomNode(target) &&
885
+ target &&
886
+ wrapperComponent.contains(target)) {
887
+ var targetState = calculateZoomToNode(contextInstance, target, scale);
888
+ animate(contextInstance, targetState, animationTime, animationType);
889
+ }
890
+ };
891
+ };
891
892
 
892
893
  var getContext = function (contextInstance) {
893
894
  return {
@@ -951,7 +952,7 @@ var getTransformStyles = function (x, y, scale) {
951
952
  var d = scale;
952
953
  var tx = x;
953
954
  var ty = y;
954
- return "matrix3d(" + a + ", " + b + ", 0, 0, " + c + ", " + d + ", 0, 0, 0, 0, 1, 0, " + tx + ", " + ty + ", 0, 1)";
955
+ return "matrix3d(".concat(a, ", ").concat(b, ", 0, 0, ").concat(c, ", ").concat(d, ", 0, 0, 0, 0, 1, 0, ").concat(tx, ", ").concat(ty, ", 0, 1)");
955
956
  };
956
957
  var getCenterPosition = function (scale, wrapperComponent, contentComponent) {
957
958
  var contentWidth = contentComponent.offsetWidth * scale;
@@ -982,8 +983,14 @@ var isWheelAllowed = function (contextInstance, event) {
982
983
  return false;
983
984
  return true;
984
985
  };
986
+ var getDeltaY = function (event) {
987
+ if (event) {
988
+ return event.deltaY < 0 ? 1 : -1;
989
+ }
990
+ return 0;
991
+ };
985
992
  function getDelta(event, customDelta) {
986
- var deltaY = event ? (event.deltaY < 0 ? 1 : -1) : 0;
993
+ var deltaY = getDeltaY(event);
987
994
  var delta = checkIsNumber(customDelta, deltaY);
988
995
  return delta;
989
996
  }
@@ -1001,7 +1008,7 @@ function getMousePosition(event, contentComponent, scale) {
1001
1008
  mouseX = (touch.clientX - contentRect.left) / scale;
1002
1009
  mouseY = (touch.clientY - contentRect.top) / scale;
1003
1010
  }
1004
- if (isNaN(mouseX) || isNaN(mouseY))
1011
+ if (Number.isNaN(mouseX) || Number.isNaN(mouseY))
1005
1012
  console.error("No mouse or touch offset found");
1006
1013
  return {
1007
1014
  x: mouseX,
@@ -1075,8 +1082,8 @@ var calculateTouchMidPoint = function (event, scale, contentComponent) {
1075
1082
  };
1076
1083
  };
1077
1084
  var getTouchDistance = function (event) {
1078
- return Math.sqrt(Math.pow(event.touches[0].pageX - event.touches[1].pageX, 2) +
1079
- Math.pow(event.touches[0].pageY - event.touches[1].pageY, 2));
1085
+ return Math.sqrt(Math.pow((event.touches[0].pageX - event.touches[1].pageX), 2) +
1086
+ Math.pow((event.touches[0].pageY - event.touches[1].pageY), 2));
1080
1087
  };
1081
1088
  var calculatePinchZoom = function (contextInstance, currentDistance) {
1082
1089
  var pinchStartScale = contextInstance.pinchStartScale, pinchStartDistance = contextInstance.pinchStartDistance, setup = contextInstance.setup;
@@ -1172,7 +1179,7 @@ var handlePinchZoom = function (contextInstance, event) {
1172
1179
  return;
1173
1180
  var midPoint = calculateTouchMidPoint(event, scale, contentComponent);
1174
1181
  // if touches goes off of the wrapper element
1175
- if (!isFinite(midPoint.x) || !isFinite(midPoint.y))
1182
+ if (!Number.isFinite(midPoint.x) || !Number.isFinite(midPoint.y))
1176
1183
  return;
1177
1184
  var currentDistance = getTouchDistance(event);
1178
1185
  var newScale = calculatePinchZoom(contextInstance, currentDistance);
@@ -1232,45 +1239,51 @@ var isDoubleClickAllowed = function (contextInstance, event) {
1232
1239
  return true;
1233
1240
  };
1234
1241
 
1235
- var Context = React.createContext(contextInitialState);
1236
- var TransformContext = /** @class */ (function (_super) {
1237
- __extends(TransformContext, _super);
1238
- function TransformContext() {
1239
- var _this = _super !== null && _super.apply(this, arguments) || this;
1240
- _this.mounted = true;
1241
- _this.transformState = createState(_this.props);
1242
- _this.setup = createSetup(_this.props);
1242
+ var ZoomPanPinch = /** @class */ (function () {
1243
+ function ZoomPanPinch(props) {
1244
+ var _this = this;
1245
+ this.mounted = true;
1243
1246
  // Components
1244
- _this.wrapperComponent = null;
1245
- _this.contentComponent = null;
1247
+ this.wrapperComponent = null;
1248
+ this.contentComponent = null;
1246
1249
  // Initialization
1247
- _this.isInitialized = false;
1248
- _this.bounds = null;
1250
+ this.isInitialized = false;
1251
+ this.bounds = null;
1249
1252
  // wheel helpers
1250
- _this.previousWheelEvent = null;
1251
- _this.wheelStopEventTimer = null;
1252
- _this.wheelAnimationTimer = null;
1253
+ this.previousWheelEvent = null;
1254
+ this.wheelStopEventTimer = null;
1255
+ this.wheelAnimationTimer = null;
1253
1256
  // panning helpers
1254
- _this.isPanning = false;
1255
- _this.startCoords = null;
1256
- _this.lastTouch = null;
1257
+ this.isPanning = false;
1258
+ this.startCoords = null;
1259
+ this.lastTouch = null;
1257
1260
  // pinch helpers
1258
- _this.distance = null;
1259
- _this.lastDistance = null;
1260
- _this.pinchStartDistance = null;
1261
- _this.pinchStartScale = null;
1262
- _this.pinchMidpoint = null;
1261
+ this.distance = null;
1262
+ this.lastDistance = null;
1263
+ this.pinchStartDistance = null;
1264
+ this.pinchStartScale = null;
1265
+ this.pinchMidpoint = null;
1263
1266
  // velocity helpers
1264
- _this.velocity = null;
1265
- _this.velocityTime = null;
1266
- _this.lastMousePosition = null;
1267
+ this.velocity = null;
1268
+ this.velocityTime = null;
1269
+ this.lastMousePosition = null;
1267
1270
  // animations helpers
1268
- _this.animate = false;
1269
- _this.animation = null;
1270
- _this.maxBounds = null;
1271
+ this.animate = false;
1272
+ this.animation = null;
1273
+ this.maxBounds = null;
1271
1274
  // key press
1272
- _this.pressedKeys = {};
1273
- _this.initializeWindowEvents = function () {
1275
+ this.pressedKeys = {};
1276
+ this.mount = function () {
1277
+ _this.initializeWindowEvents();
1278
+ };
1279
+ this.unmount = function () {
1280
+ _this.cleanupWindowEvents();
1281
+ };
1282
+ this.update = function (newProps) {
1283
+ handleCalculateBounds(_this, _this.transformState.scale);
1284
+ _this.setup = createSetup(newProps);
1285
+ };
1286
+ this.initializeWindowEvents = function () {
1274
1287
  var _a;
1275
1288
  var passive = makePassiveEventOption();
1276
1289
  var currentDocument = (_a = _this.wrapperComponent) === null || _a === void 0 ? void 0 : _a.ownerDocument;
@@ -1282,10 +1295,9 @@ var TransformContext = /** @class */ (function (_super) {
1282
1295
  currentDocument === null || currentDocument === void 0 ? void 0 : currentDocument.addEventListener("mouseleave", _this.clearPanning, passive);
1283
1296
  currentWindow === null || currentWindow === void 0 ? void 0 : currentWindow.addEventListener("keyup", _this.setKeyUnPressed, passive);
1284
1297
  currentWindow === null || currentWindow === void 0 ? void 0 : currentWindow.addEventListener("keydown", _this.setKeyPressed, passive);
1285
- _this.handleRef();
1286
1298
  };
1287
- _this.cleanupWindowEvents = function () {
1288
- var _a;
1299
+ this.cleanupWindowEvents = function () {
1300
+ var _a, _b;
1289
1301
  var passive = makePassiveEventOption();
1290
1302
  var currentDocument = (_a = _this.wrapperComponent) === null || _a === void 0 ? void 0 : _a.ownerDocument;
1291
1303
  var currentWindow = currentDocument === null || currentDocument === void 0 ? void 0 : currentDocument.defaultView;
@@ -1297,8 +1309,9 @@ var TransformContext = /** @class */ (function (_super) {
1297
1309
  currentWindow === null || currentWindow === void 0 ? void 0 : currentWindow.removeEventListener("keydown", _this.setKeyPressed, passive);
1298
1310
  document.removeEventListener("mouseleave", _this.clearPanning, passive);
1299
1311
  handleCancelAnimation(_this);
1312
+ (_b = _this.observer) === null || _b === void 0 ? void 0 : _b.disconnect();
1300
1313
  };
1301
- _this.handleInitializeWrapperEvents = function (wrapper) {
1314
+ this.handleInitializeWrapperEvents = function (wrapper) {
1302
1315
  // Zooming events on wrapper
1303
1316
  var passive = makePassiveEventOption();
1304
1317
  wrapper.addEventListener("wheel", _this.onWheelZoom, passive);
@@ -1307,34 +1320,24 @@ var TransformContext = /** @class */ (function (_super) {
1307
1320
  wrapper.addEventListener("touchmove", _this.onTouchPanning, passive);
1308
1321
  wrapper.addEventListener("touchend", _this.onTouchPanningStop, passive);
1309
1322
  };
1310
- _this.handleInitialize = function () {
1323
+ this.handleInitialize = function (contentComponent) {
1311
1324
  var centerOnInit = _this.setup.centerOnInit;
1312
1325
  _this.applyTransformation();
1313
- _this.forceUpdate();
1314
1326
  if (centerOnInit) {
1315
- // this has to be redone once the right solution is found
1316
- // problem is - we need to execute it after mounted component specify it's height / width, images are fetched async so it's tricky
1317
- setTimeout(function () {
1318
- if (_this.mounted) {
1319
- _this.setCenter();
1320
- }
1321
- }, 50);
1322
- setTimeout(function () {
1323
- if (_this.mounted) {
1324
- _this.setCenter();
1325
- }
1326
- }, 100);
1327
- setTimeout(function () {
1328
- if (_this.mounted) {
1329
- _this.setCenter();
1330
- }
1331
- }, 200);
1327
+ _this.setCenter();
1328
+ _this.observer = new ResizeObserver(function () {
1329
+ var _a;
1330
+ _this.setCenter();
1331
+ (_a = _this.observer) === null || _a === void 0 ? void 0 : _a.disconnect();
1332
+ });
1333
+ // Start observing the target node for configured mutations
1334
+ _this.observer.observe(contentComponent);
1332
1335
  }
1333
1336
  };
1334
- //////////
1337
+ /// ///////
1335
1338
  // Zoom
1336
- //////////
1337
- _this.onWheelZoom = function (event) {
1339
+ /// ///////
1340
+ this.onWheelZoom = function (event) {
1338
1341
  var disabled = _this.setup.disabled;
1339
1342
  if (disabled)
1340
1343
  return;
@@ -1348,10 +1351,10 @@ var TransformContext = /** @class */ (function (_super) {
1348
1351
  handleWheelZoom(_this, event);
1349
1352
  handleWheelStop(_this, event);
1350
1353
  };
1351
- //////////
1354
+ /// ///////
1352
1355
  // Pan
1353
- //////////
1354
- _this.onPanningStart = function (event) {
1356
+ /// ///////
1357
+ this.onPanningStart = function (event) {
1355
1358
  var disabled = _this.setup.disabled;
1356
1359
  var onPanningStart = _this.props.onPanningStart;
1357
1360
  if (disabled)
@@ -1368,7 +1371,7 @@ var TransformContext = /** @class */ (function (_super) {
1368
1371
  handlePanningStart(_this, event);
1369
1372
  handleCallback(getContext(_this), event, onPanningStart);
1370
1373
  };
1371
- _this.onPanning = function (event) {
1374
+ this.onPanning = function (event) {
1372
1375
  var disabled = _this.setup.disabled;
1373
1376
  var onPanning = _this.props.onPanning;
1374
1377
  if (disabled)
@@ -1384,17 +1387,17 @@ var TransformContext = /** @class */ (function (_super) {
1384
1387
  handlePanning(_this, event.clientX, event.clientY);
1385
1388
  handleCallback(getContext(_this), event, onPanning);
1386
1389
  };
1387
- _this.onPanningStop = function (event) {
1390
+ this.onPanningStop = function (event) {
1388
1391
  var onPanningStop = _this.props.onPanningStop;
1389
1392
  if (_this.isPanning) {
1390
1393
  handlePanningEnd(_this);
1391
1394
  handleCallback(getContext(_this), event, onPanningStop);
1392
1395
  }
1393
1396
  };
1394
- //////////
1397
+ /// ///////
1395
1398
  // Pinch
1396
- //////////
1397
- _this.onPinchStart = function (event) {
1399
+ /// ///////
1400
+ this.onPinchStart = function (event) {
1398
1401
  var disabled = _this.setup.disabled;
1399
1402
  var _a = _this.props, onPinchingStart = _a.onPinchingStart, onZoomStart = _a.onZoomStart;
1400
1403
  if (disabled)
@@ -1407,7 +1410,7 @@ var TransformContext = /** @class */ (function (_super) {
1407
1410
  handleCallback(getContext(_this), event, onPinchingStart);
1408
1411
  handleCallback(getContext(_this), event, onZoomStart);
1409
1412
  };
1410
- _this.onPinch = function (event) {
1413
+ this.onPinch = function (event) {
1411
1414
  var disabled = _this.setup.disabled;
1412
1415
  var _a = _this.props, onPinching = _a.onPinching, onZoom = _a.onZoom;
1413
1416
  if (disabled)
@@ -1421,7 +1424,7 @@ var TransformContext = /** @class */ (function (_super) {
1421
1424
  handleCallback(getContext(_this), event, onPinching);
1422
1425
  handleCallback(getContext(_this), event, onZoom);
1423
1426
  };
1424
- _this.onPinchStop = function (event) {
1427
+ this.onPinchStop = function (event) {
1425
1428
  var _a = _this.props, onPinchingStop = _a.onPinchingStop, onZoomStop = _a.onZoomStop;
1426
1429
  if (_this.pinchStartScale) {
1427
1430
  handlePinchStop(_this);
@@ -1429,10 +1432,10 @@ var TransformContext = /** @class */ (function (_super) {
1429
1432
  handleCallback(getContext(_this), event, onZoomStop);
1430
1433
  }
1431
1434
  };
1432
- //////////
1435
+ /// ///////
1433
1436
  // Touch
1434
- //////////
1435
- _this.onTouchPanningStart = function (event) {
1437
+ /// ///////
1438
+ this.onTouchPanningStart = function (event) {
1436
1439
  var disabled = _this.setup.disabled;
1437
1440
  var onPanningStart = _this.props.onPanningStart;
1438
1441
  if (disabled)
@@ -1460,7 +1463,7 @@ var TransformContext = /** @class */ (function (_super) {
1460
1463
  }
1461
1464
  }
1462
1465
  };
1463
- _this.onTouchPanning = function (event) {
1466
+ this.onTouchPanning = function (event) {
1464
1467
  var disabled = _this.setup.disabled;
1465
1468
  var onPanning = _this.props.onPanning;
1466
1469
  if (_this.isPanning && event.touches.length === 1) {
@@ -1479,14 +1482,14 @@ var TransformContext = /** @class */ (function (_super) {
1479
1482
  _this.onPinch(event);
1480
1483
  }
1481
1484
  };
1482
- _this.onTouchPanningStop = function (event) {
1485
+ this.onTouchPanningStop = function (event) {
1483
1486
  _this.onPanningStop(event);
1484
1487
  _this.onPinchStop(event);
1485
1488
  };
1486
- //////////
1489
+ /// ///////
1487
1490
  // Double Click
1488
- //////////
1489
- _this.onDoubleClick = function (event) {
1491
+ /// ///////
1492
+ this.onDoubleClick = function (event) {
1490
1493
  var disabled = _this.setup.disabled;
1491
1494
  if (disabled)
1492
1495
  return;
@@ -1495,41 +1498,31 @@ var TransformContext = /** @class */ (function (_super) {
1495
1498
  return;
1496
1499
  handleDoubleClick(_this, event);
1497
1500
  };
1498
- //////////
1501
+ /// ///////
1499
1502
  // Helpers
1500
- //////////
1501
- _this.clearPanning = function (event) {
1503
+ /// ///////
1504
+ this.clearPanning = function (event) {
1502
1505
  if (_this.isPanning) {
1503
1506
  _this.onPanningStop(event);
1504
1507
  }
1505
1508
  };
1506
- _this.setKeyPressed = function (e) {
1509
+ this.setKeyPressed = function (e) {
1507
1510
  _this.pressedKeys[e.key] = true;
1508
1511
  };
1509
- _this.setKeyUnPressed = function (e) {
1512
+ this.setKeyUnPressed = function (e) {
1510
1513
  _this.pressedKeys[e.key] = false;
1511
1514
  };
1512
- _this.isPressingKeys = function (keys) {
1515
+ this.isPressingKeys = function (keys) {
1513
1516
  if (!keys.length) {
1514
1517
  return true;
1515
1518
  }
1516
1519
  return Boolean(keys.find(function (key) { return _this.pressedKeys[key]; }));
1517
1520
  };
1518
- _this.setComponents = function (wrapperComponent, contentComponent) {
1519
- _this.cleanupWindowEvents();
1520
- _this.wrapperComponent = wrapperComponent;
1521
- _this.contentComponent = contentComponent;
1522
- handleCalculateBounds(_this, _this.transformState.scale);
1523
- _this.handleInitializeWrapperEvents(wrapperComponent);
1524
- _this.initializeWindowEvents();
1525
- _this.handleInitialize();
1526
- _this.handleRef();
1527
- _this.isInitialized = true;
1528
- handleCallback(getContext(_this), undefined, _this.props.onInit);
1529
- };
1530
- _this.setTransformState = function (scale, positionX, positionY) {
1521
+ this.setTransformState = function (scale, positionX, positionY) {
1531
1522
  var onTransformed = _this.props.onTransformed;
1532
- if (!isNaN(scale) && !isNaN(positionX) && !isNaN(positionY)) {
1523
+ if (!Number.isNaN(scale) &&
1524
+ !Number.isNaN(positionX) &&
1525
+ !Number.isNaN(positionY)) {
1533
1526
  if (scale !== _this.transformState.scale) {
1534
1527
  _this.transformState.previousScale = _this.transformState.scale;
1535
1528
  _this.transformState.scale = scale;
@@ -1543,50 +1536,62 @@ var TransformContext = /** @class */ (function (_super) {
1543
1536
  console.error("Detected NaN set state values");
1544
1537
  }
1545
1538
  };
1546
- _this.setCenter = function () {
1539
+ this.setCenter = function () {
1547
1540
  if (_this.wrapperComponent && _this.contentComponent) {
1548
1541
  var targetState = getCenterPosition(_this.transformState.scale, _this.wrapperComponent, _this.contentComponent);
1549
1542
  _this.setTransformState(targetState.scale, targetState.positionX, targetState.positionY);
1550
1543
  }
1551
1544
  };
1552
- _this.applyTransformation = function () {
1545
+ this.applyTransformation = function () {
1553
1546
  if (!_this.mounted || !_this.contentComponent)
1554
1547
  return;
1555
1548
  var _a = _this.transformState, scale = _a.scale, positionX = _a.positionX, positionY = _a.positionY;
1556
1549
  var transform = getTransformStyles(positionX, positionY, scale);
1557
1550
  _this.contentComponent.style.transform = transform;
1558
- _this.handleRef();
1559
1551
  };
1560
- _this.handleRef = function () {
1561
- _this.props.setRef(getContext(_this));
1552
+ this.getContext = function () {
1553
+ return getContext(_this);
1562
1554
  };
1563
- return _this;
1555
+ /**
1556
+ * Initialization
1557
+ */
1558
+ this.init = function (wrapperComponent, contentComponent) {
1559
+ _this.cleanupWindowEvents();
1560
+ _this.wrapperComponent = wrapperComponent;
1561
+ _this.contentComponent = contentComponent;
1562
+ handleCalculateBounds(_this, _this.transformState.scale);
1563
+ _this.handleInitializeWrapperEvents(wrapperComponent);
1564
+ _this.handleInitialize(contentComponent);
1565
+ _this.initializeWindowEvents();
1566
+ _this.isInitialized = true;
1567
+ handleCallback(getContext(_this), undefined, _this.props.onInit);
1568
+ };
1569
+ this.props = props;
1570
+ this.setup = createSetup(this.props);
1571
+ this.transformState = createState(this.props);
1564
1572
  }
1565
- TransformContext.prototype.componentDidMount = function () {
1566
- this.initializeWindowEvents();
1567
- };
1568
- TransformContext.prototype.componentWillUnmount = function () {
1569
- this.cleanupWindowEvents();
1570
- };
1571
- TransformContext.prototype.componentDidUpdate = function (oldProps) {
1572
- if (oldProps !== this.props) {
1573
- handleCalculateBounds(this, this.transformState.scale);
1574
- this.setup = createSetup(this.props);
1575
- }
1576
- };
1577
- TransformContext.prototype.render = function () {
1578
- var value = getContext(this);
1579
- var children = this.props.children;
1580
- var content = typeof children === "function" ? children(value) : children;
1581
- return (React.createElement(Context.Provider, { value: __assign(__assign({}, this.transformState), { setComponents: this.setComponents, contextInstance: this }) }, content));
1582
- };
1583
- return TransformContext;
1584
- }(Component));
1573
+ return ZoomPanPinch;
1574
+ }());
1585
1575
 
1576
+ var Context = React.createContext(contextInitialState);
1586
1577
  var TransformWrapper = React.forwardRef(function (props, ref) {
1587
- var _a = useState(null), innerRef = _a[0], setRef = _a[1];
1588
- useImperativeHandle(ref, function () { return innerRef; }, [innerRef]);
1589
- return React.createElement(TransformContext, __assign({}, props, { setRef: setRef }));
1578
+ var children = props.children;
1579
+ var instance = useRef(new ZoomPanPinch(props)).current;
1580
+ var content = useMemo(function () {
1581
+ if (typeof children === "function") {
1582
+ return children(getContext(instance));
1583
+ }
1584
+ return children;
1585
+ }, [children, instance]);
1586
+ var value = useMemo(function () {
1587
+ return __assign(__assign({}, instance.transformState), { setComponents: instance.init, contextInstance: instance });
1588
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1589
+ }, [JSON.stringify(instance.transformState)]);
1590
+ useImperativeHandle(ref, function () { return getContext(instance); }, [instance]);
1591
+ useEffect(function () {
1592
+ instance.update(props);
1593
+ }, [instance, props]);
1594
+ return React.createElement(Context.Provider, { value: value }, content);
1590
1595
  });
1591
1596
 
1592
1597
  function styleInject(css, ref) {
@@ -1616,10 +1621,11 @@ function styleInject(css, ref) {
1616
1621
  }
1617
1622
  }
1618
1623
 
1619
- var css_248z = ".transform-component-module_wrapper__1_Fgj {\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__2jYgh {\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__2jYgh img {\n pointer-events: none;\n}\n";
1620
- var styles = {"wrapper":"transform-component-module_wrapper__1_Fgj","content":"transform-component-module_content__2jYgh"};
1624
+ var css_248z = ".transform-component-module_wrapper__7HFJe {\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__uCDPE {\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__uCDPE img {\n pointer-events: none;\n}\n";
1625
+ var styles = {"wrapper":"transform-component-module_wrapper__7HFJe","content":"transform-component-module_content__uCDPE"};
1621
1626
  styleInject(css_248z);
1622
1627
 
1628
+ /* eslint-disable react/require-default-props */
1623
1629
  var TransformComponent = function (_a) {
1624
1630
  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;
1625
1631
  var setComponents = useContext(Context).setComponents;
@@ -1632,8 +1638,8 @@ var TransformComponent = function (_a) {
1632
1638
  setComponents(wrapper, content);
1633
1639
  }
1634
1640
  }, []);
1635
- return (React.createElement("div", { ref: wrapperRef, className: "react-transform-wrapper " + styles.wrapper + " " + wrapperClass, style: wrapperStyle },
1636
- React.createElement("div", { ref: contentRef, className: "react-transform-component " + styles.content + " " + contentClass, style: contentStyle }, children)));
1641
+ return (React.createElement("div", { ref: wrapperRef, className: "react-transform-wrapper ".concat(styles.wrapper, " ").concat(wrapperClass), style: wrapperStyle },
1642
+ React.createElement("div", { ref: contentRef, className: "react-transform-component ".concat(styles.content, " ").concat(contentClass), style: contentStyle }, children)));
1637
1643
  };
1638
1644
 
1639
1645
  var useTransformContext = function () {