mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-09-18 20:07:58 +00:00
fix(mail): Restore scroll position when refreshing emails
This commit is contained in:
@@ -22,10 +22,10 @@
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
sgMessageListItemController.$inject = ['$scope', '$element', 'Mailbox'];
|
||||
function sgMessageListItemController($scope, $element, Mailbox) {
|
||||
sgMessageListItemController.$inject = ['$scope', '$element', '$timeout', 'Mailbox'];
|
||||
function sgMessageListItemController($scope, $element, $timeout, Mailbox) {
|
||||
var $ctrl = this;
|
||||
|
||||
var scrollPosition = 0;
|
||||
|
||||
this.$onInit = function () {
|
||||
var watchedAttrs = ['uid', 'isread', 'isflagged', 'flags', 'loading'];
|
||||
@@ -77,6 +77,28 @@
|
||||
element.classList.add('ng-hide');
|
||||
};
|
||||
|
||||
// The following functions are used to store and restore the scroll position of the message list
|
||||
// Position is stored and restored through the Mailbox service using broadcasting
|
||||
function storeScrollPosition() {
|
||||
if ($element.parent()[0] && $element.parent()[0].parentElement && $element.parent()[0].parentElement.parentElement)
|
||||
scrollPosition = $element.parent()[0].parentElement.parentElement.scrollTop;
|
||||
}
|
||||
|
||||
function restoreScrollPosition() {
|
||||
$timeout(function () {
|
||||
if ($element.parent()[0] && $element.parent()[0].parentElement && $element.parent()[0].parentElement.parentElement)
|
||||
$element.parent()[0].parentElement.parentElement.scrollTop = scrollPosition;
|
||||
}, 0);
|
||||
}
|
||||
|
||||
$scope.$on('listRefreshed', function () {
|
||||
restoreScrollPosition();
|
||||
});
|
||||
|
||||
$scope.$on('beforeListRefresh', function () {
|
||||
storeScrollPosition();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user