Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test opacity of a partly visible marker #3644

Merged
merged 2 commits into from
Jan 29, 2024
Merged
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
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