I've followed the tutorial on here but i cant get it to work.
https://blog.appery.io/2015/07/how-to...
my JS asset is:
pre
var onScrollHandler = function(){
window.clearTimeout(self.scrollTimeout);
var onDelay = function(){
var scrollTop = jQuery(window).scrollTop();
var windowHeight = jQuery(window).height();
var scrollHeight = jQuery(document).height();
var scrollBottom = scrollHeight - scrollTop - windowHeight;
Code: Select all
console.log("scrollBottom = " + scrollBottom);
if(scrollBottom < 50)
jQuery(window).trigger("onScrollBottom");
};
self.scrollTimeout = window.setTimeout(onDelay, 500);
};
$(function() {
jQuery(window).scroll(onScrollHandler);
});
/pre
JS on page load:
pre
var onScrollBottom = function(){
Code: Select all
var infiniteList = Apperyio.storage.homeInfinite.get();
if(infiniteList.noMoreItems == "true")
return;
infiniteList.skip = parseInt(infiniteList.skip) + parseInt(infiniteList.limit) + "";
Apperyio.storage.homeInfinite.set(infiniteList);
listReviews.execute();
};
jQuery(window).bind("onScrollBottom", onScrollBottom);
/pre
JS on page show:
pre
$(function() {
jQuery(window).scroll(onScrollHandler);
});
//Here you can set the needed "limit". Currently it's set to 12.
var infiniteList = {limit: "5", skip: "0", noMoreItems: undefined};
Apperyio.storage.homeInfinite.set(infiniteList);
jQuery( window ).scroll(onScrollHandler);
/pre
I also invoke listReviews service on page show.
on service success JS (but before the mapping):
pre
self.homeScrollTop = jQuery(window).scrollTop();
if(data.length == 0){
var infiniteList = Apperyio.storage.homeInfinite.get();
infiniteList.noMoreItems = "true";
Code: Select all
Apperyio.storage.homeInfinite.set(infiniteList);
};
//Where "infinite_list" is your list component name.
self.homeListItems = Apperyio("postList_home").find("li:not([data-appery-tpl])");
homeListItems.detach();
/pre
on service success JS (after mapping):
pre
//Where "infinite_list" is your list component name.
Apperyio("postList_home").prepend(self.homeListItems);
jQuery(window).scrollTop(self.homeScrollTop);
/pre
The limit and skip is set on page show and the service is invoked according to the limit. but when i scroll to the bottom nothing happens.
I had a look at the demo...
http://infinitescroll.app.appery.io/s...
... and every time i scroll here the scrollBottom is shown in the console log.
But when I scroll on my app the scrollBottom is not shown in the console.log. suggesting that the scroll function is not being recognised.
any suggestions?
thank you