Skip to content

Commit

Permalink
Ensure padding is not propagated from fitBounds to transform padding (#…
Browse files Browse the repository at this point in the history
…9481)

(cherry picked from commit 7431c95)
  • Loading branch information
Arindam Bose authored Mar 31, 2020
1 parent e27049d commit 8131815
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/ui/camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,8 @@ class Camera extends Evented {
if (!calculatedOptions) return this;

options = extend(calculatedOptions, options);
// Explictly remove the padding field because, calculatedOptions already accounts for padding by setting zoom and center accordingly.
delete options.padding;

return options.linear ?
this.easeTo(options, eventData) :
Expand Down
15 changes: 15 additions & 0 deletions test/unit/ui/camera.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1889,6 +1889,21 @@ test('camera', (t) => {
t.end();
});

t.test('padding does not get propagated to transform.padding', (t) => {
const camera = createCamera();
const bb = [[-133, 16], [-68, 50]];

camera.fitBounds(bb, {padding: {top: 10, right: 75, bottom: 50, left: 25}, duration:0});
const padding = camera.transform.padding;
t.deepEqual(padding, {
left: 0,
right: 0,
top: 0,
bottom: 0
});
t.end();
});

t.end();
});

Expand Down

0 comments on commit 8131815

Please sign in to comment.