Skip to content

Commit 3123ddc

Browse files
committed
#30a covering 2D WebGL plot with the plotly_relayout event on pan / zoom
1 parent 40bd1e7 commit 3123ddc

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/plots/gl2d/scene2d.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,16 @@ proto.updateFx = function(options) {
268268
fullLayout.hovermode = options.hovermode;
269269
};
270270

271+
var relayoutCallback = function(scene) {
272+
var update = {};
273+
update[scene.id] = { // scene.camera has no many useful projection or scale information
274+
lastInputTime: scene.camera.lastInputTime, // helps determine which one is the latest input (if async)
275+
xrange: scene.xaxis.range.slice(0),
276+
yrange: scene.yaxis.range.slice(0)
277+
};
278+
scene.container.parentElement.parentElement.parentElement.emit('plotly_relayout', update);
279+
};
280+
271281
proto.cameraChanged = function() {
272282
var camera = this.camera,
273283
xrange = this.xaxis.range,
@@ -285,6 +295,7 @@ proto.cameraChanged = function() {
285295
this.glplotOptions.ticks = nextTicks;
286296
this.glplotOptions.dataBox = camera.dataBox;
287297
this.glplot.update(this.glplotOptions);
298+
relayoutCallback(this);
288299
}
289300
};
290301

0 commit comments

Comments
 (0)