feat(forums): add 'upToTop' directive to scroll window to top

This commit is contained in:
OldHawk
2017-11-17 15:55:57 +08:00
parent 9d2f567dff
commit c8696f4032
5 changed files with 143 additions and 4 deletions

View File

@@ -7,11 +7,11 @@
ForumsTopicController.$inject = ['$scope', '$state', '$translate', 'Authentication', 'MeanTorrentConfig', 'ForumsService', 'ScoreLevelService', '$timeout', 'NotifycationService',
'marked', 'ModalConfirmService', '$stateParams', 'TopicsService', 'localStorageService', '$compile', 'RepliesService', '$filter', 'Upload', 'DownloadService',
'DebugConsoleService'];
'DebugConsoleService', '$window'];
function ForumsTopicController($scope, $state, $translate, Authentication, MeanTorrentConfig, ForumsService, ScoreLevelService, $timeout, NotifycationService,
marked, ModalConfirmService, $stateParams, TopicsService, localStorageService, $compile, RepliesService, $filter, Upload, DownloadService,
mtDebug) {
mtDebug, $window) {
var vm = this;
vm.DLS = DownloadService;
vm.forumsConfig = MeanTorrentConfig.meanTorrentConfig.forumsConfig;
@@ -23,6 +23,26 @@
vm.forumPath = [];
vm.postReplyFields = {};
angular.element($window).bind('scroll', function (e) {
var scTop = angular.element('#top_of_reply_list').prop('offsetTop') - 60;
if ($(window).scrollTop() > scTop) {
//alert('boom');up-to-top
angular.element('.up-to-top').css('display', 'block');
} else {
angular.element('.up-to-top').css('display', 'none');
}
});
/**
* upToTop
*/
vm.upToTop = function () {
var element = angular.element('#top_of_reply_list');
$timeout(function () {
$('html,body').animate({scrollTop: element[0].offsetTop - 60}, 200);
}, 10);
};
/**
* buildPager
* pagination init