Skip to content

Commit

Permalink
Test opacity of a partly visible marker (#3644)
Browse files Browse the repository at this point in the history
* Test opacity of a partly visible marker

* Commit to trigger gh action
  • Loading branch information
sbachinin authored Jan 29, 2024
1 parent 28472bb commit 10f0104
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/ui/marker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,23 @@ describe('marker', () => {
map.remove();
});

test('Applies options.opacity when marker\'s base is hidden by 3d terrain but its center is visible', () => {
const map = createMap();
map.transform.lngLatToCameraDepth = () => .95; // Mocking distance to marker
const marker = new Marker({opacity: '0.7'})
.setLngLat([0, 0])
.addTo(map);

map.terrain = {
getElevationForLngLatZoom: () => 0,
depthAtPoint: (p) => p.y === 256 ? .95 : .92 // return "far" given the marker's center coord; return "near" otherwise
} as any as Terrain;
map.fire('terrain');

expect(marker.getElement().style.opacity).toMatch('.7');
map.remove();
});

test('Applies options.opacityWhenCovered when marker is hidden by 3d terrain', () => {
const map = createMap();
map.transform.lngLatToCameraDepth = () => .95; // Mocking distance to marker
Expand Down

0 comments on commit 10f0104

Please sign in to comment.