Code Monkey home page Code Monkey logo

datalazyload's Introduction

Data Lazy Load Plugin for jQuery

Lazy Load delays loading of data in long web pages like sina weibo.

How to Use?

Load jQuery and jquery.lazyload.min.js

<script src="jquery.js" type="text/javascript"></script>
<script src="DataLazyLoad.min.js" type="text/javascript"></script>

Add the HTML code

<ul class = 'list'>
<li>aaaa</li>
<li>bbbb</li>
<li>cccc</li>
<li>dddd</li>
<li>eeee</li>
<li>ffff</li>
<li>gggg</li>
</ul>

Call DataLazyLoad

//Call DataLazyLoad
$(function(){
  $(".list").DataLazyLoad({load : function(page, unLocked)
  {
      var html = '';
      var max = 10;
      //Generate the data
      for (var i = 0; i < 10; i++)
      {
           html += '<li>Page: ' + page + ', Data Index: ' + i + ' </li>';
      }
      $(html).appendTo('.list');
      //Check whether to end
      page = page >= max ? 0 : page + 1;
      //You must call after loading the data, To prevent repeated load, The first parameter to the next page, No page is 0
      unLocked(page);
      if (page == 0)
      {
          $("<li class = 'h2'>The End!</li>").appendTo('.list');
      }
  }});
});

DEMO && EXAMPLES

EXAMPLES

DEMO

Options

$(".list").DataLazyLoad(options);

|parameter|type|default|description| |---|:---|:---:|:---:|---:| |offset|int|200|When less than offset distance at the bottom of the page to load data.| |load|function|function(page, unLocked){}|The load data handler. Parameters: page is Need to load the page, unLocked is a function. After loading the data must be called unLocked function, and pass nextPage parameters.| |page|int|2|Loading page Numbers for the first time|

License

All code licensed under the MIT License. All images licensed under Creative Commons Attribution 3.0 Unported License. In other words you are basically free to do whatever you want. Just don’t remove my name from the source.

datalazyload's People

Contributors

logbird avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.