8000 Add config options in plot schema by etpinard · Pull Request #3376 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

Add config options in plot schema #3376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jan 16, 2019
Merged
Prev Previous commit
Merge branch 'master' into config-opts-in-plot-schema
  • Loading branch information
etpinard committed Jan 16, 2019
commit e7f1478ee000432696c9cfb27621167e80d1833f
84 changes: 84 additions & 0 deletions test/jasmine/tests/config_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -822,4 +822,88 @@ describe('config argument', function() {
.then(done);
});
});

describe('scrollZoom interactions:', function() {
var gd;

afterEach(destroyGraphDiv);

function _scroll() {
var mainDrag = d3.select('.nsewdrag[data-subplot="xy"]').node();
mouseEvent('scroll', 200, 200, {deltaY: -200, element: mainDrag});
}

it('should not disable scrollZoom when *responsive:true*', function(done) {
gd = document.createElement('div');
gd.id = 'graph';
gd.style.height = '85vh';
gd.style.minHeight = '300px';
document.body.appendChild(gd);

// locking down fix for:
// https://github.com/plotly/plotly.js/issues/3337

var xrng0;
var yrng0;

Plotly.newPlot(gd, [{
y: [1, 2, 1]
}], {}, {
scrollZoom: true,
responsive: true
})
.then(function() {
xrng0 = gd._fullLayout.xaxis.range.slice();
yrng0 = gd._fullLayout.yaxis.range.slice();
})
.then(_scroll)
.then(function() {
var xrng = gd._fullLayout.xaxis.range;
expect(xrng[0]).toBeGreaterThan(xrng0[0], 'scrolled x-range[0]');
expect(xrng[1]).toBeLessThan(xrng0[1], 'scrolled x-range[1]');

var yrng = gd._fullLayout.yaxis.range;
expect(yrng[0]).toBeGreaterThan(yrng0[0], 'scrolled y-range[0]');
expect(yrng[1]).toBeLessThan(yrng0[1], 'scrolled y-range[1]');
})
.catch(failTest)
.then(done);
});

it('should not disable scrollZoom when page is made scrollable by large graph', function(done) {
gd = document.createElement('div');
gd.id = 'graph';
document.body.appendChild(gd);

// locking down fix for:
// https://github.com/plotly/plotly.js/issues/2371

var xrng0;
var yrng0;

Plotly.newPlot(gd, [{
y: [1, 2, 1]
}], {
width: 2 * window.innerWidth
}, {
scrollZoom: true
})
.then(function() {
xrng0 = gd._fullLayout.xaxis.range.slice();
yrng0 = gd._fullLayout.yaxis.range.slice();
})
.then(_scroll)
.then(function() {
var xrng = gd._fullLayout.xaxis.range;
expect(xrng[0]).toBeGreaterThan(xrng0[0], 'scrolled x-range[0]');
expect(xrng[1]).toBeLessThan(xrng0[1], 'scrolled x-range[1]');

var yrng = gd._fullLayout.yaxis.range;
expect(yrng[0]).toBeGreaterThan(yrng0[0], 'scrolled y-range[0]');
expect(yrng[1]).toBeLessThan(yrng0[1], 'scrolled y-range[1]');
})
.catch(failTest)
.then(done);
});
});
});
You are viewing a condensed version of this merge commit. You can view the full changes here.
0