index : btroops | |
Virtual board game-aid for BattleTroops, an infantry combat simulator wargame published by FASA in 1989. |
aboutsummaryrefslogtreecommitdiff |
diff options
author | Catalin Mititiuc <webdevcat@proton.me> | 2024-04-27 15:58:11 -0700 |
---|---|---|
committer | Catalin Mititiuc <webdevcat@proton.me> | 2024-04-27 15:58:11 -0700 |
commit | ce98e325656b8419b80d8c248e0469f3a9708322 (patch) | |
tree | 293c5e23601195be80161912275277554fcfb07e /src/modules/panzoom.js | |
parent | 75a0c37ea5e5a9fa395690984c373536e8efccfa (diff) |
Rename some files
Diffstat (limited to 'src/modules/panzoom.js')
-rw-r--r-- | src/modules/panzoom.js | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/src/modules/panzoom.js b/src/modules/panzoom.js deleted file mode 100644 index 86f6727..0000000 --- a/src/modules/panzoom.js +++ /dev/null @@ -1,33 +0,0 @@ -import { pan, zoom } from 'pan-zoom'; - -const storageKey = 'pan-zoom', - zoomFactor = 0.25; - -function restorePanZoomVal(svg) { - const storedPanZoomVal = localStorage.getItem(storageKey); - - if (storedPanZoomVal) { - svg.style.transform = storedPanZoomVal; - } -} - -function addEventListeners(svg) { - svg.addEventListener('wheel', e => zoom(svg, e, zoomFactor), { passive: false }); - svg.addEventListener('pointerdown', e => pan(svg, e), { passive: false }); -} - -function storePanZoomVal(transformMatrix) { - localStorage.setItem(storageKey, transformMatrix); -} - -function observePanZoomChanges(svg) { - const observer = new MutationObserver(() => storePanZoomVal(svg.style.transform)); - - observer.observe(svg, { attributeFilter: ['style'] }); -} - -export function start(svg) { - restorePanZoomVal(svg); - addEventListeners(svg); - observePanZoomChanges(svg); -} |