Skip to content

Commit b56591d

Browse files
committed
resolves #143 - implement scrollZoom:false for geo subplots
1 parent c83538a commit b56591d

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

src/plots/geo/geo.js

+3
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,9 @@ proto.updateFx = function(fullLayout, geoLayout) {
420420
bgRect.node().onmousedown = null;
421421
bgRect.call(createGeoZoom(_this, geoLayout));
422422
bgRect.on('dblclick.zoom', zoomReset);
423+
if(!gd._context._scrollZoom.geo) {
424+
bgRect.on('wheel.zoom', null);
425+
}
423426
}
424427
else if(dragMode === 'select' || dragMode === 'lasso') {
425428
bgRect.on('.zoom', null);

test/jasmine/tests/geo_test.js

+48
Original file line numberDiff line numberDiff line change
@@ -1961,4 +1961,52 @@ describe('Test geo zoom/pan/drag interactions:', function() {
19611961
.catch(failTest)
19621962
.then(done);
19631963
});
1964+
1965+
it('should respect scrollZoom config option', function(done) {
1966+
var fig = Lib.extendDeep({}, require('@mocks/geo_winkel-tripel'));
1967+
fig.layout.width = 700;
1968+
fig.layout.height = 500;
1969+
fig.layout.dragmode = 'pan';
1970+
1971+
function _assert(step, attr, proj, eventKeys) {
1972+
var msg = '[' + step + '] ';
1973+
1974+
var geoLayout = gd._fullLayout.geo;
1975+
var scale = geoLayout.projection.scale;
1976+
expect(scale).toBeCloseTo(attr[0], 1, msg + 'zoom');
1977+
1978+
var geo = geoLayout._subplot;
1979+
var _scale = geo.projection.scale();
1980+
expect(_scale).toBeCloseTo(proj[0], 0, msg + 'scale');
1981+
1982+
assertEventData(msg, eventKeys);
1983+
}
1984+
1985+
plot(fig)
1986+
.then(function() {
1987+
_assert('base', [1], [101.9], undefined);
1988+
})
1989+
.then(function() { return scroll([200, 250], [-200, -200]); })
1990+
.then(function() {
1991+
_assert('with scroll enable (by default)',
1992+
[1.3], [134.4],
1993+
['geo.projection.rotation.lon', 'geo.center.lon', 'geo.center.lat', 'geo.projection.scale']
1994+
);
1995+
})
1996+
.then(function() { return Plotly.plot(gd, [], {}, {scrollZoom: false}); })
1997+
.then(function() { return scroll([200, 250], [-200, -200]); })
1998+
.then(function() {
1999+
_assert('with scrollZoom:false', [1.3], [134.4], undefined);
2000+
})
2001+
.then(function() { return Plotly.plot(gd, [], {}, {scrollZoom: 'geo'}); })
2002+
.then(function() { return scroll([200, 250], [-200, -200]); })
2003+
.then(function() {
2004+
_assert('with scrollZoom:geo',
2005+
[1.74], [177.34],
2006+
['geo.projection.rotation.lon', 'geo.center.lon', 'geo.center.lat', 'geo.projection.scale']
2007+
);
2008+
})
2009+
.catch(failTest)
2010+
.then(done);
2011+
});
19642012
});

0 commit comments

Comments
 (0)