Skip to content

Commit

Permalink
Add responsive padding to FlyToGeoJsonExtension
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerMatteo committed Aug 22, 2024
1 parent 116764f commit 1345110
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions app/extensions/FlyToGeoJsonExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,22 @@ export class FlyToGeoJsonExtension extends LayerExtension {
) {
const viewport = this.context.viewport as WebMercatorViewport;
const [minX, minY, maxX, maxY] = bbox(props.data as Geometry);
const { longitude, latitude, zoom } = viewport.fitBounds([
[minX, minY],
[maxX, maxY],
]);
const { longitude, latitude, zoom } = viewport.fitBounds(
[
[minX, minY],
[maxX, maxY],
],
{
padding:
window.innerWidth < 992
? { top: 100, bottom: 400, left: 16, right: 16 }
: { top: 64, bottom: 64, left: 368, right: 368 },
},
);
const newViewState = {
longitude,
latitude,
zoom: zoom - 0.25,
zoom: zoom,
transitionDuration: 750,
transitionInterpolator: new FlyToInterpolator(),
};
Expand Down

0 comments on commit 1345110

Please sign in to comment.