Check for element before scrolling

This commit is contained in:
Tor Hveem 2013-10-11 18:45:01 +02:00
parent 2ee29923c1
commit 9a1bcf0cc0
1 changed files with 4 additions and 1 deletions

View File

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