Workaround for unfreezing the screen in iOS Safari
authorAlexander Ebert <ebert@woltlab.com>
Mon, 9 Aug 2021 16:36:13 +0000 (18:36 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 9 Aug 2021 16:36:13 +0000 (18:36 +0200)
The change to the CSS class and the properties cause a recalculation that could sometimes interfere with the page scrolling.

Forcing the scrolling into the next iteration of the event loop solves this issue by separating both actions. Since the scrolling does depend on the actions in the lines above it, this is reasonably safe to do.

ts/WoltLabSuite/Core/Ui/Screen.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Screen.js

index 9e330b895c7d16880aa4c00c4d130c1b51ac5ac3..1ae58614fb1262eeb7b4fb153a97a3e5de1563ec 100644 (file)
@@ -138,7 +138,10 @@ export function scrollEnable(): void {
       }
 
       if (_scrollTop) {
-        document[_scrollOffsetFrom].scrollTop = ~~_scrollTop;
+        // Slightly delay this to prevent conflicts caused by a CSS recalculation.
+        window.setTimeout(() => {
+          document[_scrollOffsetFrom].scrollTop = ~~_scrollTop;
+        }, 1);
       }
     }
   }
index 26cae7dd847990781294e30c92648186c6228d34..1f9807a03b18d0ab2b21e723307ef4146784133f 100644 (file)
@@ -124,7 +124,10 @@ define(["require", "exports", "tslib", "../Core", "../Environment"], function (r
                     pageContainer.style.removeProperty("margin-top");
                 }
                 if (_scrollTop) {
-                    document[_scrollOffsetFrom].scrollTop = ~~_scrollTop;
+                    // Slightly delay this to prevent conflicts caused by a CSS recalculation.
+                    window.setTimeout(() => {
+                        document[_scrollOffsetFrom].scrollTop = ~~_scrollTop;
+                    }, 1);
                 }
             }
         }