d3 / d3-zoom

Pan and zoom SVG, HTML or Canvas using mouse or touch input.
https://d3js.org/d3-zoom
ISC License
505 stars 143 forks source link

Cannot read property 'transform' of null #166

Closed Josema closed 5 years ago

Josema commented 5 years ago

I'm using ES6 to build my own version of d3 because I don't need the whole library.

How I build my own d3

import * as d3dispatch from 'd3-dispatch'
import * as d3drag from 'd3-drag'
import * as d3selection from 'd3-selection'
import * as d3transition from 'd3-transition'
import * as d3zoom from 'd3-zoom'

const d3 = Object.assign({}, d3dispatch, d3drag, d3drag, d3selection, d3zoom)

But I'm getting this error: Uncaught TypeError: Cannot read property 'transform' of null

The error I'm getting is in this line:

...
d3.zoom().on('zoom', function() {
    const d3_transform = d3.event.transform;
...

Also tried this:

const d3 = Object.assign(d3zoom, d3dispatch, d3drag, d3drag, d3selection)

But I get this error: Uncaught TypeError: Cannot add property dispatch, object is not extensible

Is there a way to compose d3 submodules with ES6?

Josema commented 5 years ago

https://github.com/d3/d3-dispatch/issues/19