jQuery插件实现新浪微博自动底部加载

新浪微博网页自动底部加载的效果很酷吧?其实这种叫做“无限滚动的翻页技术”,当你页面滑到列表底部时候无需点击就自动加载更多的内容。

其实有很多jQuery的插件都已经实现了这个效果,我们来介绍几个吧!


1、jQuery ScrollPagination

jQuery ScrollPagination plugin 是一个jQuery 实现的支持无限滚动加载数据的插件。

地址:http://andersonferminiano.com/jqueryscrollpagination/

他的demo下载:http://andersonferminiano.com/jqueryscrollpagination/jqueryscrollpagination.zip


实例代码:

 
 
  1. $(function(){
  2. $('#content').scrollPagination({
  3. 'contentPage': 'democontent.html', // the url you are fetching the results
  4. 'contentData': {}, // these are the variables you can pass to the request, for example: children().size() to know which page you are
  5. 'scrollTarget': $(window), // who gonna scroll? in this example, the full window
  6. 'heightOffset': 10, // it gonna request when scroll is 10 pixels before the page ends
  7. 'beforeLoad': function(){ // before load function, you can display a preloader div
  8. $('#loading').fadeIn();
  9. },
  10. 'afterLoad': function(elementsLoaded){ // after loading content, you can use this function to animate your new elements
  11. $('#loading').fadeOut();
  12. var i = 0;
  13. $(elementsLoaded).fadeInWithDelay();
  14. if ($('#content').children().size() > 100){ // if more than 100 results already loaded, then stop pagination (only for testing)
  15. $('#nomoreresults').fadeIn();
  16. $('#content').stopScrollPagination();
  17. }
  18. }
  19. });
  20.  
  21. // code for fade in element by element
  22. $.fn.fadeInWithDelay = function(){
  23. var delay = 0;
  24. return this.each(function(){
  25. $(this).delay(delay).animate({opacity:1}, 200);
  26. delay += 100;
  27. });
  28. };
  29.  
  30. });

2、 jQuery Screw

Screw (scroll + view) 是一个 jQuery 插件当用户滚动页面的时候加载内容,是一个无限滚动翻页的插件。

官方地址:https://github.com/jasonlau/jQuery-Screw

3. AutoBrowse jQuery Plugin

Autobrowse jQuery Plugin 插件在用户滚动页面的时候自动通过 Ajax 加载更多内容,使用浏览器内置缓存。

官方地址:https://github.com/msjolund/jquery-esn-autobrowse



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值