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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-zoom-pan-pinch",
3
- "version": "4.0.2",
3
+ "version": "4.0.4",
4
4
  "packageManager": "yarn@4.9.2",
5
5
  "description": "Zoom and pan html elements in easy way.",
6
6
  "author": "prc5",
@@ -16,7 +16,7 @@
16
16
  ],
17
17
  "scripts": {
18
18
  "build": "rollup -c",
19
- "build:docs": "STORYBOOK_BASE=/react-zoom-pan-pinch/ storybook build",
19
+ "build:docs": "STORYBOOK_BASE=/react-zoom-pan-pinch/ storybook build && touch storybook-static/.nojekyll",
20
20
  "start": "cross-env DISABLE_ESLINT_PLUGIN=true yarn storybook dev -p 6006",
21
21
  "test": "jest",
22
22
  "test:debug": "jest-preview",
@@ -24,7 +24,7 @@
24
24
  "format": "prettier --write .",
25
25
  "typecheck": "tsc --noEmit --emitDeclarationOnly false",
26
26
  "predeploy": "yarn run build:docs",
27
- "deploy": "gh-pages -d storybook-static",
27
+ "deploy": "gh-pages -t -d storybook-static",
28
28
  "release": "yarn semantic-release",
29
29
  "storybook": "storybook dev -p 6006",
30
30
  "storybook:build": "storybook build"
@@ -40,12 +40,12 @@
40
40
  "@commitlint/config-conventional": "^18.4.4",
41
41
  "@rollup/plugin-babel": "^6.0.4",
42
42
  "@rollup/plugin-typescript": "^11.1.6",
43
- "@semantic-release/changelog": "^6.0.3",
44
- "@semantic-release/commit-analyzer": "^11.1.0",
45
- "@semantic-release/git": "^10.0.1",
46
- "@semantic-release/github": "^9.2.6",
47
- "@semantic-release/npm": "^11.0.2",
48
- "@semantic-release/release-notes-generator": "^12.1.0",
43
+ "@semantic-release/changelog": "^7",
44
+ "@semantic-release/commit-analyzer": "^13",
45
+ "@semantic-release/git": "^11",
46
+ "@semantic-release/github": "^12",
47
+ "@semantic-release/npm": "^13",
48
+ "@semantic-release/release-notes-generator": "^14",
49
49
  "@storybook/addon-a11y": "7.6.9",
50
50
  "@storybook/addon-actions": "7.6.9",
51
51
  "@storybook/addon-docs": "7.6.9",
@@ -100,7 +100,7 @@
100
100
  "rollup-plugin-dts": "^6.1.0",
101
101
  "rollup-plugin-peer-deps-external": "^2.2.4",
102
102
  "rollup-plugin-postcss": "^4.0.2",
103
- "semantic-release": "^19.0.5",
103
+ "semantic-release": "^25",
104
104
  "storybook": "^7.6.9",
105
105
  "ts-jest": "^29.1.1",
106
106
  "ts-loader": "^9.5.1",
@@ -121,7 +121,7 @@
121
121
  },
122
122
  "repository": {
123
123
  "type": "git",
124
- "url": "https://github.com/prc5/react-zoom-pan-pinch.git"
124
+ "url": "https://github.com/BetterTyped/react-zoom-pan-pinch.git"
125
125
  },
126
126
  "eslintConfig": {
127
127
  "extends": [
@@ -276,7 +276,9 @@ export class ZoomPanPinch {
276
276
 
277
277
  if (!isAllowed) return;
278
278
 
279
- event.preventDefault();
279
+ if (event.cancelable) {
280
+ event.preventDefault();
281
+ }
280
282
  event.stopPropagation();
281
283
 
282
284
  const { positionX, positionY } = this.state;
@@ -324,7 +326,9 @@ export class ZoomPanPinch {
324
326
  if (event.button === 1 && !this.setup.panning.allowMiddleClickPan) return;
325
327
  if (event.button === 2 && !this.setup.panning.allowRightClickPan) return;
326
328
 
327
- event.preventDefault();
329
+ if (event.cancelable) {
330
+ event.preventDefault();
331
+ }
328
332
  event.stopPropagation();
329
333
 
330
334
  handleCancelAnimation(this);
@@ -353,7 +357,9 @@ export class ZoomPanPinch {
353
357
  const keysPressed = this.isPressingKeys(this.setup.panning.activationKeys);
354
358
  if (!keysPressed) return;
355
359
 
356
- event.preventDefault();
360
+ if (event.cancelable) {
361
+ event.preventDefault();
362
+ }
357
363
  event.stopPropagation();
358
364
 
359
365
  handlePanning(this, event.clientX, event.clientY, DeviceType.MOUSE);
@@ -397,7 +403,9 @@ export class ZoomPanPinch {
397
403
  const isAllowed = isPinchAllowed(this);
398
404
  if (!isAllowed) return;
399
405
 
400
- event.preventDefault();
406
+ if (event.cancelable) {
407
+ event.preventDefault();
408
+ }
401
409
  event.stopPropagation();
402
410
 
403
411
  handlePinchZoom(this, event);
@@ -53,7 +53,9 @@ export const handleWheelZoom = (
53
53
  throw new Error("Component not mounted");
54
54
  }
55
55
 
56
- event.preventDefault();
56
+ if (event.cancelable) {
57
+ event.preventDefault();
58
+ }
57
59
  event.stopPropagation();
58
60
 
59
61
  const delta = getDelta(event, null);
@@ -96,8 +96,10 @@ export function getMousePosition(
96
96
  mouseY = (touch.clientY - contentRect.top) / scale;
97
97
  }
98
98
 
99
- if (Number.isNaN(mouseX) || Number.isNaN(mouseY))
99
+ if (Number.isNaN(mouseX) || Number.isNaN(mouseY)) {
100
100
  console.error("No mouse or touch offset found");
101
+ return { x: 0, y: 0 };
102
+ }
101
103
 
102
104
  return {
103
105
  x: mouseX,
@@ -17,7 +17,7 @@ export function handleCalculateZoomPositions(
17
17
 
18
18
  const scaleDifference = newScale - scale;
19
19
 
20
- if (typeof mouseX !== "number" || typeof mouseY !== "number") {
20
+ if (!Number.isFinite(mouseX) || !Number.isFinite(mouseY)) {
21
21
  console.error("Mouse X and Y position were not provided!");
22
22
  return { x: positionX, y: positionY };
23
23
  }