Skip to content

Commit 7431c95

Browse files
author
Arindam Bose
committed
Ensure padding is not propagated from fitBounds to transform padding
1 parent 25d48f4 commit 7431c95

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/ui/camera.js

+2
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,8 @@ class Camera extends Evented {
599599
if (!calculatedOptions) return this;
600600

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

603605
return options.linear ?
604606
this.easeTo(options, eventData) :

test/unit/ui/camera.test.js

+15
Original file line numberDiff line numberDiff line change
@@ -1889,6 +1889,21 @@ test('camera', (t) => {
18891889
t.end();
18901890
});
18911891

1892+
t.test('padding does not get propagated to transform.padding', (t) => {
1893+
const camera = createCamera();
1894+
const bb = [[-133, 16], [-68, 50]];
1895+
1896+
camera.fitBounds(bb, {padding: {top: 10, right: 75, bottom: 50, left: 25}, duration:0});
1897+
const padding = camera.transform.padding;
1898+
t.deepEqual(padding, {
1899+
left: 0,
1900+
right: 0,
1901+
top: 0,
1902+
bottom: 0
1903+
});
1904+
t.end();
1905+
});
1906+
18921907
t.end();
18931908
});
18941909

0 commit comments

Comments
 (0)