mirror of
https://github.com/pinry/pinry.git
synced 2025-11-18 02:40:40 +01:00
Don't load Pins "in background" when lightbox is active.
Remove the scroll event handler when lightbox is active, so pins are not loaded in background breaking the page layout.
This commit is contained in:
@@ -22,12 +22,22 @@ $(window).load(function() {
|
||||
'margin-top': -$('body').data('scroll-level')
|
||||
});
|
||||
$(window).scrollTop(0);
|
||||
/* disable the global pin-loading scroll handler so we don't
|
||||
load pins when scrolling a selected image */
|
||||
$(window).off('scroll');
|
||||
} else {
|
||||
$('#pins').css({
|
||||
'position': 'static',
|
||||
'margin-top': 0
|
||||
});
|
||||
$(window).scrollTop($('body').data('scroll-level'));
|
||||
/* enable the pin-loading scroll handler unless we've already
|
||||
loaded all pins from the server (in which case an element
|
||||
with id 'the-end' exists */
|
||||
var theEnd = document.getElementById('the-end');
|
||||
if (!theEnd) {
|
||||
$(window).scroll(scrollHandler);
|
||||
}
|
||||
}
|
||||
}
|
||||
// End Helper Functions
|
||||
|
||||
@@ -91,6 +91,14 @@ $(window).load(function() {
|
||||
blockContainer.css('height', colHeights.sort().slice(-1)[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* On scroll load more pins from the server
|
||||
*/
|
||||
window.scrollHandler = function() {
|
||||
var windowPosition = $(window).scrollTop() + $(window).height();
|
||||
var bottom = $(document).height() - 100;
|
||||
if(windowPosition > bottom) loadPins();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load our pins using the pins template into our UI, be sure to define a
|
||||
@@ -138,11 +146,7 @@ $(window).load(function() {
|
||||
$('body').append(theEnd);
|
||||
}
|
||||
} else {
|
||||
$(window).scroll(function() {
|
||||
var windowPosition = $(window).scrollTop() + $(window).height();
|
||||
var bottom = $(document).height() - 100;
|
||||
if(windowPosition > bottom) loadPins();
|
||||
});
|
||||
$(window).scroll(scrollHandler);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user