Revert "fix(mobile): viewport size on keyboard focus (#1925)"
This reverts commit e0b75946f6.
This commit is contained in:
@@ -60,6 +60,7 @@ const startApplication: StartApplication = async function startApplication(
|
|||||||
|
|
||||||
const setupViewportHeightListeners = () => {
|
const setupViewportHeightListeners = () => {
|
||||||
if (!isDesktop) {
|
if (!isDesktop) {
|
||||||
|
setViewportHeightWithFallback()
|
||||||
window.addEventListener('orientationchange', setViewportHeightWithFallback)
|
window.addEventListener('orientationchange', setViewportHeightWithFallback)
|
||||||
window.addEventListener('resize', setViewportHeightWithFallback)
|
window.addEventListener('resize', setViewportHeightWithFallback)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,15 +2,24 @@ import { log, LoggingDomain } from './Logging'
|
|||||||
|
|
||||||
export const ViewportHeightKey = '--viewport-height'
|
export const ViewportHeightKey = '--viewport-height'
|
||||||
|
|
||||||
|
export const setViewportHeightWithFallback = () => {
|
||||||
|
const newValue = visualViewport && visualViewport.height > 0 ? visualViewport.height : window.innerHeight
|
||||||
|
|
||||||
|
if (!newValue) {
|
||||||
|
setCustomViewportHeight('100', 'vh')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
setCustomViewportHeight(String(newValue), 'px')
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param forceTriggerResizeEvent On iPad at least, setProperty(ViewportHeightKey) does not trigger a resize event
|
* @param forceTriggerResizeEvent On iPad at least, setProperty(ViewportHeightKey) does not trigger a resize event
|
||||||
*/
|
*/
|
||||||
export const setCustomViewportHeight = (height: number, suffix: 'px' | 'vh', forceTriggerResizeEvent = false) => {
|
export const setCustomViewportHeight = (height: string, suffix: 'px' | 'vh', forceTriggerResizeEvent = false) => {
|
||||||
const value = `${height}${suffix}`
|
log(LoggingDomain.Viewport, `setCustomViewportHeight: ${height}`)
|
||||||
|
|
||||||
log(LoggingDomain.Viewport, `setCustomViewportHeight: ${value}`)
|
document.documentElement.style.setProperty(ViewportHeightKey, `${height}${suffix}`)
|
||||||
|
|
||||||
document.documentElement.style.setProperty(ViewportHeightKey, value)
|
|
||||||
|
|
||||||
if (forceTriggerResizeEvent) {
|
if (forceTriggerResizeEvent) {
|
||||||
window.dispatchEvent(new Event('resize'))
|
window.dispatchEvent(new Event('resize'))
|
||||||
|
|||||||
Reference in New Issue
Block a user