From 6e982e6e011db931db26bb94ec306415a1582671 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 11 Jul 2023 12:29:58 +0200 Subject: [PATCH] Preventing the body scrolling no longer requires a hack on non-iOS devices --- ts/WoltLabSuite/Core/Ui/Screen.ts | 7 ++----- wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Screen.js | 9 ++------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/ts/WoltLabSuite/Core/Ui/Screen.ts b/ts/WoltLabSuite/Core/Ui/Screen.ts index bd59cdef9a..095ec3f74b 100644 --- a/ts/WoltLabSuite/Core/Ui/Screen.ts +++ b/ts/WoltLabSuite/Core/Ui/Screen.ts @@ -103,12 +103,11 @@ export function scrollDisable(): void { const pageContainer = document.getElementById("pageContainer")!; - // setting translateY causes Mobile Safari to snap + // iOS does not handle overflow and fixed positioning well, we need to + // simulate the scrolling by vertically moving the container. if (Environment.platform() === "ios") { pageContainer.style.setProperty("position", "relative", ""); pageContainer.style.setProperty("top", `-${_scrollTop}px`, ""); - } else { - pageContainer.style.setProperty("margin-top", `-${_scrollTop}px`, ""); } document.documentElement.classList.add("disableScrolling"); @@ -131,8 +130,6 @@ export function scrollEnable(): void { if (Environment.platform() === "ios") { pageContainer.style.removeProperty("position"); pageContainer.style.removeProperty("top"); - } else { - pageContainer.style.removeProperty("margin-top"); } if (_scrollTop) { diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Screen.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Screen.js index 13265a4f05..3634799b18 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Screen.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Screen.js @@ -92,14 +92,12 @@ define(["require", "exports", "tslib", "../Core", "../Environment"], function (r _scrollOffsetFrom = "documentElement"; } const pageContainer = document.getElementById("pageContainer"); - // setting translateY causes Mobile Safari to snap + // iOS does not handle overflow and fixed positioning well, we need to + // simulate the scrolling by vertically moving the container. if (Environment.platform() === "ios") { pageContainer.style.setProperty("position", "relative", ""); pageContainer.style.setProperty("top", `-${_scrollTop}px`, ""); } - else { - pageContainer.style.setProperty("margin-top", `-${_scrollTop}px`, ""); - } document.documentElement.classList.add("disableScrolling"); } _scrollDisableCounter++; @@ -118,9 +116,6 @@ define(["require", "exports", "tslib", "../Core", "../Environment"], function (r pageContainer.style.removeProperty("position"); pageContainer.style.removeProperty("top"); } - else { - pageContainer.style.removeProperty("margin-top"); - } if (_scrollTop) { document[_scrollOffsetFrom].scrollTop = ~~_scrollTop; } -- 2.20.1