From 351875cda45a6f8f975016a42a8f571d3597c0e9 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Tue, 24 Mar 2015 18:51:55 +0300 Subject: [PATCH] Fixed focus scroll problem --- app/js/controllers.js | 7 +++++-- app/js/directives.js | 9 ++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/js/controllers.js b/app/js/controllers.js index 0514a388..650b8f6c 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -1165,10 +1165,10 @@ angular.module('myApp.controllers', ['myApp.i18n']) $scope.state.mayBeHasMore = true; - console.log(dT(), 'start load history', $scope.curDialog); + // console.log(dT(), 'start load history', $scope.curDialog); getMessagesPromise.then(function (historyResult) { if (curJump != jump) return; - console.log(dT(), 'history loaded', historyResult); + // console.log(dT(), 'history loaded', historyResult); var fetchedLength = historyResult.history.length; @@ -1401,6 +1401,9 @@ angular.module('myApp.controllers', ['myApp.i18n']) } return; } + if ($scope.curDialog.messageID && addedMessage.my) { + returnToRecent(); + } delete $scope.state.empty; } // console.log('append', addedMessage); diff --git a/app/js/directives.js b/app/js/directives.js index fe25429c..60d8f058 100755 --- a/app/js/directives.js +++ b/app/js/directives.js @@ -888,7 +888,7 @@ angular.module('myApp.directives', ['myApp.filters']) if (options.idleScroll) { onContentLoaded(function () { $(historyWrap).nanoScroller(); - changeScroll(); + changeScroll(true); }); return; } @@ -929,11 +929,12 @@ angular.module('myApp.directives', ['myApp.filters']) }); }); - function changeScroll () { + function changeScroll (noFocus) { var unreadSplit, focusMessage; // console.trace('change scroll'); - if (focusMessage = $('.im_message_focus:visible', scrollableWrap)[0]) { + if (!noFocus && + (focusMessage = $('.im_message_focus:visible', scrollableWrap)[0])) { var ch = scrollableWrap.clientHeight, st = scrollableWrap.scrollTop, ot = focusMessage.offsetTop, @@ -979,6 +980,7 @@ angular.module('myApp.directives', ['myApp.filters']) $scope.$on('ui_history_focus', function () { if (!atBottom) { + // console.log(dT(), 'scroll history focus'); scrollableWrap.scrollTop = scrollableWrap.scrollHeight; updateScroller(); atBottom = true; @@ -1124,6 +1126,7 @@ angular.module('myApp.directives', ['myApp.filters']) if (heightOnly === true) return; if (atBottom) { onContentLoaded(function () { + // console.log('change scroll bottom'); scrollableWrap.scrollTop = scrollableWrap.scrollHeight; updateScroller(); });