Web Dev Solutions

Catalin Mititiuc

From 263201d869956b94660d4efa8297e89dadbe36a8 Mon Sep 17 00:00:00 2001 From: Catalin Mititiuc Date: Fri, 12 Apr 2024 10:57:15 -0700 Subject: Initial commit --- src/app.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/app.js (limited to 'src/app.js') diff --git a/src/app.js b/src/app.js new file mode 100644 index 0000000..f5a4fa8 --- /dev/null +++ b/src/app.js @@ -0,0 +1,18 @@ +import zoom from './modules/zoom.js'; +import pan from './modules/pan.js'; + +window.addEventListener('load', function () { + const svg = document.querySelector('object').contentDocument.querySelector('svg'); + + svg.addEventListener('wheel', e => { + e.preventDefault(); + + svg.setAttributeNS(null, 'viewBox', zoom(svg, e)); + }, { passive: false }); + + svg.addEventListener('pointerdown', e => { + e.preventDefault(); + + pan(svg, e); + }, { passive: false }); +}); -- cgit v1.2.3