Skip to content

Commit 52be69a

Browse files
committed
Merge pull request plotly#421 from plotly/gl-draw-promise
Return promise after gl rendering
2 parents 8138572 + bf1f65f commit 52be69a

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

src/plots/gl2d/scene2d.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ proto.toImage = function(format) {
166166
if(this.staticPlot) this.container.appendChild(STATIC_CANVAS);
167167

168168
// force redraw
169-
this.glplot.setDirty(true);
169+
this.glplot.setDirty();
170170
this.glplot.draw();
171171

172172
// grab context and yank out pixels
@@ -408,6 +408,9 @@ proto.plot = function(fullData, fullLayout) {
408408

409409
options.merge(fullLayout);
410410
glplot.update(options);
411+
412+
// force redraw so that promise is returned when rendering is completed
413+
this.glplot.draw();
411414
};
412415

413416
proto.draw = function() {

src/plots/gl3d/scene.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,9 @@ proto.plot = function(sceneData, fullLayout, layout) {
542542
containerStyle.width = (size.w * (domain.x[1] - domain.x[0])) + 'px';
543543
containerStyle.height = (size.h * (domain.y[1] - domain.y[0])) + 'px';
544544
}
545+
546+
// force redraw so that promise is returned when rendering is completed
547+
this.glplot.redraw();
545548
};
546549

547550
proto.destroy = function() {

test/jasmine/tests/gl_plot_interact_test.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ var customMatchers = require('../assets/custom_matchers');
1616
*
1717
*/
1818

19-
var PLOT_DELAY = 200;
20-
var MOUSE_DELAY = 20;
2119
var MODEBAR_DELAY = 500;
2220

2321

@@ -54,10 +52,9 @@ describe('Test gl plot interactions', function() {
5452
destroyGraphDiv();
5553
});
5654

55+
// ...
5756
function delay(done) {
58-
setTimeout(function() {
59-
done();
60-
}, PLOT_DELAY);
57+
setTimeout(done, 0);
6158
}
6259

6360
describe('gl3d plots', function() {
@@ -99,9 +96,7 @@ describe('Test gl plot interactions', function() {
9996

10097
mouseEventScatter3d('mouseover');
10198

102-
setTimeout(function() {
103-
done();
104-
}, MOUSE_DELAY);
99+
delay(done);
105100
});
106101

107102
it('should have', function() {
@@ -139,9 +134,7 @@ describe('Test gl plot interactions', function() {
139134
// with button 1 pressed
140135
mouseEventScatter3d('mouseover', {buttons: 1});
141136

142-
setTimeout(function() {
143-
done();
144-
}, MOUSE_DELAY);
137+
delay(done);
145138
});
146139

147140
it('should have', function() {

0 commit comments

Comments
 (0)