Fix bridge viewport safe-area insets.

This commit is contained in:
Denis Švara
2026-01-06 17:14:51 +01:00
parent 37f0a2cfe9
commit 2d7b76ff78
+8 -3
View File
@@ -1,19 +1,24 @@
let top = 0
const viewportTarget = window.visualViewport || window
export const viewport = {
get top() {
return top
},
get height() {
return visualViewport.height
return viewportTarget.height || window.innerHeight
}
}
function update() {
requestAnimationFrame(() => {
top = parseInt(getComputedStyle(document.documentElement).getPropertyValue("--safe-area-inset-top"))
const styles = getComputedStyle(document.documentElement)
const customInset = styles.getPropertyValue("--custom-safe-inset-top")
const fallbackInset = styles.getPropertyValue("--safe-area-inset-top")
const insetValue = (customInset || fallbackInset).trim()
top = parseInt(insetValue || "0", 10) || 0
})
}
visualViewport.addEventListener("resize", update)
viewportTarget.addEventListener("resize", update)
update()