Web Dev Solutions

Catalin Mititiuc

aboutsummaryrefslogtreecommitdiff
blob: f5a4fa87a1ec55c9a882435ebb1dd53a01756915 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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 });
});