[situation] I have problems about photoswipe close. I have a html page A using Photoswipe for a photo view. I have defined a scroll event in page A. When I open and then close photoswipe and go back to my page A, the scroll event is not working any more.
My scroll event:
$(window).scroll(function(){
if ((getDocumentHeight() - getWindowHeight() - getSrollHeight()) == 0) {
alert("buttom");
};
});
I noticed photoswipe's close and destory method call _unbindEvents
methods, which executes the unbind function.
// Closes the gallery, then destroy it
close: function() {
if(!_isOpen) {
return;
}
_isOpen = false;
_isDestroying = true;
_shout('close');
_unbindEvents();
_showOrHide( self.currItem, null, true, self.destroy);
},
// destroys gallery (unbinds events, cleans up intervals and timeouts to avoid memory leaks)
destroy: function() {
_shout('destroy');
if(_showOrHideTimeout) {
clearTimeout(_showOrHideTimeout);
}
template.setAttribute('aria-hidden', 'true');
template.className = _initalClassName;
if(_updateSizeInterval) {
clearInterval(_updateSizeInterval);
}
framework.unbind(self.scrollWrap, _downEvents, self);
// we unbind lost event at the end, as closing animation may depend on it
framework.unbind(window, 'scroll', self);
_stopDragUpdateLoop();
_stopAllAnimations();
_listeners = null;
},
_unbindEvents = function() {
framework.unbind(window, 'resize', self);
framework.unbind(window, 'scroll', _globalEventHandlers.scroll);
framework.unbind(document, 'keydown', self);
framework.unbind(document, 'mousemove', _onFirstMouseMove);
if(_features.transform) {
framework.unbind(self.scrollWrap, 'click', self);
}
if(_isDragging) {
framework.unbind(window, _upMoveEvents, self);
}
_shout('unbindEvents');
},
[question] How can I prevent photoswipe to unbind my scroll event?
I have fixed this problem.
$(document).scroll()
instead of
$(window).scroll()
It's working.