Skip to content

Commit e111300

Browse files
authored
Merge pull request #3745 from plotly/mapbox-scrollzoom-fix
Disable mapbox scroll zoom on init, when required
2 parents 5baa139 + 57a06e5 commit e111300

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

src/plots/mapbox/mapbox.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,6 @@ proto.updateMap = function(calcData, fullLayout, resolve, reject) {
258258
self.updateLayout(fullLayout);
259259
self.resolveOnRender(resolve);
260260
}
261-
262-
if(this.gd._context._scrollZoom.mapbox) {
263-
map.scrollZoom.enable();
264-
} else {
265-
map.scrollZoom.disable();
266-
}
267261
};
268262

269263
proto.updateData = function(calcData) {
@@ -314,6 +308,12 @@ proto.updateLayout = function(fullLayout) {
314308
this.updateFramework(fullLayout);
315309
this.updateFx(fullLayout);
316310
this.map.resize();
311+
312+
if(this.gd._context._scrollZoom.mapbox) {
313+
map.scrollZoom.enable();
314+
} else {
315+
map.scrollZoom.disable();
316+
}
317317
};
318318

319319
proto.resolveOnRender = function(resolve) {

test/jasmine/tests/mapbox_test.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,9 @@ describe('@noCI, mapbox plots', function() {
977977
}, LONG_TIMEOUT_INTERVAL);
978978

979979
it('should respect scrollZoom config option', function(done) {
980+
var mockCopy2 = Lib.extendDeep({}, mock);
981+
mockCopy2.config = {scrollZoom: false};
982+
980983
var relayoutCnt = 0;
981984
gd.on('plotly_relayout', function() { relayoutCnt++; });
982985

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

992995
var zoom = getMapInfo(gd).zoom;
993996
expect(zoom).toBeCloseTo(1.234);
997+
var zoom0 = zoom;
994998

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

10161020
var zoomNew = getMapInfo(gd).zoom;
10171021
expect(zoomNew).toBeGreaterThan(zoom);
1018-
zoom = zoomNew;
1022+
})
1023+
.then(function() { return Plotly.newPlot(gd, mockCopy2); })
1024+
.then(_scroll)
1025+
.then(function() {
1026+
// see https://github.com/plotly/plotly.js/issues/3738
1027+
var zoomNew = getMapInfo(gd).zoom;
1028+
expect(zoomNew).toBe(zoom0);
10191029
})
10201030
.catch(failTest)
10211031
.then(done);

0 commit comments

Comments
 (0)