From a505c146f297b6561c658163de308c575f40736e Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Tue, 22 Oct 2013 19:58:12 +0200 Subject: [PATCH] Trying to improve scrolling. Still not elegant --- js/websockets.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/js/websockets.js b/js/websockets.js index 0928911..9a65798 100644 --- a/js/websockets.js +++ b/js/websockets.js @@ -425,17 +425,23 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', $rootScope.scrollToBottom = function() { // FIXME doesn't work if the settimeout runs without a short delay - // 300 ms seems to do the trick but creates a noticable flickr var scroll = function() { var readmarker = document.getElementById('readmarker'); if(readmarker) { - readmarker.scrollIntoView(); + readmarker.scrollIntoView(); }else{ - window.scroll(0, document.documentElement.scrollHeight - document.documentElement.clientHeight); + var sTop = document.documentElement.scrollTop; + var sVal = document.documentElement.scrollHeight - document.documentElement.clientHeight; + if(sTop < sVal) { + document.documentElement.scrollTop = sVal; + } } } - scroll(); + // Here be scrolling dragons + $timeout(scroll); + $timeout(scroll, 100); $timeout(scroll, 300); + $timeout(scroll, 500); } $scope.sendMessage = function() {