react-zoom-pan-pinch 4.0.3 → 4.0.5
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/README.md +60 -32
- package/dist/index.cjs.js +19 -7
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +19 -7
- package/dist/index.esm.js.map +1 -1
- package/package.json +9 -9
- package/src/core/instance.core.ts +12 -4
- package/src/core/wheel/wheel.logic.ts +3 -1
- package/src/core/wheel/wheel.utils.ts +3 -1
- package/src/core/zoom/zoom.utils.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-zoom-pan-pinch",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.5",
|
|
4
4
|
"packageManager": "yarn@4.9.2",
|
|
5
5
|
"description": "Zoom and pan html elements in easy way.",
|
|
6
6
|
"author": "prc5",
|
|
@@ -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": "^
|
|
44
|
-
"@semantic-release/commit-analyzer": "^
|
|
45
|
-
"@semantic-release/git": "^
|
|
46
|
-
"@semantic-release/github": "^
|
|
47
|
-
"@semantic-release/npm": "^
|
|
48
|
-
"@semantic-release/release-notes-generator": "^
|
|
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": "^
|
|
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/
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
406
|
+
if (event.cancelable) {
|
|
407
|
+
event.preventDefault();
|
|
408
|
+
}
|
|
401
409
|
event.stopPropagation();
|
|
402
410
|
|
|
403
411
|
handlePinchZoom(this, event);
|
|
@@ -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 (
|
|
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
|
}
|