From 1c0a0880fc904714339f059658f3ba3a88bb8e6e Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 11 Mar 2024 13:51:35 +0100 Subject: [PATCH] Use window.visualViewport for window size for scrolling FIX: Fix an issue where some commands didn't properly scroll the cursor into view on Mobile Safari. --- src/dom.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/dom.ts b/src/dom.ts index 193d86b..ec223a5 100644 --- a/src/dom.ts +++ b/src/dom.ts @@ -94,6 +94,11 @@ export function flattenRect(rect: Rect, left: boolean) { } function windowRect(win: Window): Rect { + let vp = win.visualViewport + if (vp) return { + left: 0, right: vp.width, + top: 0, bottom: vp.height + } return {left: 0, right: win.innerWidth, top: 0, bottom: win.innerHeight} }