From 9a1bcf0cc089f9e7ed14dd5473b3b8100cefdb90 Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Fri, 11 Oct 2013 18:45:01 +0200 Subject: [PATCH] Check for element before scrolling --- js/websockets.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/js/websockets.js b/js/websockets.js index 21c745b..01f2965 100644 --- a/js/websockets.js +++ b/js/websockets.js @@ -449,7 +449,10 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', // 300 ms seems to do the trick but creates a noticable flickr $timeout(function() { // TODO in the future, implement scrolling to last read line - window.scrollTo(0, document.querySelector('.bufferline:last-child').offsetTop); + var lastline = document.querySelector('.bufferline:last-child'); + if(lastline) { + window.scrollTo(0, lastline.offsetTop); + } }, 300); }