Web Dev Solutions

Catalin Mititiuc

aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/app.js')
-rw-r--r--src/app.js18
1 files changed, 18 insertions, 0 deletions
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 });
+});