Web Dev Solutions

Catalin Mititiuc

aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--package-lock.json9
-rw-r--r--package.json6
-rw-r--r--src/modules/panzoom.js16
3 files changed, 12 insertions, 19 deletions
diff --git a/package-lock.json b/package-lock.json
index c1865e4..bbd028a 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -5,7 +5,7 @@
"packages": {
"": {
"dependencies": {
- "svg-pan-zoom": "github:webdevcat-me/svg-pan-zoom"
+ "pan-zoom": "github:webdevcat-me/pan-zoom"
},
"devDependencies": {
"esbuild": "^0.20.2",
@@ -3042,6 +3042,10 @@
"integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==",
"dev": true
},
+ "node_modules/pan-zoom": {
+ "version": "0.1.0",
+ "resolved": "git+ssh://git@github.com/webdevcat-me/pan-zoom.git#2d3fc1cd22ffcc61ec178eeaf97f3a4d7cba98bf"
+ },
"node_modules/parse-json": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz",
@@ -3486,9 +3490,6 @@
"url": "https://github.com/sponsors/ljharb"
}
},
- "node_modules/svg-pan-zoom": {
- "resolved": "git+ssh://git@github.com/webdevcat-me/svg-pan-zoom.git#e7c191a78d583029192776f90833b8346f0227ff"
- },
"node_modules/test-exclude": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz",
diff --git a/package.json b/package.json
index 10700e4..f437438 100644
--- a/package.json
+++ b/package.json
@@ -1,5 +1,8 @@
{
"type": "module",
+ "dependencies": {
+ "pan-zoom": "github:webdevcat-me/pan-zoom"
+ },
"devDependencies": {
"esbuild": "^0.20.2",
"esbuild-server": "^0.3.0",
@@ -10,8 +13,5 @@
"start": "node dev-server.cjs",
"test:integ": "jest --config jest.config.integ.cjs",
"test": "jest"
- },
- "dependencies": {
- "svg-pan-zoom": "github:webdevcat-me/svg-pan-zoom"
}
}
diff --git a/src/modules/panzoom.js b/src/modules/panzoom.js
index 38b6b08..ae95171 100644
--- a/src/modules/panzoom.js
+++ b/src/modules/panzoom.js
@@ -1,7 +1,8 @@
-import { pan, zoom } from 'svg-pan-zoom';
+import { pan, zoom } from 'pan-zoom';
export default class PanZoom {
#storageKey = 'pan-zoom';
+ #zoomFactor = 0.25;
constructor(svg) {
this.#restorePanZoomVal(svg);
@@ -29,16 +30,7 @@ export default class PanZoom {
}
#addEventListeners(svg) {
- svg.addEventListener('wheel', e => {
- e.preventDefault();
-
- zoom(svg, e);
- }, { passive: false });
-
- svg.addEventListener('pointerdown', e => {
- e.preventDefault();
-
- pan(svg, e);
- }, { passive: false });
+ svg.addEventListener('wheel', e => zoom(svg, e, this.#zoomFactor), { passive: false });
+ svg.addEventListener('pointerdown', e => pan(svg, e), { passive: false });
}
};