I have a class which I call via:
this.infiniteScroll = new gd.InfiniteScroll();
In this class it checks if user is at bottom of window.
Later on in my script I have no use for this infinite scroll script (as all data has been loaded). How can I delete it? or stop it from checking if user is at bottom of window?
Here's the infinite scroll class:
(function(){
"use strict";
var InfiniteScroll = function() {
this.init();
};
var p = InfiniteScroll.prototype = gd.BaseClass.extend(gd.BaseClass);
p.BaseClass_init = p.init;
/*
* Public properties
*/
p.canLoad = true;
p.cog;
/*
* Public methods
*/
p.init = function() {
// Super
this.BaseClass_init();
// Init
this.ready();
};
p.ready = function() {
this._initInfiniteScroll();
};
p.loadRequested = function(){
p.canLoad = false;
console.log('show cog');
$.event.trigger('loadRequested');
}
p.loadComplete = function(){
p.canLoad = true;
console.log('hide cog');
console.log(p.canLoad);
}
p._initInfiniteScroll = function() {
$(window).scroll(function(){
console.log('scroll!');
if(($(window).scrollTop() == ($(document).height() - $(window).height())) && p.canLoad){
p.loadRequested();
}
});
}
gd.InfiniteScroll = InfiniteScroll;
}(window));