svg-pan-zoom icon indicating copy to clipboard operation
svg-pan-zoom copied to clipboard

Library not loading with webpack and import

Open Armaldio opened this issue 6 years ago • 2 comments

Bug report

Expected behaviour

Expecting the library to load correctly

Actual behaviour

In a webpack environment (https://github.com/SimulatedGREG/electron-vue), the library doesn't load with either import or require

import: electron_2018-08-01_23-31-29

require: electron_2018-08-01_23-31-09

Steps to reproduce the behaviour

  1. Clone the repo (https://github.com/SimulatedGREG/electron-vue)
  2. Install library via npm
  3. Insert div#drawing element
  4. Add the following code
import svgPanZoom from 'svg-pan-zoom';
svgPanZoom('#drawing');

Configuration

  • svg-pan-zoom version: 3.5.3
  • Browser(s): chrome/electron
  • Operating system(s): W10

Thanks

Armaldio avatar Aug 01 '18 21:08 Armaldio

Hi,

I had this issue as well (using the same electron-vue setup), and was able to work around it by specifying the file to require, like this:

var svgPanZoom = require('svg-pan-zoom/dist/svg-pan-zoom.min.js')

Hope that helps a bit!

andre-lichtsteiner avatar Apr 30 '19 01:04 andre-lichtsteiner

I'm facing the same issue. Instead of working around by using require, how does one import svgPanZoom such that you can do e.g.

import ...svgPanZoom..?
svgPanZoom('#demo-tiger', {
    zoomEnabled: true,
    controlIconsEnabled: true,
    fit: true,
    center: true
});

I'm using typescript too.

nscozzaro avatar Apr 23 '20 16:04 nscozzaro