使用scrollpagination实现页面底端自动加载无需翻页功能
当阅读到页面最底端的时候,会自动显示一个“加载中”的功能,并自动从服务器端无刷新的将内容下载到本地浏览器显示。
这样的自动加载功能是如何实现的?jQuery的插件 ScrollPagination 可以帮助实现这个功能。
这里是ScrollPagination 功能的原型化代码,
$(function() {
$('#content').scrollPagination({
'contentPage': 'democontent.html', // the page where you are searching for results
'contentData': {}, // you can pass the children().size() to know where is the pagination
// who gonna scroll? in this example, the full window
'scrollTarget': $(window),
// how many pixels before reaching end of the page would loading start?
'heightOffset': ,positives numbers only please
'beforeLoad': function() { // before load, some function, maybe display a preloader div
$('.loading').fadeIn();
},
// after loading, some function to animate results and hide a preloader div
'afterLoad': function(elementsLoaded){
$('.loading').fadeOut();
var i = ;
$(elementsLoaded).fadeInWithDelay();
// if more than 100 results loaded stop pagination (only for test)
if ($('#content').children().size() > ){
$('#content').stopScrollPagination();
}
}
});
// code for fade in element by element with delay
$.fn.fadeInWithDelay = function(){
var delay = ;
return this.each(function(){
$(this).delay(delay).animate({opacity:}, );
delay += ;
});
};
});
这里可以看到jQuery Scroll Pagination的实现效果,
http://andersonferminiano.com/jqueryscrollpagination/
只要将界面不断往下滚动就可以看到。
var page = ;
$(function() {
$('#getAjax').scrollPagination({
'contentPage': '__ACTION__',
// the url you are fetching the results
'contentData': { id : {$Think.request.id}, pic : {$Think.request.pic}, ps : {$ps}, pn : function(){return page} },
// these are the variables you can pass to the request, for example: children().size() to know which page you are
'scrollTarget': $(window),
// who gonna scroll? in this example, the full window
'heightOffset': ,
// it gonna request when scroll is 10 pixels before the page ends
'beforeLoad': function() {
page = page + ;
},
'afterLoad': function(elementsLoaded) { // after loading content, you can use this function to animate your new elements
$(elementsLoaded).fadeInWithDelay();
}
}); // code for fade in element by element
$.fn.fadeInWithDelay = function() {
var delay = ;
return this.each(function() {
$(this).delay(delay).animate({
opacity:
},
);
delay += ;
});
};
});
使用scrollpagination实现页面底端自动加载无需翻页功能的更多相关文章
- 页面滚动动态加载数据,页面下拉自动加载内容 jquery
<!DOCTYPE=html> <html> <head> < script src="js/jquery.js" type=" ...
- Jquery页面滚动动态加载数据,页面下拉自动加载内容
<!DOCTYPE=html> <html> <head> <script src="js/jquery.js" type="t ...
- AngularJS 实现页面滚动到底自动加载数据的功能
要实现这个功能,可以通过https://github.com/sroze/ngInfiniteScroll这个第三方控件来实现.步骤如下: 1. 下载ng-infinite-scroll.js程序ht ...
- AngularJS:实现页面滚动到底自动加载数据的功能
要实现这个功能,可以通过https://github.com/sroze/ngInfiniteScroll这个第三方控件来实现.步骤如下: 1. 下载ng-infinite-scroll.js程序ht ...
- 如何自动加载scratch3.0的页面上实现自动加载原有的作品
首先,我们在安装scratch3.0后,浏览器默认打开的是编程的页面.如下图: 那么我们希望开发一个功能,就是打开的时候默认加入某一个SB3的开发文件 1.首先,我们需要有一个.SB3的开发文件,建议 ...
- Python网络爬虫_爬取Ajax动态加载和翻页时url不变的网页
1 . 什么是 AJAX ? AJAX = 异步 JavaScript 和 XML. AJAX 是一种用于创建快速动态网页的技术. 通过在后台与服务器进行少量数据交换,AJAX 可以使网页实现异步更新 ...
- ★android开发--ListView+Json+异步网络图片加载+滚动翻页的例子(图片能缓存,图片不错乱)
例子中用于解析Json的Gson请自己Google下载 主Activity: package COM.Example.Main; import java.util.HashMap; import ja ...
- [JS前端开发] js/jquery控制页面动态加载数据 滑动滚动条自动加载事件
页面滚动动态加载数据,页面下拉自动加载内容 相信很多人都见过瀑布流图片布局,那些图片是动态加载出来的,效果很好,对服务器的压力相对来说也小了很多 有手机的相信都见过这样的效果:进入qq空间,向下拉动空 ...
- Python3从零开始爬取今日头条的新闻【三、滚动到底自动加载】
Python3从零开始爬取今日头条的新闻[一.开发环境搭建] Python3从零开始爬取今日头条的新闻[二.首页热点新闻抓取] Python3从零开始爬取今日头条的新闻[三.滚动到底自动加载] Pyt ...
随机推荐
- 《TypeScript 中文入门教程》 1、基础数据类型
转载:https://github.com/MyErpSoft/TypeScript-Handbook/blob/master/pages/zh-CHS/Basic%20Types.md 概述 为了让 ...
- 最短路径之Floyd算法
Floyd算法又称弗洛伊德算法,也叫做Floyd's algorithm,Roy–Warshall algorithm,Roy–Floyd algorithm, WFI algorithm. Floy ...
- MVC Razor语法
Razor语法, 视图引擎 Razor(CSHTML) @ 可以编写一条C#语句@{} 可以编写一组C#语句,也有可能嵌着Html@: 将文字内容直接输出到页面上去@() 在一句中将一段C#代码包括起 ...
- Linux(Centos)之安装Nginx及注意事项
1.Nginx的简单说明 a. Nginx是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP服务器,期初开发的目的就是为了代理电子邮件服务器室友:Igor Sysoev开发 ...
- Unable to extract 64-bitimage. Run Process Explorer from a writeable directory
Unable to extract 64-bitimage. Run Process Explorer from a writeable directory When we run Process E ...
- 自定义View字段表头
适用场景: 三个列表进行Join,然后试图上显示ProjectedField,而ProjectedField不支持设置DisplayName.默认只能显示英文名. join caml如下: <V ...
- jQuery介绍 DOM对象和jQuery对象的转换与区别
jQuery介绍 DOM对象和jQuery对象的转换与区别 jQuery介绍 jQuery: http://jquery.com/ write less, do more. j ...
- HotApp小程序统计云后台 免费的Https云后台服务器,方便学习小程序
小程序学习有些地方需要后台,比如需要存储数据到服务器,比如微信登录. hotapp有免费的小程序云后台 包含基本的 新增,查询,修改,删除 操作,方便于学习,而且不需要微信appid 也可使用. 小程 ...
- Mac ping localhost 地址变化
title: Mac ping localhost 地址变化date: 2016-1-15 16:21:55categories: IOS tags: mac 小小程序猿我的博客:http://day ...
- Android—定位
public class MainActivity extends AppCompatActivity implements View.OnClickListener { private Button ...