diff --git a/css/files.scss b/css/files.scss index 01bab08748..d05fa7b469 100644 --- a/css/files.scss +++ b/css/files.scss @@ -23,7 +23,7 @@ opacity: 1; } -#richdocumentsframe { +.office-viewer__iframe { background-color: #fff; width:100%; height: 100vh; diff --git a/css/mobile.css b/css/mobile.css index c7ef3151e7..8195d7fd85 100644 --- a/css/mobile.css +++ b/css/mobile.css @@ -15,7 +15,7 @@ padding-top: 0; } - #richdocumentsframe { + .office-viewer__iframe { height: 100%; position: fixed; } diff --git a/src/document.js b/src/document.js index 17f0c0cb4c..60f9234965 100644 --- a/src/document.js +++ b/src/document.js @@ -9,7 +9,7 @@ import { getRequestToken } from '@nextcloud/auth' import { loadState } from '@nextcloud/initial-state' import Config from './services/config.tsx' import { getUIDefaults, generateCSSVarTokens, getCollaboraTheme } from './helpers/coolParameters.js' -import { enableScrollLock } from './helpers/safariFixer.js' +import { enableScrollLock } from './helpers/mobileFixer.js' import PostMessageService from './services/postMessage.tsx' import { getCapabilities } from './services/capabilities.ts' import { diff --git a/src/helpers/safariFixer.js b/src/helpers/mobileFixer.js similarity index 71% rename from src/helpers/safariFixer.js rename to src/helpers/mobileFixer.js index adf34f1f0b..2de2cd1ba2 100644 --- a/src/helpers/safariFixer.js +++ b/src/helpers/mobileFixer.js @@ -6,27 +6,19 @@ let scrollLock = false let intervalHandler -const isiOS = [ - 'iPad Simulator', - 'iPhone Simulator', - 'iPod Simulator', - 'iPad', - 'iPhone', - 'iPod', -].includes(navigator.platform) || (navigator.userAgent.includes('Mac') && navigator.maxTouchPoints > 1) - -// Workaround for Safari automatically scrolling the body when the hidden input is focussed +// Workaround for browsers automatically scrolling the body when the hidden input is focussed const handleScrollReset = () => { document.documentElement.scrollTop = 0 document.scrollingElement.scrollTop = 0 } -// Workaround for Safari to resize the iframe to the proper height -// as 100vh is not the proper viewport height there +// Workaround for mobile browsers to resize the iframe to the visual viewport height +// as visual viewport area - which includes OSK, say - is not propagated to iframes +// see https://developer.mozilla.org/en-US/docs/Web/API/VisualViewport const handleResize = () => { const expectedHeight = window.visualViewport.height ?? document.documentElement.clientHeight - const frame = document.getElementById('richdocumentsframe') - if (frame) { + const frames = document.getElementsByClassName('office-viewer__iframe') + for (const frame of frames) { frame.style.maxHeight = expectedHeight + 'px' } const viewer = document.querySelector('.office-viewer') @@ -36,12 +28,10 @@ const handleResize = () => { } const fixThemAll = () => { - if (!isiOS) { - return - } if (!scrollLock) { return } + handleScrollReset() handleResize() } @@ -49,7 +39,7 @@ const fixThemAll = () => { const preventDefault = (e) => e.preventDefault() export const enableScrollLock = () => { - if (scrollLock || !isiOS) { + if (scrollLock) { return } @@ -65,7 +55,7 @@ export const enableScrollLock = () => { } export const disableScrollLock = () => { - if (!scrollLock || !isiOS) { + if (!scrollLock) { return } diff --git a/src/view/Office.vue b/src/view/Office.vue index 1a699392c4..c4b351fa94 100644 --- a/src/view/Office.vue +++ b/src/view/Office.vue @@ -99,7 +99,7 @@ import { import PostMessageService from '../services/postMessage.tsx' import FilesAppIntegration from './FilesAppIntegration.js' import { LOADING_ERROR, checkCollaboraConfiguration, checkProxyStatus } from '../services/collabora.js' -import { enableScrollLock, disableScrollLock } from '../helpers/safariFixer.js' +import { enableScrollLock, disableScrollLock } from '../helpers/mobileFixer.js' import axios from '@nextcloud/axios' import { generateUrl,