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.cjs.js CHANGED
@@ -8,7 +8,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
8
8
 
9
9
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
10
10
 
11
- /*! *****************************************************************************
11
+ /******************************************************************************
12
12
  Copyright (c) Microsoft Corporation.
13
13
 
14
14
  Permission to use, copy, modify, and/or distribute this software for any
@@ -22,22 +22,6 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
22
22
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
23
23
  PERFORMANCE OF THIS SOFTWARE.
24
24
  ***************************************************************************** */
25
- /* global Reflect, Promise */
26
-
27
- var extendStatics = function(d, b) {
28
- extendStatics = Object.setPrototypeOf ||
29
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
30
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
31
- return extendStatics(d, b);
32
- };
33
-
34
- function __extends(d, b) {
35
- if (typeof b !== "function" && b !== null)
36
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
37
- extendStatics(d, b);
38
- function __() { this.constructor = d; }
39
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
40
- }
41
25
 
42
26
  var __assign = function() {
43
27
  __assign = Object.assign || function __assign(t) {
@@ -57,7 +41,7 @@ function __spreadArray(to, from, pack) {
57
41
  ar[i] = from[i];
58
42
  }
59
43
  }
60
- return to.concat(ar || from);
44
+ return to.concat(ar || Array.prototype.slice.call(from));
61
45
  }
62
46
 
63
47
  /**
@@ -82,6 +66,8 @@ var handleCallback = function (context, event, callback) {
82
66
  }
83
67
  };
84
68
 
69
+ /* eslint-disable no-plusplus */
70
+ /* eslint-disable no-param-reassign */
85
71
  /**
86
72
  * Functions should return denominator of the target value, which is the next animation step.
87
73
  * t is a value from 0 to 1, reflecting the percentage of animation status.
@@ -158,6 +144,7 @@ var animations = {
158
144
  easeInOutQuint: easeInOutQuint,
159
145
  };
160
146
 
147
+ /* eslint-disable no-param-reassign */
161
148
  var handleCancelAnimationFrame = function (animation) {
162
149
  if (typeof animation === "number") {
163
150
  cancelAnimationFrame(animation);
@@ -199,6 +186,15 @@ function handleSetupAnimation(contextInstance, animationName, animationTime, cal
199
186
  };
200
187
  requestAnimationFrame(contextInstance.animation);
201
188
  }
189
+ function isValidTargetState(targetState) {
190
+ var scale = targetState.scale, positionX = targetState.positionX, positionY = targetState.positionY;
191
+ if (Number.isNaN(scale) ||
192
+ Number.isNaN(positionX) ||
193
+ Number.isNaN(positionY)) {
194
+ return false;
195
+ }
196
+ return true;
197
+ }
202
198
  function animate(contextInstance, targetState, animationTime, animationName) {
203
199
  var isValid = isValidTargetState(targetState);
204
200
  if (!contextInstance.mounted || !isValid)
@@ -221,14 +217,8 @@ function animate(contextInstance, targetState, animationTime, animationName) {
221
217
  });
222
218
  }
223
219
  }
224
- function isValidTargetState(targetState) {
225
- var scale = targetState.scale, positionX = targetState.positionX, positionY = targetState.positionY;
226
- if (isNaN(scale) || isNaN(positionX) || isNaN(positionY)) {
227
- return false;
228
- }
229
- return true;
230
- }
231
220
 
221
+ /* eslint-disable no-param-reassign */
232
222
  function getComponentsSizes(wrapperComponent, contentComponent, newScale) {
233
223
  var wrapperWidth = wrapperComponent.offsetWidth;
234
224
  var wrapperHeight = wrapperComponent.offsetHeight;
@@ -270,6 +260,22 @@ var calculateBounds = function (contextInstance, newScale) {
270
260
  var bounds = getBounds(wrapperWidth, newContentWidth, newDiffWidth, wrapperHeight, newContentHeight, newDiffHeight, Boolean(centerZoomedOut));
271
261
  return bounds;
272
262
  };
263
+ /**
264
+ * Keeps value between given bounds, used for limiting view to given boundaries
265
+ * 1# eg. boundLimiter(2, 0, 3, true) => 2
266
+ * 2# eg. boundLimiter(4, 0, 3, true) => 3
267
+ * 3# eg. boundLimiter(-2, 0, 3, true) => 0
268
+ * 4# eg. boundLimiter(10, 0, 3, false) => 10
269
+ */
270
+ var boundLimiter = function (value, minBound, maxBound, isActive) {
271
+ if (!isActive)
272
+ return roundNumber(value, 2);
273
+ if (value < minBound)
274
+ return roundNumber(minBound, 2);
275
+ if (value > maxBound)
276
+ return roundNumber(maxBound, 2);
277
+ return roundNumber(value, 2);
278
+ };
273
279
  var handleCalculateBounds = function (contextInstance, newScale) {
274
280
  var bounds = calculateBounds(contextInstance, newScale);
275
281
  // Save bounds
@@ -288,22 +294,6 @@ function getMouseBoundedPosition(positionX, positionY, bounds, limitToBounds, pa
288
294
  var y = boundLimiter(positionY, minPositionY - paddingY, maxPositionY + paddingY, limitToBounds);
289
295
  return { x: x, y: y };
290
296
  }
291
- /**
292
- * Keeps value between given bounds, used for limiting view to given boundaries
293
- * 1# eg. boundLimiter(2, 0, 3, true) => 2
294
- * 2# eg. boundLimiter(4, 0, 3, true) => 3
295
- * 3# eg. boundLimiter(-2, 0, 3, true) => 0
296
- * 4# eg. boundLimiter(10, 0, 3, false) => 10
297
- */
298
- var boundLimiter = function (value, minBound, maxBound, isActive) {
299
- if (!isActive)
300
- return roundNumber(value, 2);
301
- if (value < minBound)
302
- return roundNumber(minBound, 2);
303
- if (value > maxBound)
304
- return roundNumber(maxBound, 2);
305
- return roundNumber(value, 2);
306
- };
307
297
 
308
298
  function handleCalculateZoomPositions(contextInstance, mouseX, mouseY, newScale, bounds, limitToBounds) {
309
299
  var _a = contextInstance.transformState, scale = _a.scale, positionX = _a.positionX, positionY = _a.positionY;
@@ -322,9 +312,9 @@ function handleCalculateZoomPositions(contextInstance, mouseX, mouseY, newScale,
322
312
  function checkZoomBounds(zoom, minScale, maxScale, zoomPadding, enablePadding) {
323
313
  var scalePadding = enablePadding ? zoomPadding : 0;
324
314
  var minScaleWithPadding = minScale - scalePadding;
325
- if (!isNaN(maxScale) && zoom >= maxScale)
315
+ if (!Number.isNaN(maxScale) && zoom >= maxScale)
326
316
  return maxScale;
327
- if (!isNaN(minScale) && zoom <= minScaleWithPadding)
317
+ if (!Number.isNaN(minScale) && zoom <= minScaleWithPadding)
328
318
  return minScaleWithPadding;
329
319
  return zoom;
330
320
  }
@@ -566,6 +556,18 @@ function handlePanningStart(contextInstance, event) {
566
556
  handlePanningSetup(contextInstance, event);
567
557
  }
568
558
  }
559
+ function handleAlignToBounds(contextInstance) {
560
+ var scale = contextInstance.transformState.scale;
561
+ var _a = contextInstance.setup, minScale = _a.minScale, alignmentAnimation = _a.alignmentAnimation;
562
+ var disabled = alignmentAnimation.disabled, sizeX = alignmentAnimation.sizeX, sizeY = alignmentAnimation.sizeY, animationTime = alignmentAnimation.animationTime, animationType = alignmentAnimation.animationType;
563
+ var isDisabled = disabled || scale < minScale || (!sizeX && !sizeY);
564
+ if (isDisabled)
565
+ return;
566
+ var targetState = handlePanToBounds(contextInstance);
567
+ if (targetState) {
568
+ animate(contextInstance, targetState, animationTime, animationType);
569
+ }
570
+ }
569
571
  function handlePanning(contextInstance, clientX, clientY) {
570
572
  var startCoords = contextInstance.startCoords, setup = contextInstance.setup;
571
573
  var _a = setup.alignmentAnimation, sizeX = _a.sizeX, sizeY = _a.sizeY;
@@ -600,19 +602,14 @@ function handlePanningEnd(contextInstance) {
600
602
  }
601
603
  }
602
604
  }
603
- function handleAlignToBounds(contextInstance) {
604
- var scale = contextInstance.transformState.scale;
605
- var _a = contextInstance.setup, minScale = _a.minScale, alignmentAnimation = _a.alignmentAnimation;
606
- var disabled = alignmentAnimation.disabled, sizeX = alignmentAnimation.sizeX, sizeY = alignmentAnimation.sizeY, animationTime = alignmentAnimation.animationTime, animationType = alignmentAnimation.animationType;
607
- var isDisabled = disabled || scale < minScale || (!sizeX && !sizeY);
608
- if (isDisabled)
609
- return;
610
- var targetState = handlePanToBounds(contextInstance);
611
- if (targetState) {
612
- animate(contextInstance, targetState, animationTime, animationType);
613
- }
614
- }
615
605
 
606
+ function handleZoomToPoint(contextInstance, scale, mouseX, mouseY) {
607
+ var _a = contextInstance.setup, minScale = _a.minScale, maxScale = _a.maxScale, limitToBounds = _a.limitToBounds;
608
+ var newScale = checkZoomBounds(roundNumber(scale, 2), minScale, maxScale, 0, false);
609
+ var bounds = handleCalculateBounds(contextInstance, newScale);
610
+ var _b = handleCalculateZoomPositions(contextInstance, mouseX, mouseY, newScale, bounds, limitToBounds), x = _b.x, y = _b.y;
611
+ return { scale: newScale, positionX: x, positionY: y };
612
+ }
616
613
  function handleAlignToScaleBounds(contextInstance, mousePositionX, mousePositionY) {
617
614
  var scale = contextInstance.transformState.scale;
618
615
  var wrapperComponent = contextInstance.wrapperComponent;
@@ -632,13 +629,6 @@ function handleAlignToScaleBounds(contextInstance, mousePositionX, mousePosition
632
629
  animate(contextInstance, targetState, animationTime, animationType);
633
630
  }
634
631
  }
635
- function handleZoomToPoint(contextInstance, scale, mouseX, mouseY) {
636
- var _a = contextInstance.setup, minScale = _a.minScale, maxScale = _a.maxScale, limitToBounds = _a.limitToBounds;
637
- var newScale = checkZoomBounds(roundNumber(scale, 2), minScale, maxScale, 0, false);
638
- var bounds = handleCalculateBounds(contextInstance, newScale);
639
- var _b = handleCalculateZoomPositions(contextInstance, mouseX, mouseY, newScale, bounds, limitToBounds), x = _b.x, y = _b.y;
640
- return { scale: newScale, positionX: x, positionY: y };
641
- }
642
632
 
643
633
  var initialState = {
644
634
  previousScale: 1,
@@ -733,7 +723,7 @@ var createSetup = function (props) {
733
723
  newSetup[key] = __assign(__assign({}, initialSetup[key]), props[key]);
734
724
  }
735
725
  else if (isArray) {
736
- newSetup[key] = __spreadArray(__spreadArray([], initialSetup[key]), props[key]);
726
+ newSetup[key] = __spreadArray(__spreadArray([], initialSetup[key], true), props[key], true);
737
727
  }
738
728
  else {
739
729
  newSetup[key] = props[key];
@@ -792,6 +782,20 @@ function resetTransformations(contextInstance, animationTime, animationType) {
792
782
  }
793
783
  animate(contextInstance, newState, animationTime, animationType);
794
784
  }
785
+ function getOffset(element) {
786
+ var el = element;
787
+ var offsetLeft = 0;
788
+ var offsetTop = 0;
789
+ while (el) {
790
+ offsetLeft += el.offsetLeft;
791
+ offsetTop += el.offsetTop;
792
+ el = el.offsetParent;
793
+ }
794
+ return {
795
+ x: offsetLeft - window.scrollX,
796
+ y: offsetTop - window.scrollY,
797
+ };
798
+ }
795
799
  function calculateZoomToNode(contextInstance, node, customZoom) {
796
800
  var wrapperComponent = contextInstance.wrapperComponent;
797
801
  var _a = contextInstance.setup, limitToBounds = _a.limitToBounds, minScale = _a.minScale, maxScale = _a.maxScale;
@@ -814,88 +818,85 @@ function calculateZoomToNode(contextInstance, node, customZoom) {
814
818
  var _b = getMouseBoundedPosition(newPositionX, newPositionY, bounds, limitToBounds, 0, 0, wrapperComponent), x = _b.x, y = _b.y;
815
819
  return { positionX: x, positionY: y, scale: newScale };
816
820
  }
817
- function getOffset(element) {
818
- var el = element;
819
- var offsetLeft = 0;
820
- var offsetTop = 0;
821
- while (el) {
822
- offsetLeft += el.offsetLeft;
823
- offsetTop += el.offsetTop;
824
- el = el.offsetParent;
825
- }
826
- return {
827
- x: offsetLeft - window.scrollX,
828
- y: offsetTop - window.scrollY,
829
- };
830
- }
831
821
  function isValidZoomNode(node) {
832
822
  if (!node) {
833
823
  console.error("Zoom node not found");
834
824
  return false;
835
825
  }
836
- else if ((node === null || node === void 0 ? void 0 : node.offsetWidth) === undefined ||
837
- (node === null || node === void 0 ? void 0 : node.offsetHeight) === undefined) {
826
+ if ((node === null || node === void 0 ? void 0 : node.offsetWidth) === undefined || (node === null || node === void 0 ? void 0 : node.offsetHeight) === undefined) {
838
827
  console.error("Zoom node is not valid - it must contain offsetWidth and offsetHeight");
839
828
  return false;
840
829
  }
841
830
  return true;
842
831
  }
843
832
 
844
- var zoomIn = function (contextInstance) { return function (step, animationTime, animationType) {
845
- if (step === void 0) { step = 0.5; }
846
- if (animationTime === void 0) { animationTime = 300; }
847
- if (animationType === void 0) { animationType = "easeOut"; }
848
- handleZoomToViewCenter(contextInstance, 1, step, animationTime, animationType);
849
- }; };
850
- var zoomOut = function (contextInstance) { return function (step, animationTime, animationType) {
851
- if (step === void 0) { step = 0.5; }
852
- if (animationTime === void 0) { animationTime = 300; }
853
- if (animationType === void 0) { animationType = "easeOut"; }
854
- handleZoomToViewCenter(contextInstance, -1, step, animationTime, animationType);
855
- }; };
856
- var setTransform = function (contextInstance) { return function (newPositionX, newPositionY, newScale, animationTime, animationType) {
857
- if (animationTime === void 0) { animationTime = 300; }
858
- if (animationType === void 0) { animationType = "easeOut"; }
859
- var _a = contextInstance.transformState, positionX = _a.positionX, positionY = _a.positionY, scale = _a.scale;
860
- var wrapperComponent = contextInstance.wrapperComponent, contentComponent = contextInstance.contentComponent;
861
- var disabled = contextInstance.setup.disabled;
862
- if (disabled || !wrapperComponent || !contentComponent)
863
- return;
864
- var targetState = {
865
- positionX: isNaN(newPositionX) ? positionX : newPositionX,
866
- positionY: isNaN(newPositionY) ? positionY : newPositionY,
867
- scale: isNaN(newScale) ? scale : newScale,
833
+ var zoomIn = 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);
868
839
  };
869
- animate(contextInstance, targetState, animationTime, animationType);
870
- }; };
871
- var resetTransform = function (contextInstance) { return function (animationTime, animationType) {
872
- if (animationTime === void 0) { animationTime = 200; }
873
- if (animationType === void 0) { animationType = "easeOut"; }
874
- resetTransformations(contextInstance, animationTime, animationType);
875
- }; };
876
- var centerView = function (contextInstance) { return function (scale, animationTime, animationType) {
877
- if (animationTime === void 0) { animationTime = 200; }
878
- if (animationType === void 0) { animationType = "easeOut"; }
879
- var transformState = contextInstance.transformState, wrapperComponent = contextInstance.wrapperComponent, contentComponent = contextInstance.contentComponent;
880
- if (wrapperComponent && contentComponent) {
881
- var targetState = getCenterPosition(scale || transformState.scale, wrapperComponent, contentComponent);
882
- animate(contextInstance, targetState, animationTime, animationType);
883
- }
884
- }; };
885
- var zoomToElement = function (contextInstance) { return function (node, scale, animationTime, animationType) {
886
- if (animationTime === void 0) { animationTime = 600; }
887
- if (animationType === void 0) { animationType = "easeOut"; }
888
- handleCancelAnimation(contextInstance);
889
- var wrapperComponent = contextInstance.wrapperComponent;
890
- var target = typeof node === "string" ? document.getElementById(node) : node;
891
- if (wrapperComponent &&
892
- isValidZoomNode(target) &&
893
- target &&
894
- wrapperComponent.contains(target)) {
895
- var targetState = calculateZoomToNode(contextInstance, target, scale);
840
+ };
841
+ var zoomOut = function (contextInstance) {
842
+ 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
+ };
849
+ var setTransform = function (contextInstance) {
850
+ return function (newPositionX, newPositionY, newScale, animationTime, animationType) {
851
+ if (animationTime === void 0) { animationTime = 300; }
852
+ if (animationType === void 0) { animationType = "easeOut"; }
853
+ var _a = contextInstance.transformState, positionX = _a.positionX, positionY = _a.positionY, scale = _a.scale;
854
+ var wrapperComponent = contextInstance.wrapperComponent, contentComponent = contextInstance.contentComponent;
855
+ var disabled = contextInstance.setup.disabled;
856
+ if (disabled || !wrapperComponent || !contentComponent)
857
+ return;
858
+ var targetState = {
859
+ positionX: Number.isNaN(newPositionX) ? positionX : newPositionX,
860
+ positionY: Number.isNaN(newPositionY) ? positionY : newPositionY,
861
+ scale: Number.isNaN(newScale) ? scale : newScale,
862
+ };
896
863
  animate(contextInstance, targetState, animationTime, animationType);
897
- }
898
- }; };
864
+ };
865
+ };
866
+ var resetTransform = function (contextInstance) {
867
+ return function (animationTime, animationType) {
868
+ if (animationTime === void 0) { animationTime = 200; }
869
+ if (animationType === void 0) { animationType = "easeOut"; }
870
+ resetTransformations(contextInstance, animationTime, animationType);
871
+ };
872
+ };
873
+ var centerView = function (contextInstance) {
874
+ return function (scale, animationTime, animationType) {
875
+ if (animationTime === void 0) { animationTime = 200; }
876
+ if (animationType === void 0) { animationType = "easeOut"; }
877
+ var transformState = contextInstance.transformState, wrapperComponent = contextInstance.wrapperComponent, contentComponent = contextInstance.contentComponent;
878
+ if (wrapperComponent && contentComponent) {
879
+ var targetState = getCenterPosition(scale || transformState.scale, wrapperComponent, contentComponent);
880
+ animate(contextInstance, targetState, animationTime, animationType);
881
+ }
882
+ };
883
+ };
884
+ var zoomToElement = function (contextInstance) {
885
+ return function (node, scale, animationTime, animationType) {
886
+ if (animationTime === void 0) { animationTime = 600; }
887
+ if (animationType === void 0) { animationType = "easeOut"; }
888
+ handleCancelAnimation(contextInstance);
889
+ var wrapperComponent = contextInstance.wrapperComponent;
890
+ var target = typeof node === "string" ? document.getElementById(node) : node;
891
+ if (wrapperComponent &&
892
+ isValidZoomNode(target) &&
893
+ target &&
894
+ wrapperComponent.contains(target)) {
895
+ var targetState = calculateZoomToNode(contextInstance, target, scale);
896
+ animate(contextInstance, targetState, animationTime, animationType);
897
+ }
898
+ };
899
+ };
899
900
 
900
901
  var getContext = function (contextInstance) {
901
902
  return {
@@ -959,7 +960,7 @@ var getTransformStyles = function (x, y, scale) {
959
960
  var d = scale;
960
961
  var tx = x;
961
962
  var ty = y;
962
- return "matrix3d(" + a + ", " + b + ", 0, 0, " + c + ", " + d + ", 0, 0, 0, 0, 1, 0, " + tx + ", " + ty + ", 0, 1)";
963
+ return "matrix3d(".concat(a, ", ").concat(b, ", 0, 0, ").concat(c, ", ").concat(d, ", 0, 0, 0, 0, 1, 0, ").concat(tx, ", ").concat(ty, ", 0, 1)");
963
964
  };
964
965
  var getCenterPosition = function (scale, wrapperComponent, contentComponent) {
965
966
  var contentWidth = contentComponent.offsetWidth * scale;
@@ -990,8 +991,14 @@ var isWheelAllowed = function (contextInstance, event) {
990
991
  return false;
991
992
  return true;
992
993
  };
994
+ var getDeltaY = function (event) {
995
+ if (event) {
996
+ return event.deltaY < 0 ? 1 : -1;
997
+ }
998
+ return 0;
999
+ };
993
1000
  function getDelta(event, customDelta) {
994
- var deltaY = event ? (event.deltaY < 0 ? 1 : -1) : 0;
1001
+ var deltaY = getDeltaY(event);
995
1002
  var delta = checkIsNumber(customDelta, deltaY);
996
1003
  return delta;
997
1004
  }
@@ -1009,7 +1016,7 @@ function getMousePosition(event, contentComponent, scale) {
1009
1016
  mouseX = (touch.clientX - contentRect.left) / scale;
1010
1017
  mouseY = (touch.clientY - contentRect.top) / scale;
1011
1018
  }
1012
- if (isNaN(mouseX) || isNaN(mouseY))
1019
+ if (Number.isNaN(mouseX) || Number.isNaN(mouseY))
1013
1020
  console.error("No mouse or touch offset found");
1014
1021
  return {
1015
1022
  x: mouseX,
@@ -1083,8 +1090,8 @@ var calculateTouchMidPoint = function (event, scale, contentComponent) {
1083
1090
  };
1084
1091
  };
1085
1092
  var getTouchDistance = function (event) {
1086
- return Math.sqrt(Math.pow(event.touches[0].pageX - event.touches[1].pageX, 2) +
1087
- Math.pow(event.touches[0].pageY - event.touches[1].pageY, 2));
1093
+ return Math.sqrt(Math.pow((event.touches[0].pageX - event.touches[1].pageX), 2) +
1094
+ Math.pow((event.touches[0].pageY - event.touches[1].pageY), 2));
1088
1095
  };
1089
1096
  var calculatePinchZoom = function (contextInstance, currentDistance) {
1090
1097
  var pinchStartScale = contextInstance.pinchStartScale, pinchStartDistance = contextInstance.pinchStartDistance, setup = contextInstance.setup;
@@ -1180,7 +1187,7 @@ var handlePinchZoom = function (contextInstance, event) {
1180
1187
  return;
1181
1188
  var midPoint = calculateTouchMidPoint(event, scale, contentComponent);
1182
1189
  // if touches goes off of the wrapper element
1183
- if (!isFinite(midPoint.x) || !isFinite(midPoint.y))
1190
+ if (!Number.isFinite(midPoint.x) || !Number.isFinite(midPoint.y))
1184
1191
  return;
1185
1192
  var currentDistance = getTouchDistance(event);
1186
1193
  var newScale = calculatePinchZoom(contextInstance, currentDistance);
@@ -1240,45 +1247,51 @@ var isDoubleClickAllowed = function (contextInstance, event) {
1240
1247
  return true;
1241
1248
  };
1242
1249
 
1243
- var Context = React__default['default'].createContext(contextInitialState);
1244
- var TransformContext = /** @class */ (function (_super) {
1245
- __extends(TransformContext, _super);
1246
- function TransformContext() {
1247
- var _this = _super !== null && _super.apply(this, arguments) || this;
1248
- _this.mounted = true;
1249
- _this.transformState = createState(_this.props);
1250
- _this.setup = createSetup(_this.props);
1250
+ var ZoomPanPinch = /** @class */ (function () {
1251
+ function ZoomPanPinch(props) {
1252
+ var _this = this;
1253
+ this.mounted = true;
1251
1254
  // Components
1252
- _this.wrapperComponent = null;
1253
- _this.contentComponent = null;
1255
+ this.wrapperComponent = null;
1256
+ this.contentComponent = null;
1254
1257
  // Initialization
1255
- _this.isInitialized = false;
1256
- _this.bounds = null;
1258
+ this.isInitialized = false;
1259
+ this.bounds = null;
1257
1260
  // wheel helpers
1258
- _this.previousWheelEvent = null;
1259
- _this.wheelStopEventTimer = null;
1260
- _this.wheelAnimationTimer = null;
1261
+ this.previousWheelEvent = null;
1262
+ this.wheelStopEventTimer = null;
1263
+ this.wheelAnimationTimer = null;
1261
1264
  // panning helpers
1262
- _this.isPanning = false;
1263
- _this.startCoords = null;
1264
- _this.lastTouch = null;
1265
+ this.isPanning = false;
1266
+ this.startCoords = null;
1267
+ this.lastTouch = null;
1265
1268
  // pinch helpers
1266
- _this.distance = null;
1267
- _this.lastDistance = null;
1268
- _this.pinchStartDistance = null;
1269
- _this.pinchStartScale = null;
1270
- _this.pinchMidpoint = null;
1269
+ this.distance = null;
1270
+ this.lastDistance = null;
1271
+ this.pinchStartDistance = null;
1272
+ this.pinchStartScale = null;
1273
+ this.pinchMidpoint = null;
1271
1274
  // velocity helpers
1272
- _this.velocity = null;
1273
- _this.velocityTime = null;
1274
- _this.lastMousePosition = null;
1275
+ this.velocity = null;
1276
+ this.velocityTime = null;
1277
+ this.lastMousePosition = null;
1275
1278
  // animations helpers
1276
- _this.animate = false;
1277
- _this.animation = null;
1278
- _this.maxBounds = null;
1279
+ this.animate = false;
1280
+ this.animation = null;
1281
+ this.maxBounds = null;
1279
1282
  // key press
1280
- _this.pressedKeys = {};
1281
- _this.initializeWindowEvents = function () {
1283
+ this.pressedKeys = {};
1284
+ this.mount = function () {
1285
+ _this.initializeWindowEvents();
1286
+ };
1287
+ this.unmount = function () {
1288
+ _this.cleanupWindowEvents();
1289
+ };
1290
+ this.update = function (newProps) {
1291
+ handleCalculateBounds(_this, _this.transformState.scale);
1292
+ _this.setup = createSetup(newProps);
1293
+ };
1294
+ this.initializeWindowEvents = function () {
1282
1295
  var _a;
1283
1296
  var passive = makePassiveEventOption();
1284
1297
  var currentDocument = (_a = _this.wrapperComponent) === null || _a === void 0 ? void 0 : _a.ownerDocument;
@@ -1290,10 +1303,9 @@ var TransformContext = /** @class */ (function (_super) {
1290
1303
  currentDocument === null || currentDocument === void 0 ? void 0 : currentDocument.addEventListener("mouseleave", _this.clearPanning, passive);
1291
1304
  currentWindow === null || currentWindow === void 0 ? void 0 : currentWindow.addEventListener("keyup", _this.setKeyUnPressed, passive);
1292
1305
  currentWindow === null || currentWindow === void 0 ? void 0 : currentWindow.addEventListener("keydown", _this.setKeyPressed, passive);
1293
- _this.handleRef();
1294
1306
  };
1295
- _this.cleanupWindowEvents = function () {
1296
- var _a;
1307
+ this.cleanupWindowEvents = function () {
1308
+ var _a, _b;
1297
1309
  var passive = makePassiveEventOption();
1298
1310
  var currentDocument = (_a = _this.wrapperComponent) === null || _a === void 0 ? void 0 : _a.ownerDocument;
1299
1311
  var currentWindow = currentDocument === null || currentDocument === void 0 ? void 0 : currentDocument.defaultView;
@@ -1305,8 +1317,9 @@ var TransformContext = /** @class */ (function (_super) {
1305
1317
  currentWindow === null || currentWindow === void 0 ? void 0 : currentWindow.removeEventListener("keydown", _this.setKeyPressed, passive);
1306
1318
  document.removeEventListener("mouseleave", _this.clearPanning, passive);
1307
1319
  handleCancelAnimation(_this);
1320
+ (_b = _this.observer) === null || _b === void 0 ? void 0 : _b.disconnect();
1308
1321
  };
1309
- _this.handleInitializeWrapperEvents = function (wrapper) {
1322
+ this.handleInitializeWrapperEvents = function (wrapper) {
1310
1323
  // Zooming events on wrapper
1311
1324
  var passive = makePassiveEventOption();
1312
1325
  wrapper.addEventListener("wheel", _this.onWheelZoom, passive);
@@ -1315,34 +1328,24 @@ var TransformContext = /** @class */ (function (_super) {
1315
1328
  wrapper.addEventListener("touchmove", _this.onTouchPanning, passive);
1316
1329
  wrapper.addEventListener("touchend", _this.onTouchPanningStop, passive);
1317
1330
  };
1318
- _this.handleInitialize = function () {
1331
+ this.handleInitialize = function (contentComponent) {
1319
1332
  var centerOnInit = _this.setup.centerOnInit;
1320
1333
  _this.applyTransformation();
1321
- _this.forceUpdate();
1322
1334
  if (centerOnInit) {
1323
- // this has to be redone once the right solution is found
1324
- // problem is - we need to execute it after mounted component specify it's height / width, images are fetched async so it's tricky
1325
- setTimeout(function () {
1326
- if (_this.mounted) {
1327
- _this.setCenter();
1328
- }
1329
- }, 50);
1330
- setTimeout(function () {
1331
- if (_this.mounted) {
1332
- _this.setCenter();
1333
- }
1334
- }, 100);
1335
- setTimeout(function () {
1336
- if (_this.mounted) {
1337
- _this.setCenter();
1338
- }
1339
- }, 200);
1335
+ _this.setCenter();
1336
+ _this.observer = new ResizeObserver(function () {
1337
+ var _a;
1338
+ _this.setCenter();
1339
+ (_a = _this.observer) === null || _a === void 0 ? void 0 : _a.disconnect();
1340
+ });
1341
+ // Start observing the target node for configured mutations
1342
+ _this.observer.observe(contentComponent);
1340
1343
  }
1341
1344
  };
1342
- //////////
1345
+ /// ///////
1343
1346
  // Zoom
1344
- //////////
1345
- _this.onWheelZoom = function (event) {
1347
+ /// ///////
1348
+ this.onWheelZoom = function (event) {
1346
1349
  var disabled = _this.setup.disabled;
1347
1350
  if (disabled)
1348
1351
  return;
@@ -1356,10 +1359,10 @@ var TransformContext = /** @class */ (function (_super) {
1356
1359
  handleWheelZoom(_this, event);
1357
1360
  handleWheelStop(_this, event);
1358
1361
  };
1359
- //////////
1362
+ /// ///////
1360
1363
  // Pan
1361
- //////////
1362
- _this.onPanningStart = function (event) {
1364
+ /// ///////
1365
+ this.onPanningStart = function (event) {
1363
1366
  var disabled = _this.setup.disabled;
1364
1367
  var onPanningStart = _this.props.onPanningStart;
1365
1368
  if (disabled)
@@ -1376,7 +1379,7 @@ var TransformContext = /** @class */ (function (_super) {
1376
1379
  handlePanningStart(_this, event);
1377
1380
  handleCallback(getContext(_this), event, onPanningStart);
1378
1381
  };
1379
- _this.onPanning = function (event) {
1382
+ this.onPanning = function (event) {
1380
1383
  var disabled = _this.setup.disabled;
1381
1384
  var onPanning = _this.props.onPanning;
1382
1385
  if (disabled)
@@ -1392,17 +1395,17 @@ var TransformContext = /** @class */ (function (_super) {
1392
1395
  handlePanning(_this, event.clientX, event.clientY);
1393
1396
  handleCallback(getContext(_this), event, onPanning);
1394
1397
  };
1395
- _this.onPanningStop = function (event) {
1398
+ this.onPanningStop = function (event) {
1396
1399
  var onPanningStop = _this.props.onPanningStop;
1397
1400
  if (_this.isPanning) {
1398
1401
  handlePanningEnd(_this);
1399
1402
  handleCallback(getContext(_this), event, onPanningStop);
1400
1403
  }
1401
1404
  };
1402
- //////////
1405
+ /// ///////
1403
1406
  // Pinch
1404
- //////////
1405
- _this.onPinchStart = function (event) {
1407
+ /// ///////
1408
+ this.onPinchStart = function (event) {
1406
1409
  var disabled = _this.setup.disabled;
1407
1410
  var _a = _this.props, onPinchingStart = _a.onPinchingStart, onZoomStart = _a.onZoomStart;
1408
1411
  if (disabled)
@@ -1415,7 +1418,7 @@ var TransformContext = /** @class */ (function (_super) {
1415
1418
  handleCallback(getContext(_this), event, onPinchingStart);
1416
1419
  handleCallback(getContext(_this), event, onZoomStart);
1417
1420
  };
1418
- _this.onPinch = function (event) {
1421
+ this.onPinch = function (event) {
1419
1422
  var disabled = _this.setup.disabled;
1420
1423
  var _a = _this.props, onPinching = _a.onPinching, onZoom = _a.onZoom;
1421
1424
  if (disabled)
@@ -1429,7 +1432,7 @@ var TransformContext = /** @class */ (function (_super) {
1429
1432
  handleCallback(getContext(_this), event, onPinching);
1430
1433
  handleCallback(getContext(_this), event, onZoom);
1431
1434
  };
1432
- _this.onPinchStop = function (event) {
1435
+ this.onPinchStop = function (event) {
1433
1436
  var _a = _this.props, onPinchingStop = _a.onPinchingStop, onZoomStop = _a.onZoomStop;
1434
1437
  if (_this.pinchStartScale) {
1435
1438
  handlePinchStop(_this);
@@ -1437,10 +1440,10 @@ var TransformContext = /** @class */ (function (_super) {
1437
1440
  handleCallback(getContext(_this), event, onZoomStop);
1438
1441
  }
1439
1442
  };
1440
- //////////
1443
+ /// ///////
1441
1444
  // Touch
1442
- //////////
1443
- _this.onTouchPanningStart = function (event) {
1445
+ /// ///////
1446
+ this.onTouchPanningStart = function (event) {
1444
1447
  var disabled = _this.setup.disabled;
1445
1448
  var onPanningStart = _this.props.onPanningStart;
1446
1449
  if (disabled)
@@ -1468,7 +1471,7 @@ var TransformContext = /** @class */ (function (_super) {
1468
1471
  }
1469
1472
  }
1470
1473
  };
1471
- _this.onTouchPanning = function (event) {
1474
+ this.onTouchPanning = function (event) {
1472
1475
  var disabled = _this.setup.disabled;
1473
1476
  var onPanning = _this.props.onPanning;
1474
1477
  if (_this.isPanning && event.touches.length === 1) {
@@ -1487,14 +1490,14 @@ var TransformContext = /** @class */ (function (_super) {
1487
1490
  _this.onPinch(event);
1488
1491
  }
1489
1492
  };
1490
- _this.onTouchPanningStop = function (event) {
1493
+ this.onTouchPanningStop = function (event) {
1491
1494
  _this.onPanningStop(event);
1492
1495
  _this.onPinchStop(event);
1493
1496
  };
1494
- //////////
1497
+ /// ///////
1495
1498
  // Double Click
1496
- //////////
1497
- _this.onDoubleClick = function (event) {
1499
+ /// ///////
1500
+ this.onDoubleClick = function (event) {
1498
1501
  var disabled = _this.setup.disabled;
1499
1502
  if (disabled)
1500
1503
  return;
@@ -1503,41 +1506,31 @@ var TransformContext = /** @class */ (function (_super) {
1503
1506
  return;
1504
1507
  handleDoubleClick(_this, event);
1505
1508
  };
1506
- //////////
1509
+ /// ///////
1507
1510
  // Helpers
1508
- //////////
1509
- _this.clearPanning = function (event) {
1511
+ /// ///////
1512
+ this.clearPanning = function (event) {
1510
1513
  if (_this.isPanning) {
1511
1514
  _this.onPanningStop(event);
1512
1515
  }
1513
1516
  };
1514
- _this.setKeyPressed = function (e) {
1517
+ this.setKeyPressed = function (e) {
1515
1518
  _this.pressedKeys[e.key] = true;
1516
1519
  };
1517
- _this.setKeyUnPressed = function (e) {
1520
+ this.setKeyUnPressed = function (e) {
1518
1521
  _this.pressedKeys[e.key] = false;
1519
1522
  };
1520
- _this.isPressingKeys = function (keys) {
1523
+ this.isPressingKeys = function (keys) {
1521
1524
  if (!keys.length) {
1522
1525
  return true;
1523
1526
  }
1524
1527
  return Boolean(keys.find(function (key) { return _this.pressedKeys[key]; }));
1525
1528
  };
1526
- _this.setComponents = function (wrapperComponent, contentComponent) {
1527
- _this.cleanupWindowEvents();
1528
- _this.wrapperComponent = wrapperComponent;
1529
- _this.contentComponent = contentComponent;
1530
- handleCalculateBounds(_this, _this.transformState.scale);
1531
- _this.handleInitializeWrapperEvents(wrapperComponent);
1532
- _this.initializeWindowEvents();
1533
- _this.handleInitialize();
1534
- _this.handleRef();
1535
- _this.isInitialized = true;
1536
- handleCallback(getContext(_this), undefined, _this.props.onInit);
1537
- };
1538
- _this.setTransformState = function (scale, positionX, positionY) {
1529
+ this.setTransformState = function (scale, positionX, positionY) {
1539
1530
  var onTransformed = _this.props.onTransformed;
1540
- if (!isNaN(scale) && !isNaN(positionX) && !isNaN(positionY)) {
1531
+ if (!Number.isNaN(scale) &&
1532
+ !Number.isNaN(positionX) &&
1533
+ !Number.isNaN(positionY)) {
1541
1534
  if (scale !== _this.transformState.scale) {
1542
1535
  _this.transformState.previousScale = _this.transformState.scale;
1543
1536
  _this.transformState.scale = scale;
@@ -1551,50 +1544,62 @@ var TransformContext = /** @class */ (function (_super) {
1551
1544
  console.error("Detected NaN set state values");
1552
1545
  }
1553
1546
  };
1554
- _this.setCenter = function () {
1547
+ this.setCenter = function () {
1555
1548
  if (_this.wrapperComponent && _this.contentComponent) {
1556
1549
  var targetState = getCenterPosition(_this.transformState.scale, _this.wrapperComponent, _this.contentComponent);
1557
1550
  _this.setTransformState(targetState.scale, targetState.positionX, targetState.positionY);
1558
1551
  }
1559
1552
  };
1560
- _this.applyTransformation = function () {
1553
+ this.applyTransformation = function () {
1561
1554
  if (!_this.mounted || !_this.contentComponent)
1562
1555
  return;
1563
1556
  var _a = _this.transformState, scale = _a.scale, positionX = _a.positionX, positionY = _a.positionY;
1564
1557
  var transform = getTransformStyles(positionX, positionY, scale);
1565
1558
  _this.contentComponent.style.transform = transform;
1566
- _this.handleRef();
1567
1559
  };
1568
- _this.handleRef = function () {
1569
- _this.props.setRef(getContext(_this));
1560
+ this.getContext = function () {
1561
+ return getContext(_this);
1570
1562
  };
1571
- return _this;
1563
+ /**
1564
+ * Initialization
1565
+ */
1566
+ this.init = function (wrapperComponent, contentComponent) {
1567
+ _this.cleanupWindowEvents();
1568
+ _this.wrapperComponent = wrapperComponent;
1569
+ _this.contentComponent = contentComponent;
1570
+ handleCalculateBounds(_this, _this.transformState.scale);
1571
+ _this.handleInitializeWrapperEvents(wrapperComponent);
1572
+ _this.handleInitialize(contentComponent);
1573
+ _this.initializeWindowEvents();
1574
+ _this.isInitialized = true;
1575
+ handleCallback(getContext(_this), undefined, _this.props.onInit);
1576
+ };
1577
+ this.props = props;
1578
+ this.setup = createSetup(this.props);
1579
+ this.transformState = createState(this.props);
1572
1580
  }
1573
- TransformContext.prototype.componentDidMount = function () {
1574
- this.initializeWindowEvents();
1575
- };
1576
- TransformContext.prototype.componentWillUnmount = function () {
1577
- this.cleanupWindowEvents();
1578
- };
1579
- TransformContext.prototype.componentDidUpdate = function (oldProps) {
1580
- if (oldProps !== this.props) {
1581
- handleCalculateBounds(this, this.transformState.scale);
1582
- this.setup = createSetup(this.props);
1583
- }
1584
- };
1585
- TransformContext.prototype.render = function () {
1586
- var value = getContext(this);
1587
- var children = this.props.children;
1588
- var content = typeof children === "function" ? children(value) : children;
1589
- return (React__default['default'].createElement(Context.Provider, { value: __assign(__assign({}, this.transformState), { setComponents: this.setComponents, contextInstance: this }) }, content));
1590
- };
1591
- return TransformContext;
1592
- }(React.Component));
1581
+ return ZoomPanPinch;
1582
+ }());
1593
1583
 
1594
- var TransformWrapper = React__default['default'].forwardRef(function (props, ref) {
1595
- var _a = React.useState(null), innerRef = _a[0], setRef = _a[1];
1596
- React.useImperativeHandle(ref, function () { return innerRef; }, [innerRef]);
1597
- return React__default['default'].createElement(TransformContext, __assign({}, props, { setRef: setRef }));
1584
+ var Context = React__default["default"].createContext(contextInitialState);
1585
+ var TransformWrapper = React__default["default"].forwardRef(function (props, ref) {
1586
+ var children = props.children;
1587
+ var instance = React.useRef(new ZoomPanPinch(props)).current;
1588
+ var content = React.useMemo(function () {
1589
+ if (typeof children === "function") {
1590
+ return children(getContext(instance));
1591
+ }
1592
+ return children;
1593
+ }, [children, instance]);
1594
+ var value = React.useMemo(function () {
1595
+ return __assign(__assign({}, instance.transformState), { setComponents: instance.init, contextInstance: instance });
1596
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1597
+ }, [JSON.stringify(instance.transformState)]);
1598
+ React.useImperativeHandle(ref, function () { return getContext(instance); }, [instance]);
1599
+ React.useEffect(function () {
1600
+ instance.update(props);
1601
+ }, [instance, props]);
1602
+ return React__default["default"].createElement(Context.Provider, { value: value }, content);
1598
1603
  });
1599
1604
 
1600
1605
  function styleInject(css, ref) {
@@ -1624,10 +1629,11 @@ function styleInject(css, ref) {
1624
1629
  }
1625
1630
  }
1626
1631
 
1627
- 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";
1628
- var styles = {"wrapper":"transform-component-module_wrapper__1_Fgj","content":"transform-component-module_content__2jYgh"};
1632
+ 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";
1633
+ var styles = {"wrapper":"transform-component-module_wrapper__7HFJe","content":"transform-component-module_content__uCDPE"};
1629
1634
  styleInject(css_248z);
1630
1635
 
1636
+ /* eslint-disable react/require-default-props */
1631
1637
  var TransformComponent = function (_a) {
1632
1638
  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;
1633
1639
  var setComponents = React.useContext(Context).setComponents;
@@ -1640,8 +1646,8 @@ var TransformComponent = function (_a) {
1640
1646
  setComponents(wrapper, content);
1641
1647
  }
1642
1648
  }, []);
1643
- return (React__default['default'].createElement("div", { ref: wrapperRef, className: "react-transform-wrapper " + styles.wrapper + " " + wrapperClass, style: wrapperStyle },
1644
- React__default['default'].createElement("div", { ref: contentRef, className: "react-transform-component " + styles.content + " " + contentClass, style: contentStyle }, children)));
1649
+ return (React__default["default"].createElement("div", { ref: wrapperRef, className: "react-transform-wrapper ".concat(styles.wrapper, " ").concat(wrapperClass), style: wrapperStyle },
1650
+ React__default["default"].createElement("div", { ref: contentRef, className: "react-transform-component ".concat(styles.content, " ").concat(contentClass), style: contentStyle }, children)));
1645
1651
  };
1646
1652
 
1647
1653
  var useTransformContext = function () {