fix previous commit so it only uses window height if viewport <=0

v1.18.x
barisusakli 10 years ago
parent e78de34122
commit b2dbb127e2

@ -12,19 +12,22 @@ define('forum/infinitescroll', ['translator'], function(translator) {
scroll.init = function(el, cb) {
if (typeof el === 'function') {
cb = el;
el = null;
callback = el;
container = $(document);
} else {
callback = cb;
container = el || $(document);
}
callback = cb;
container = el || $(document);
$(window).off('scroll', onScroll).on('scroll', onScroll);
};
function onScroll() {
var currentScrollTop = $(window).scrollTop();
var wh = $(window).height();
var viewportHeight = container.height() - wh;
var offsetTop = container.offset() ? container.offset().top : 0;
var scrollPercent = 100 * (currentScrollTop - offsetTop) / Math.max(wh, (container.height() - wh));
var scrollPercent = 100 * (currentScrollTop - offsetTop) / (viewportHeight <= 0 ? wh : viewportHeight);
var top = 20, bottom = 80;

@ -22,7 +22,7 @@ define('forum/recent', ['forum/infinitescroll', 'components'], function(infinite
$('#new-topics-alert').on('click', function() {
$(this).addClass('hide');
});
console.log('da fuq is going on')
infinitescroll.init(Recent.loadMoreTopics);
};

Loading…
Cancel
Save