Skip to content

Commit aec8c55

Browse files
authored
Merge pull request #5137 from Minion3665/private/minion/push-rmmvnkvqyynr
fix(android): match iframe size to visual viewport
2 parents abb2a34 + f496a79 commit aec8c55

File tree

5 files changed

+13
-23
lines changed

5 files changed

+13
-23
lines changed

css/files.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
opacity: 1;
2424
}
2525

26-
#richdocumentsframe {
26+
.office-viewer__iframe {
2727
background-color: #fff;
2828
width:100%;
2929
height: 100vh;

css/mobile.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
padding-top: 0;
1616
}
1717

18-
#richdocumentsframe {
18+
.office-viewer__iframe {
1919
height: 100%;
2020
position: fixed;
2121
}

src/document.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { getRequestToken } from '@nextcloud/auth'
99
import { loadState } from '@nextcloud/initial-state'
1010
import Config from './services/config.tsx'
1111
import { getUIDefaults, generateCSSVarTokens, getCollaboraTheme } from './helpers/coolParameters.js'
12-
import { enableScrollLock } from './helpers/safariFixer.js'
12+
import { enableScrollLock } from './helpers/mobileFixer.js'
1313
import PostMessageService from './services/postMessage.tsx'
1414
import { getCapabilities } from './services/capabilities.ts'
1515
import {

src/helpers/safariFixer.js renamed to src/helpers/mobileFixer.js

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,19 @@
66
let scrollLock = false
77
let intervalHandler
88

9-
const isiOS = [
10-
'iPad Simulator',
11-
'iPhone Simulator',
12-
'iPod Simulator',
13-
'iPad',
14-
'iPhone',
15-
'iPod',
16-
].includes(navigator.platform) || (navigator.userAgent.includes('Mac') && navigator.maxTouchPoints > 1)
17-
18-
// Workaround for Safari automatically scrolling the body when the hidden input is focussed
9+
// Workaround for browsers automatically scrolling the body when the hidden input is focussed
1910
const handleScrollReset = () => {
2011
document.documentElement.scrollTop = 0
2112
document.scrollingElement.scrollTop = 0
2213
}
2314

24-
// Workaround for Safari to resize the iframe to the proper height
25-
// as 100vh is not the proper viewport height there
15+
// Workaround for mobile browsers to resize the iframe to the visual viewport height
16+
// as visual viewport area - which includes OSK, say - is not propagated to iframes
17+
// see https://developer.mozilla.org/en-US/docs/Web/API/VisualViewport
2618
const handleResize = () => {
2719
const expectedHeight = window.visualViewport.height ?? document.documentElement.clientHeight
28-
const frame = document.getElementById('richdocumentsframe')
29-
if (frame) {
20+
const frames = document.getElementsByClassName('office-viewer__iframe')
21+
for (const frame of frames) {
3022
frame.style.maxHeight = expectedHeight + 'px'
3123
}
3224
const viewer = document.querySelector('.office-viewer')
@@ -36,20 +28,18 @@ const handleResize = () => {
3628
}
3729

3830
const fixThemAll = () => {
39-
if (!isiOS) {
40-
return
41-
}
4231
if (!scrollLock) {
4332
return
4433
}
34+
4535
handleScrollReset()
4636
handleResize()
4737
}
4838

4939
const preventDefault = (e) => e.preventDefault()
5040

5141
export const enableScrollLock = () => {
52-
if (scrollLock || !isiOS) {
42+
if (scrollLock) {
5343
return
5444
}
5545

@@ -65,7 +55,7 @@ export const enableScrollLock = () => {
6555
}
6656

6757
export const disableScrollLock = () => {
68-
if (!scrollLock || !isiOS) {
58+
if (!scrollLock) {
6959
return
7060
}
7161

src/view/Office.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ import {
9999
import PostMessageService from '../services/postMessage.tsx'
100100
import FilesAppIntegration from './FilesAppIntegration.js'
101101
import { LOADING_ERROR, checkCollaboraConfiguration, checkProxyStatus } from '../services/collabora.js'
102-
import { enableScrollLock, disableScrollLock } from '../helpers/safariFixer.js'
102+
import { enableScrollLock, disableScrollLock } from '../helpers/mobileFixer.js'
103103
import axios from '@nextcloud/axios'
104104
import {
105105
generateUrl,

0 commit comments

Comments
 (0)