Skip to content

Make scrollZoom config option a flaglist #3422

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 5 commits into from
Jan 16, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
implement scrollZoom:false for mapbox subplots
  • Loading branch information
etpinard committed Jan 8, 2019
commit 16a01e7d4fd388f68b3bce61af0a362e6770d300
6 changes: 6 additions & 0 deletions src/plots/mapbox/mapbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,12 @@ proto.updateMap = function(calcData, fullLayout, resolve, reject) {
self.updateLayout(fullLayout);
self.resolveOnRender(resolve);
}

if(this.gd._context._scrollZoom.mapbox) {
map.scrollZoom.enable();
} else {
map.scrollZoom.disable();
}
};

proto.updateData = function(calcData) {
Expand Down
45 changes: 45 additions & 0 deletions test/jasmine/tests/mapbox_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,51 @@ describe('@noCI, mapbox plots', function() {
.then(done);
}, LONG_TIMEOUT_INTERVAL);

it('should respect scrollZoom config option', function(done) {
var relayoutCnt = 0;
gd.on('plotly_relayout', function() { relayoutCnt++; });

function _scroll() {
relayoutCnt = 0;
return new Promise(function(resolve) {
mouseEvent('mousemove', pointPos[0], pointPos[1]);
mouseEvent('scroll', pointPos[0], pointPos[1], {deltaY: -400});
setTimeout(resolve, 500);
});
}

var zoom = getMapInfo(gd).zoom;
expect(zoom).toBeCloseTo(1.234);

_scroll().then(function() {
expect(relayoutCnt).toBe(1, 'scroll relayout cnt');

var zoomNew = getMapInfo(gd).zoom;
expect(zoomNew).toBeGreaterThan(zoom);
zoom = zoomNew;
})
.then(function() { return Plotly.plot(gd, [], {}, {scrollZoom: false}); })
.then(_scroll)
.then(function() {
expect(relayoutCnt).toBe(0, 'no additional relayout call');

var zoomNew = getMapInfo(gd).zoom;
expect(zoomNew).toBe(zoom);
zoom = zoomNew;
})
.then(function() { return Plotly.plot(gd, [], {}, {scrollZoom: true}); })
.then(_scroll)
.then(function() {
expect(relayoutCnt).toBe(1, 'scroll relayout cnt');

var zoomNew = getMapInfo(gd).zoom;
expect(zoomNew).toBeGreaterThan(zoom);
zoom = zoomNew;
})
.catch(failTest)
.then(done);
}, LONG_TIMEOUT_INTERVAL);

function getMapInfo(gd) {
var subplot = gd._fullLayout.mapbox._subplot;
var map = subplot.map;
Expand Down