Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions debug/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@
style: 'mapbox://styles/mapbox/streets-v10',
hash: true
});
map.showPadding = true;
map.setPadding({
left: 10,
right: 20,
top: 30,
bottom: 40
});

var popup = new mapboxgl.Popup({closeButton: false, closeOnClick: false})
.trackPointer()
Expand Down
8 changes: 4 additions & 4 deletions src/ui/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -555,10 +555,10 @@ export default class Popup extends Evented {
const width = container.offsetWidth;
const height = container.offsetHeight;

const isTop = pos.y + bottomY < height;
const isBottom = pos.y > map.transform.height - height;
const isLeft = pos.x < width / 2;
const isRight = pos.x > map.transform.width - width / 2;
const isTop = pos.y + bottomY < height + map.transform.padding.top;
const isBottom = pos.y > map.transform.height - height - map.transform.padding.bottom;
const isLeft = pos.x < width / 2 + map.transform.padding.left;
const isRight = pos.x > map.transform.width - width / 2 - map.transform.padding.right;

if (isTop) {
if (isLeft) return 'top-left';
Expand Down