mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig.space.git
synced 2025-12-13 16:26:50 +00:00
Display map coordinates on click
This commit is contained in:
@@ -11,7 +11,8 @@
|
||||
margin-top: var(--space-xl);
|
||||
|
||||
& img,
|
||||
& .dot {
|
||||
& .dot,
|
||||
& .tooltip {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
@@ -75,6 +76,16 @@
|
||||
animation-name: pulse;
|
||||
}
|
||||
}
|
||||
|
||||
& .tooltip {
|
||||
position: absolute;
|
||||
z-index: 2;
|
||||
min-width: 7rem;
|
||||
font-size: .65rem;
|
||||
padding: var(--space-xs) var(--space-m);
|
||||
background: var(--color-overlay-bg);
|
||||
border-radius: var(--space-m);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ block main
|
||||
- j++
|
||||
|
||||
img#dach(src=assetPath('/img/dach.svg') alt="DE, AT, CH")
|
||||
#tooltip.tooltip(hidden)
|
||||
|
||||
if unmapped.length
|
||||
#unmapped
|
||||
|
||||
@@ -53,6 +53,7 @@ block main
|
||||
- j++
|
||||
|
||||
img#dach(src=assetPath('/img/dach.svg') alt="DE, AT, CH")
|
||||
#tooltip.tooltip(hidden)
|
||||
|
||||
#unmapped
|
||||
h2 Weitere Meetups
|
||||
|
||||
@@ -109,13 +109,18 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
})
|
||||
|
||||
// Map
|
||||
const map = document.getElementById('dach')
|
||||
if (map) {
|
||||
map.onclick = e => {
|
||||
console.log({
|
||||
top: Math.round((e.offsetY / e.target.height) * 100) - 2,
|
||||
left: Math.round((e.offsetX / e.target.width) * 100) + 1,
|
||||
})
|
||||
const map = document.getElementById('map')
|
||||
const mapImg = document.getElementById('dach')
|
||||
const tooltip = document.getElementById('tooltip')
|
||||
if (map && mapImg && tooltip) {
|
||||
mapImg.onclick = e => {
|
||||
const top = Math.round((e.offsetY / e.target.height) * 100) - 2
|
||||
const left = Math.round((e.offsetX / e.target.width) * 100) + 1
|
||||
console.log({ top, left }, map)
|
||||
tooltip.innerText = `Top: ${top} / Left: ${left}`
|
||||
tooltip.removeAttribute('hidden')
|
||||
tooltip.style.top = `${top + 1}%`
|
||||
tooltip.style.left = `${left}%`
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user