zippy1978 / jquery.scrollz

Modern scrolling for jQuery
GNU General Public License v2.0
81 stars 17 forks source link

How to disable automatic pull after document is finish loading #22

Open mal3k opened 10 years ago

mal3k commented 10 years ago

In mobile.html, I noticed the pull is launched automatically after the document has finished loading. I would love to know how to disable that on the document load and only keep it on user pull event. Thanks

zippy1978 commented 10 years ago

Hi, The best is to disable content loading initially.

If you look at the code of the mobile.html example:

  1. Comment the initial data loading and hide the pull header:

       // Load initial items
       //loadMore();
       setTimeout(function() {
           $('#content').scrollz('hidePullHeader', false);
       }, 20);
  2. Modify the bottomreached event handling to prevent loading more items if the current list is still empty:

       // Bind events
       $(document).on('bottomreached', '#content', function() {
           // Load more
         if ($('#items li').length > 0) {
           loadMore();
         }
    
       });

I hope it will help you.

Regards, Gilles