react-zoom-pan-pinch 4.0.2 → 4.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -290,7 +290,7 @@ function getMouseBoundedPosition(positionX, positionY, bounds, limitToBounds, pa
290
290
  function handleCalculateZoomPositions(contextInstance, mouseX, mouseY, newScale, bounds, limitToBounds) {
291
291
  var _a = contextInstance.state, scale = _a.scale, positionX = _a.positionX, positionY = _a.positionY;
292
292
  var scaleDifference = newScale - scale;
293
- if (typeof mouseX !== "number" || typeof mouseY !== "number") {
293
+ if (!Number.isFinite(mouseX) || !Number.isFinite(mouseY)) {
294
294
  console.error("Mouse X and Y position were not provided!");
295
295
  return { x: positionX, y: positionY };
296
296
  }
@@ -1247,8 +1247,10 @@ function getMousePosition(event, contentComponent, scale) {
1247
1247
  mouseX = (touch.clientX - contentRect.left) / scale;
1248
1248
  mouseY = (touch.clientY - contentRect.top) / scale;
1249
1249
  }
1250
- if (Number.isNaN(mouseX) || Number.isNaN(mouseY))
1250
+ if (Number.isNaN(mouseX) || Number.isNaN(mouseY)) {
1251
1251
  console.error("No mouse or touch offset found");
1252
+ return { x: 0, y: 0 };
1253
+ }
1252
1254
  return {
1253
1255
  x: mouseX,
1254
1256
  y: mouseY,
@@ -1364,7 +1366,9 @@ var handleWheelZoom = function (contextInstance, event) {
1364
1366
  if (!contentComponent) {
1365
1367
  throw new Error("Component not mounted");
1366
1368
  }
1367
- event.preventDefault();
1369
+ if (event.cancelable) {
1370
+ event.preventDefault();
1371
+ }
1368
1372
  event.stopPropagation();
1369
1373
  var delta = getDelta(event, null);
1370
1374
  var zoomStep = smooth ? step * Math.abs(event.deltaY) : step;
@@ -1734,7 +1738,9 @@ var ZoomPanPinch = /** @class */ (function () {
1734
1738
  var isAllowed = isWheelPanningAllowed(_this, event);
1735
1739
  if (!isAllowed)
1736
1740
  return;
1737
- event.preventDefault();
1741
+ if (event.cancelable) {
1742
+ event.preventDefault();
1743
+ }
1738
1744
  event.stopPropagation();
1739
1745
  var _a = _this.state, positionX = _a.positionX, positionY = _a.positionY;
1740
1746
  var mouseX = positionX - event.deltaX;
@@ -1772,7 +1778,9 @@ var ZoomPanPinch = /** @class */ (function () {
1772
1778
  return;
1773
1779
  if (event.button === 2 && !_this.setup.panning.allowRightClickPan)
1774
1780
  return;
1775
- event.preventDefault();
1781
+ if (event.cancelable) {
1782
+ event.preventDefault();
1783
+ }
1776
1784
  event.stopPropagation();
1777
1785
  handleCancelAnimation(_this);
1778
1786
  handlePanningStart(_this, event);
@@ -1796,7 +1804,9 @@ var ZoomPanPinch = /** @class */ (function () {
1796
1804
  var keysPressed = _this.isPressingKeys(_this.setup.panning.activationKeys);
1797
1805
  if (!keysPressed)
1798
1806
  return;
1799
- event.preventDefault();
1807
+ if (event.cancelable) {
1808
+ event.preventDefault();
1809
+ }
1800
1810
  event.stopPropagation();
1801
1811
  handlePanning(_this, event.clientX, event.clientY, DeviceType.MOUSE);
1802
1812
  handleCallback(getContext(_this), event, onPanning);
@@ -1832,7 +1842,9 @@ var ZoomPanPinch = /** @class */ (function () {
1832
1842
  var isAllowed = isPinchAllowed(_this);
1833
1843
  if (!isAllowed)
1834
1844
  return;
1835
- event.preventDefault();
1845
+ if (event.cancelable) {
1846
+ event.preventDefault();
1847
+ }
1836
1848
  event.stopPropagation();
1837
1849
  handlePinchZoom(_this, event);
1838
1850
  handleCallback(getContext(_this), event, onPinch);