fix: add fallback for initial window size (#1749)

This commit is contained in:
Aman Harwara
2022-10-06 13:49:06 +05:30
committed by GitHub
parent 4b6662d62d
commit 05aff2776b

View File

@@ -42,10 +42,19 @@ const getKey = () => {
}
const setViewportHeight = () => {
document.documentElement.style.setProperty(
'--viewport-height',
`${visualViewport ? visualViewport.height : window.innerHeight}px`,
)
const currentValue = parseInt(document.documentElement.style.getPropertyValue('--viewport-height'))
const newValue = visualViewport && visualViewport.height > 0 ? visualViewport.height : window.innerHeight
if (currentValue && !newValue) {
return
}
if (!currentValue && !newValue) {
document.documentElement.style.setProperty('--viewport-height', '100vh')
return
}
document.documentElement.style.setProperty('--viewport-height', `${newValue}px`)
}
const setDefaultMonospaceFont = (platform?: Platform) => {