Make off-map clicks visibly reposition popup
This commit is contained in:
parent
26a9bc4f17
commit
e2ed04c5a6
11
kort7/app.js
11
kort7/app.js
|
|
@ -25,6 +25,15 @@ const resetBtn = document.getElementById("resetBtn");
|
||||||
|
|
||||||
let forcedPopupVehicle = null;
|
let forcedPopupVehicle = null;
|
||||||
|
|
||||||
|
function flashVehicleMarker(v) {
|
||||||
|
const markerEl = v.marker.getElement();
|
||||||
|
if (!markerEl) return;
|
||||||
|
|
||||||
|
markerEl.classList.remove("flash-marker");
|
||||||
|
void markerEl.offsetWidth;
|
||||||
|
markerEl.classList.add("flash-marker");
|
||||||
|
}
|
||||||
|
|
||||||
function openVehiclePopup(name) {
|
function openVehiclePopup(name) {
|
||||||
const v = vehicles[name];
|
const v = vehicles[name];
|
||||||
if (!v) return;
|
if (!v) return;
|
||||||
|
|
@ -35,12 +44,14 @@ function openVehiclePopup(name) {
|
||||||
v.marker.addTo(map);
|
v.marker.addTo(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
map.panTo([v.displayLat, v.displayLon], { animate: true, duration: 0.4 });
|
||||||
v.marker.setOpacity(1);
|
v.marker.setOpacity(1);
|
||||||
v.marker.setZIndexOffset(1000);
|
v.marker.setZIndexOffset(1000);
|
||||||
v.marker.setLatLng([v.displayLat, v.displayLon]);
|
v.marker.setLatLng([v.displayLat, v.displayLon]);
|
||||||
setHeading(v.marker, v.displayHeading);
|
setHeading(v.marker, v.displayHeading);
|
||||||
v.marker.setPopupContent(popupHtml(v.name, v));
|
v.marker.setPopupContent(popupHtml(v.name, v));
|
||||||
v.marker.openPopup();
|
v.marker.openPopup();
|
||||||
|
requestAnimationFrame(() => flashVehicleMarker(v));
|
||||||
}
|
}
|
||||||
|
|
||||||
function carIcon(color) {
|
function carIcon(color) {
|
||||||
|
|
|
||||||
|
|
@ -121,6 +121,16 @@
|
||||||
opacity: 0.82;
|
opacity: 0.82;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.flash-marker {
|
||||||
|
animation: flash-marker-pulse 1.2s ease-out 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes flash-marker-pulse {
|
||||||
|
0% { transform: scale(1); filter: drop-shadow(0 1px 1px rgba(0,0,0,.35)); }
|
||||||
|
20% { transform: scale(1.8); filter: drop-shadow(0 0 0 rgba(0,0,0,0)); }
|
||||||
|
100% { transform: scale(1); filter: drop-shadow(0 1px 1px rgba(0,0,0,.35)); }
|
||||||
|
}
|
||||||
|
|
||||||
.car {
|
.car {
|
||||||
width: 24px;
|
width: 24px;
|
||||||
height: 24px;
|
height: 24px;
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,10 @@ test.describe('kort7 vehicle map', () => {
|
||||||
await expect(popup).toContainText('Usikkerhed:');
|
await expect(popup).toContainText('Usikkerhed:');
|
||||||
await expect(popup).toContainText('På kortet:');
|
await expect(popup).toContainText('På kortet:');
|
||||||
|
|
||||||
const visibleMarkerCount = await page.locator('.leaflet-marker-icon').count();
|
await expect(page.locator('.leaflet-popup')).toBeVisible();
|
||||||
expect(visibleMarkerCount).toBeGreaterThan(0);
|
|
||||||
|
const popupBox = await page.locator('.leaflet-popup').boundingBox();
|
||||||
|
expect(popupBox).not.toBeNull();
|
||||||
|
expect(popupBox.y).toBeLessThan(220);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue