From 482ee30bf551397433973e77a4bae7bbf1a1b687 Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Fri, 11 Oct 2013 00:52:16 +0200 Subject: [PATCH] Try to fix scroll issues --- js/websockets.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/js/websockets.js b/js/websockets.js index 3ca9d15..3a98523 100644 --- a/js/websockets.js +++ b/js/websockets.js @@ -384,7 +384,7 @@ weechat.factory('connection', ['$rootScope', '$log', 'handlers', 'colors', 'mode } }]); -weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', 'models', 'connection', function ($rootScope, $scope, $store, models, connection, testService) { +weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', 'models', 'connection', function ($rootScope, $scope, $store, $timeout, models, connection, testService) { // Request notification permission Notification.requestPermission(function (status) { @@ -432,18 +432,17 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', 'models', ' models.setActiveBuffer(key); var ab = models.getActiveBuffer(); $rootScope.pageTitle = ab.shortName + ' | ' + ab.title; - $rootScope.scrollToBottom(); }; - $rootScope.$watch('activeBuffer', function(newVal, oldVal) { + $scope.$watch('models.getActiveBuffer()', function(newVal, oldVal) { if (newVal && newVal !== oldVal) { $rootScope.scrollToBottom(); } }); $rootScope.scrollToBottom = function() { - setTimeout(function() { - window.scrollTo(0, window.scrollMaxY); + $timeout(function(){ + window.scrollTo(0, window.scrollMaxY-1); }); }