This wasn't trivial, so I think it's good to describe the issue a bit, and how it was solved.
d3-selection uses a global event variable, which is used in d3-drag. bqplot and bqplot-image-gl both have their own copy of d3, and thus also of this event variable.
This was very difficult to 'see', since the sourcemapping shows the same file for both versions of the library loaded. Using devtoolModuleFilenameTemplate: 'webpack://bqplot-image-gl/[namespace]/[resource-path]?[loaders]', in webpack, it makes it easier to see which d3 you are in when debugging.
Where this.parent.bg_events is an instance of a d3 selection, made in bqplot, with bqplot's d3. Invoking its call, would attach the event handler in bqplot's d3 (and setting the global event in bqplot's copy), but would result in bqplot-image-gl's event handler, which would see an event == null. If instead, we make a new selection:
This is for us a quick way to release https://github.com/bloomberg/bqplot/pull/1050 so we can use it in https://github.com/glue-viz/glue-jupyter/pull/165
This wasn't trivial, so I think it's good to describe the issue a bit, and how it was solved.
d3-selection uses a global
event
variable, which is used in d3-drag. bqplot and bqplot-image-gl both have their own copy of d3, and thus also of this event variable. This was very difficult to 'see', since the sourcemapping shows the same file for both versions of the library loaded. UsingdevtoolModuleFilenameTemplate: 'webpack://bqplot-image-gl/[namespace]/[resource-path]?[loaders]',
in webpack, it makes it easier to see which d3 you are in when debugging.Initially we had:
Where
this.parent.bg_events
is an instance of a d3 selection, made in bqplot, with bqplot's d3. Invoking its call, would attach the event handler in bqplot's d3 (and setting the global event in bqplot's copy), but would result in bqplot-image-gl's event handler, which would see anevent == null
. If instead, we make a new selection:All the event handling happens in our copy of d3.