Skip to content

Commit 3fead90

Browse files
committed
Merge pull request #377 from plotly/rangeslider-gl-safety
Rangeslider gl safety check
2 parents 046915c + 839db41 commit 3fead90

File tree

3 files changed

+45
-6
lines changed

3 files changed

+45
-6
lines changed

src/components/rangeslider/create_slider.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ module.exports = function createSlider(gd, minStart, maxStart) {
249249
]);
250250

251251
sliderContainer.data([0])
252-
.enter().append(function() {
253-
options.setRange = setRange;
254-
return slider;
255-
});
252+
.enter().append(function() {
253+
options.setRange = setRange;
254+
return slider;
255+
});
256256
};

src/components/rangeslider/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,15 @@ function draw(gd, minStart, maxStart) {
4141
var height = (fullLayout.height - fullLayout.margin.b - fullLayout.margin.t) * options.thickness,
4242
offsetShift = Math.floor(options.borderwidth / 2);
4343

44-
if(sliderContainer[0].length === 0) createSlider(gd, minStart, maxStart);
44+
if(sliderContainer[0].length === 0 && !fullLayout._hasGL2D) createSlider(gd, minStart, maxStart);
45+
46+
// Need to default to 0 for when making gl plots
47+
var bb = fullLayout.xaxis._boundingBox ?
48+
fullLayout.xaxis._boundingBox.height : 0;
4549

4650
Plots.autoMargin(gd, 'range-slider', {
4751
x: 0, y: 0, l: 0, r: 0, t: 0,
48-
b: height + fullLayout.margin.b + fullLayout.xaxis._boundingBox.height,
52+
b: height + fullLayout.margin.b + bb,
4953
pad: 15 + offsetShift * 2
5054
});
5155
}

test/jasmine/tests/gl_plot_interact_test.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,3 +414,38 @@ describe('Test gl plot interactions', function() {
414414
});
415415
});
416416
});
417+
418+
describe('Test gl plot side effects', function() {
419+
describe('when present with rangeslider', function() {
420+
421+
var gd;
422+
423+
beforeEach(function() {
424+
gd = createGraphDiv();
425+
});
426+
427+
afterEach(destroyGraphDiv);
428+
429+
it('should not draw the rangeslider', function(done) {
430+
var data = [{
431+
x: [1,2,3],
432+
y: [2,3,4],
433+
type: 'scattergl'
434+
}, {
435+
x: [1,2,3],
436+
y: [2,3,4],
437+
type: 'scatter'
438+
}];
439+
440+
var layout = {
441+
xaxis: { rangeslider: { visible: true } }
442+
};
443+
444+
Plotly.plot(gd, data, layout).then(function() {
445+
var rangeSlider = document.getElementsByClassName('range-slider')[0];
446+
expect(rangeSlider).not.toBeDefined();
447+
done();
448+
});
449+
});
450+
});
451+
});

0 commit comments

Comments
 (0)