Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 948f493

Browse files
committed
GL rangeslider saftey check
1 parent 5c53f8f commit 948f493

File tree

3 files changed

+33
-6
lines changed

3 files changed

+33
-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/range_slider_test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,29 @@ describe('the range slider', function() {
308308
expect(layoutOut).toEqual(expected);
309309
});
310310
});
311+
312+
fdescribe('when used with gl traces', function() {
313+
314+
beforeEach(function() {
315+
gd = createGraphDiv();
316+
});
317+
318+
afterEach(destroyGraphDiv);
319+
320+
it('should not be drawn with GL2d', function(done) {
321+
var data = [{
322+
x: [1,2,3],
323+
y: [2,3,4],
324+
type: 'scattergl'
325+
}];
326+
327+
Plotly.plot(gd, data, mock.layout).then(function() {
328+
rangeSlider = document.getElementsByClassName('range-slider')[0];
329+
expect(rangeSlider).not.toBeDefined();
330+
done();
331+
});
332+
});
333+
});
311334
});
312335

313336

0 commit comments

Comments
 (0)