Skip to content

Commit

Permalink
Fix edge cases for popup occlusion (#11834)
Browse files Browse the repository at this point in the history
* More thorough popup occlusion

* Updating unit test
  • Loading branch information
SnailBones authored Apr 28, 2022
1 parent ee24150 commit 3aaf9be
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/ui/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -649,11 +649,12 @@ export default class Popup extends Evented {
}

_setOpacity(opacity: number) {
if (this._container) {
this._container.style.opacity = `${opacity}`;
}
if (this._content) {
this._content.style.opacity = `${opacity}`;
this._content.style.pointerEvents = opacity ? 'auto' : 'none';
}
if (this._tip) this._tip.style.opacity = `${opacity}`;
}
}

Expand Down
6 changes: 3 additions & 3 deletions test/unit/ui/popup.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -563,17 +563,17 @@ test('Popup is positioned and occluded correctly on globe', (t) => {
.addTo(map);

t.same(popup._pos, map.project([45, 0]));
t.same(popup._content.style.opacity, 1);
t.same(popup._container.style.opacity, 1);
t.same(popup._content.style.pointerEvents, 'auto');

popup.setLngLat([270, 0]);
t.same(popup._pos, map.project([270, 0]));
t.same(popup._content.style.opacity, 0);
t.same(popup._container.style.opacity, 0);
t.same(popup._content.style.pointerEvents, 'none');

popup.setLngLat([0, 45]);
t.same(popup._pos, map.project([0, 45]));
t.same(popup._content.style.opacity, 1);
t.same(popup._container.style.opacity, 1);
t.same(popup._content.style.pointerEvents, 'auto');

t.end();
Expand Down

0 comments on commit 3aaf9be

Please sign in to comment.