Web Dev Solutions

Catalin Mititiuc

aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/index.js')
-rw-r--r--src/index.js46
1 files changed, 2 insertions, 44 deletions
diff --git a/src/index.js b/src/index.js
index 63925b1..89893b6 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,48 +1,6 @@
-import { pan, zoom } from 'svg-pan-zoom';
+import PanZoom from './modules/panzoom.js';
import Game from './modules/game.js';
-const PanZoom = new function () {
- const storageKey = 'pan-zoom';
-
- function storePanZoomVal(transformMatrix) {
- localStorage.setItem(storageKey, transformMatrix);
- }
-
- function observePanZoomChanges(svg) {
- const observer = new MutationObserver(() => storePanZoomVal(svg.style.transform));
-
- observer.observe(svg, { attributeFilter: ['style'] });
- }
-
- function restorePanZoomVal(svg) {
- const storedPanZoomVal = localStorage.getItem(storageKey);
-
- if (storedPanZoomVal) {
- svg.style.transform = storedPanZoomVal;
- }
- }
-
- function addEventListeners(svg) {
- svg.addEventListener('wheel', e => {
- e.preventDefault();
-
- zoom(svg, e);
- }, { passive: false });
-
- svg.addEventListener('pointerdown', e => {
- e.preventDefault();
-
- pan(svg, e);
- }, { passive: false });
- }
-
- this.start = function (svg) {
- restorePanZoomVal(svg);
- addEventListeners(svg);
- observePanZoomChanges(svg);
- };
-};
-
const RecordSheet = new function () {
this.unSelect = function () {
let selected = this.getSelected();
@@ -88,7 +46,7 @@ window.addEventListener('load', () => {
const svgns = "http://www.w3.org/2000/svg",
recordSheetVisibility = document.querySelector('#content input[type="checkbox"].visible');
- PanZoom.start(svg);
+ new PanZoom(svg);
const distanceOutput = document.getElementById('status');