From b84f36cc201c61cc65af85729eea6e7afe75d2d0 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Wed, 31 Aug 2016 23:15:17 +0300 Subject: [PATCH] fix navigator method not getting removed --- public/src/modules/navigator.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/public/src/modules/navigator.js b/public/src/modules/navigator.js index a70ca1939a..de49cfd1f7 100644 --- a/public/src/modules/navigator.js +++ b/public/src/modules/navigator.js @@ -9,6 +9,8 @@ define('navigator', ['forum/pagination', 'components'], function(pagination, com var navigator = {}; var index = 1; var count = 0; + var navigatorUpdateTimeoutId = 0; + navigator.scrollActive = false; navigator.init = function(selector, count, toTop, toBottom, callback, calculateIndex) { @@ -17,15 +19,8 @@ define('navigator', ['forum/pagination', 'components'], function(pagination, com navigator.callback = callback; toTop = toTop || function() {}; toBottom = toBottom || function() {}; - var navigatorUpdateTimeoutId = 0; - $(window).off('scroll', navigator.update).on('scroll', function() { - if (navigatorUpdateTimeoutId) { - clearTimeout(navigatorUpdateTimeoutId); - navigatorUpdateTimeoutId = 0; - } - navigatorUpdateTimeoutId = setTimeout(navigator.update, 100); - }); + $(window).off('scroll', navigator.delayedUpdate).on('scroll', navigator.delayedUpdate); $('.pagination-block .dropdown-menu').off('click').on('click', function(e) { e.stopPropagation(); @@ -98,6 +93,14 @@ define('navigator', ['forum/pagination', 'components'], function(pagination, com $('.pagination-block').toggleClass('ready', flag); } + navigator.delayedUpdate = function() { + if (navigatorUpdateTimeoutId) { + clearTimeout(navigatorUpdateTimeoutId); + navigatorUpdateTimeoutId = 0; + } + navigatorUpdateTimeoutId = setTimeout(navigator.update, 100); + }; + navigator.update = function(threshold) { /* The "threshold" is defined as the distance from the top of the page to @@ -136,7 +139,7 @@ define('navigator', ['forum/pagination', 'components'], function(pagination, com } else if (nearBottom) { index = count; } - +console.log('wtf', index ,count) // If a threshold is undefined, try to determine one based on new index if (threshold === undefined && ajaxify.data.template.topic === true) { if (atTop) {