mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-02-27 16:50:59 +01:00
feat(forums): add 'upToTop' directive to scroll window to top
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user