Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 6 additions & 6 deletions src/plots/mapbox/mapbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,6 @@ 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 Expand Up @@ -314,6 +308,12 @@ proto.updateLayout = function(fullLayout) {
this.updateFramework(fullLayout);
this.updateFx(fullLayout);
this.map.resize();

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

proto.resolveOnRender = function(resolve) {
Expand Down
12 changes: 11 additions & 1 deletion test/jasmine/tests/mapbox_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,9 @@ describe('@noCI, mapbox plots', function() {
}, LONG_TIMEOUT_INTERVAL);

it('should respect scrollZoom config option', function(done) {
var mockCopy2 = Lib.extendDeep({}, mock);
mockCopy2.config = {scrollZoom: false};

var relayoutCnt = 0;
gd.on('plotly_relayout', function() { relayoutCnt++; });

Expand All @@ -991,6 +994,7 @@ describe('@noCI, mapbox plots', function() {

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

_scroll().then(function() {
expect(relayoutCnt).toBe(1, 'scroll relayout cnt');
Expand All @@ -1015,7 +1019,13 @@ describe('@noCI, mapbox plots', function() {

var zoomNew = getMapInfo(gd).zoom;
expect(zoomNew).toBeGreaterThan(zoom);
zoom = zoomNew;
})
.then(function() { return Plotly.newPlot(gd, mockCopy2); })
.then(_scroll)
.then(function() {
// see https://github.com/plotly/plotly.js/issues/3738
var zoomNew = getMapInfo(gd).zoom;
expect(zoomNew).toBe(zoom0);
})
.catch(failTest)
.then(done);
Expand Down