Skip to content

Commit

Permalink
calculate matrices after constraining (#3518)
Browse files Browse the repository at this point in the history
Fixes #3474.
  • Loading branch information
mourner authored Nov 2, 2016
1 parent dce1abb commit f829bd0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions js/geo/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,17 @@ class Transform {
this.scale = this.zoomScale(z);
this.tileZoom = Math.floor(z);
this.zoomFraction = z - this.tileZoom;
this._calcMatrices();
this._constrain();
this._calcMatrices();
}

get center() { return this._center; }
set center(center) {
if (center.lat === this._center.lat && center.lng === this._center.lng) return;
this._unmodified = false;
this._center = center;
this._calcMatrices();
this._constrain();
this._calcMatrices();
}

/**
Expand Down Expand Up @@ -177,8 +177,8 @@ class Transform {
this.height = height;

this.pixelsToGLUnits = [2 / width, -2 / height];
this._calcMatrices();
this._constrain();
this._calcMatrices();
}

get unmodified() { return this._unmodified; }
Expand Down
7 changes: 7 additions & 0 deletions test/js/geo/transform.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ test('transform', (t) => {
t.end();
});

t.test('does not throw on bad center', (t) => {
const transform = new Transform();
transform.resize(500, 500);
transform.center = {lng: 50, lat: -90};
t.end();
});

t.test('panBy', (t) => {
const transform = new Transform();
transform.resize(500, 500);
Expand Down

0 comments on commit f829bd0

Please sign in to comment.