Web Dev Solutions

Catalin Mititiuc

aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCatalin Mititiuc <webdevcat@proton.me>2025-03-18 13:43:26 -0700
committerCatalin Mititiuc <webdevcat@proton.me>2025-03-18 13:47:07 -0700
commit25eca15a3007c76c4e444b859683feb29edfa183 (patch)
treed0a867be54ab95f5e138cec9df662fa0ba450544 /src/modules/pan.js
parent99d137cc0937c0342fc1076eafe609c8aa370087 (diff)
WIP: translate an object to zoomed position without scalingcm-pan-not-zoom
Diffstat (limited to 'src/modules/pan.js')
-rw-r--r--src/modules/pan.js6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/modules/pan.js b/src/modules/pan.js
index bf842bd..8be3cb9 100644
--- a/src/modules/pan.js
+++ b/src/modules/pan.js
@@ -1,4 +1,4 @@
-import { default as getComputedTransformMatrix } from './utils';
+import { default as getComputedTransformMatrix, track, getTracked } from './utils';
const minDistanceThreshold = 5;
@@ -41,9 +41,13 @@ function setTransform(el, computedMtx, startPt, endPt) {
const translateMtx = getTranslateMatrix(startPt, endPt);
const transformMtx = computedMtx.multiply(translateMtx);
+ groups.forEach(([z, p]) => track(z, p, transformMtx));
+
el.style.transform = transformMtx;
}
+const groups = getTracked(document.querySelectorAll('svg g[class] use'));
+
export function programmaticPan(el, from, to) {
const matrices = getTransformMatrices(el);
const startPt = clientToSvgPt(from, matrices.inverseScreen);