From 838eca8fe5b3083dc676896f0f138086327d4093 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Mon, 10 Jul 2017 19:16:20 +0300 Subject: [PATCH] Fix scrolling issue --- client/js/socket-events/more.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/client/js/socket-events/more.js b/client/js/socket-events/more.js index b1c4ac0b..20d5c12d 100644 --- a/client/js/socket-events/more.js +++ b/client/js/socket-events/more.js @@ -38,7 +38,13 @@ socket.on("more", function(data) { // restore scroll position const position = chan.height() - heightOld; - scrollable.scrollTop(position); + scrollable.finish().scrollTop(position); + + // We have to do this hack due to smooth scrolling in browsers, + // as scrollTop does not apply correctly + if (window.requestAnimationFrame) { + window.requestAnimationFrame(() => scrollable.scrollTop(position)); + } if (data.messages.length !== 100) { scrollable.find(".show-more").removeClass("show");