Skip to content

Commit

Permalink
fix: add fallback for initial window size (#1749)
Browse files Browse the repository at this point in the history
  • Loading branch information
amanharwara committed Oct 6, 2022
1 parent 4b6662d commit 05aff27
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions packages/web/src/javascripts/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit 05aff27

Please sign in to comment.