FIX: Use scrollY for current scroll position

FIX: Use scrollY for current scroll position

This replaces an invalid window.scrollTop occurrence, left over from a jQuery refactoring. It should fix an undesirable “shake effect” I have run into in Safari when navigating to a reply in the post stream.

diff --git a/app/assets/javascripts/discourse/app/lib/lock-on.js b/app/assets/javascripts/discourse/app/lib/lock-on.js
index c0af323..941e7d4 100644
--- a/app/assets/javascripts/discourse/app/lib/lock-on.js
+++ b/app/assets/javascripts/discourse/app/lib/lock-on.js
@@ -113,10 +113,7 @@ export default class LockOn {
       return this.clearLock();
     }
 
-    if (
-      !within(4, top, this.previousTop) ||
-      !within(4, window.scrollTop, top)
-    ) {
+    if (!within(4, top, this.previousTop) || !within(4, window.scrollY, top)) {
       window.scrollTo(window.pageXOffset, top);
       this.previousTop = top;
     }

GitHub sha: 59a83634

2 Likes