Fix scrolling issue

This commit is contained in:
Pavel Djundik 2017-07-10 19:16:20 +03:00 committed by Jérémie Astori
parent 629592d641
commit 838eca8fe5
No known key found for this signature in database
GPG Key ID: B9A4F245CD67BDE8

View File

@ -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");