Skip to content

Commit b66d9c0

Browse files
committed
should guard againt undefined projection.invert results
... that occur in some non-clipped projections
1 parent 3583485 commit b66d9c0

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

src/plots/geo/zoom.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,14 @@ function zoomNonClipped(geo, projection) {
114114
function position(x) { return projection.invert(x); }
115115

116116
function outside(x) {
117-
var pt = projection(position(x));
118-
return (Math.abs(pt[0] - x[0]) > INSIDETOLORANCEPXS ||
119-
Math.abs(pt[1] - x[1]) > INSIDETOLORANCEPXS);
117+
var pos = position(x);
118+
if(!pos) return true;
119+
120+
var pt = projection(pos);
121+
return (
122+
Math.abs(pt[0] - x[0]) > INSIDETOLORANCEPXS ||
123+
Math.abs(pt[1] - x[1]) > INSIDETOLORANCEPXS
124+
);
120125
}
121126

122127
function handleZoomstart() {

test/jasmine/tests/geo_test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1941,4 +1941,22 @@ describe('Test geo zoom/pan/drag interactions:', function() {
19411941
.catch(failTest)
19421942
.then(done);
19431943
});
1944+
1945+
it('should guard againt undefined projection.invert result in some projections', function(done) {
1946+
// e.g. aitoff
1947+
var fig = Lib.extendDeep({}, require('@mocks/geo_aitoff-sinusoidal.json'));
1948+
fig.layout.dragmode = 'pan';
1949+
delete fig.layout.geo2;
1950+
fig.data = [fig.data[0]];
1951+
fig.layout.width = 700;
1952+
fig.layout.height = 500;
1953+
1954+
plot(fig)
1955+
.then(function() { return scroll([131, 159], [-200, 200]); })
1956+
.then(function() {
1957+
// scrolling outside subplot frame should log errors,
1958+
})
1959+
.catch(failTest)
1960+
.then(done);
1961+
});
19441962
});

0 commit comments

Comments
 (0)