转 js Infinite Scrolling Demo
原文:http://www.sitepoint.com/jquery-infinite-scrolling-demos/
Infinite Scrolling Demo 5
Usage – HTML
<ul class="items">
<li>content</li>
<li>content</li>
...
</ul>
<div id="lastPostsLoader"></div>
Usage – jQuery
<script type="text/javascript">
$(document).ready(function(){
function lastAddedLiveFunc()
{
$('div#lastPostsLoader').html('<img src="bigLoader.gif"/>'); $.get("loadmore.php", function(data){
if (data != "") {
//console.log('add data..');
$(".items").append(data);
}
$('div#lastPostsLoader').empty();
});
}; //lastAddedLiveFunc();
$(window).scroll(function(){ var wintop = $(window).scrollTop(), docheight = $(document).height(), winheight = $(window).height();
var scrolltrigger = 0.95; if ((wintop/(docheight-winheight)) > scrolltrigger) {
//console.log('scroll bottom');
lastAddedLiveFunc();
}
});
});
</script>
Infinite Scrolling Demo 3
This demo loads in images on infinite scroll and never reaches the end. It uses the jquery.endless-scroll plugin which can be customised to trigger load for x number of pixels from the bottom of the screen. The demo clones the same images and inserts them at the end of the list and so on. Obviously the script can be customised to load more images from different sources quite easily
Usage – HTML
<ul id="images">
<li><img src="img/grass-blades.jpg" width="580" height="360" alt="Grass Blades" /></li>
<li><img src="img/stones.jpg" width="580" height="360" alt="Stones" /></li>
<li><img src="img/sea-mist.jpg" width="580" height="360" alt="Sea Mist" /></li>
<li><img src="img/pier.jpg" width="580" height="360" alt="Pier" /></li>
<li><img src="img/lotus.jpg" width="580" height="360" alt="Lotus" /></li>
<li><img src="img/mojave.jpg" width="580" height="360" alt="Mojave" /></li>
<li><img src="img/lightning.jpg" width="580" height="360" alt="Lightning" /></li>
</ul>
Usage – jQuery
<script type="text/javascript" src="js/jquery.endless-scroll.js"></script>
<script type="text/javascript" charset="utf-8">
$(function() {
$(document).endlessScroll({
bottomPixels: 500,
fireDelay: 10,
callback: function(i) {
var last_img = $("ul#images li:last");
last_img.after(last_img.prev().prev().prev().prev().prev().prev().clone());
}
});
});
</script>
var end = $("#BottomThing").offset().top;
var viewEnd = $(window).scrollTop() + $(window).height();
var distance = end - viewEnd;
if (distance < 300) // do load –
转 js Infinite Scrolling Demo的更多相关文章
- A Xamarin.Forms Infinite Scrolling ListView
from:http://www.codenutz.com/lac09-xamarin-forms-infinite-scrolling-listview/ The last few months ha ...
- 在线浏览PDF之PDF.JS (附demo)
平台之大势何人能挡? 带着你的Net飞奔吧!:http://www.cnblogs.com/dunitian/p/4822808.html#skill 下载地址:http://mozilla.gith ...
- echarts.js使用心得--demo
首先要感谢一下我的公司,因为公司需求上面的新颖(奇葩)的需求,让我有幸可以学习到一些好玩有趣的前端技术. 废话不多时 , 直接开始. 第一步: 导入echarts.js文件 下载地址:http://e ...
- 使用IDEA+vue.js+easyUI的demo
最近,随便写了几个开发的小例子,自己总结下,留个纪念. 例子1:使用EasyUI做了一个简单界面,服务器和客户端在一起. @Controller @RequestMapping("/demo ...
- 值得H5前端学习的60个JS插件(含DEMO演示)
下面也可以说是H5前端学习的js插件大全.基本包含了大部分的前端最前沿的js插件和库. 布局 SuperEmbed.js- 是一个Javascript库,可检测出网页上的内嵌视频并使他们能够变成响应式 ...
- Android和jS互调技术Demo实现
package com.loaderman.webviewdemo; import android.os.Bundle; import android.support.v7.app.AppCompat ...
- 微信JS SDK PHP Demo
一.JSSDK类定义 <?php class JSSDK { private $appId; private $appSecret; public function __construct($a ...
- RSA JS 加密解密DEMO
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script&g ...
- jcFlexible.js的小Demo
;(function(win, lib) { var doc = win.document; var docEl = doc.documentElement; var metaEl = doc.que ...
随机推荐
- js数字货币格式互转
//将1,234,567.00转换为1234567.00 function moneyToNumValue(val) { var num = val.trim(); var ss = num.toSt ...
- MySQL应用异常问题解决
MySQL错误:Every derived table must have its own alias 派生表都必须有自己的别名 一般在多表查询时,会出现此错误. 因为,进行嵌套查询的时候子查询出来的 ...
- [转]Centos 查看端口占用情况和开启端口命令
http://www.cnblogs.com/xqzt/p/4919191.html 1.Centos 查看端口占用 比如查看 80 端口占用情况使用如下命令: lsof -i tcp:80 2.列出 ...
- 2018牛客网暑假ACM多校训练赛(第七场)I Tree Subset Diameter 动态规划 长链剖分 线段树
原文链接https://www.cnblogs.com/zhouzhendong/p/NowCoder-2018-Summer-Round7-I.html 题目传送门 - https://www.n ...
- BZOJ4003 [JLOI2015]城池攻占 左偏树 可并堆
欢迎访问~原文出处——博客园-zhouzhendong 去博客园看该题解 题目传送门 - BZOJ4003 题意概括 题意有点复杂,直接放原题了. 小铭铭最近获得了一副新的桌游,游戏中需要用 m 个骑 ...
- python3实现链表
1.链表的实现 a.链表的结构为: b.链表的实现方法; #链表结构实现 私有属性_pro_item是指向下个节点的指针,_item为此节点的值 class ChainDemo(): def __in ...
- LoadRunner服务水平协议SLA
服务水平协议 (或称 SLA)是以插入的事务为设置对象来为负载测试场景定义的具体目标. Analysis 将这些目标与 LoadRunner在运行过程中收集和存储的性能相关数据进行比较,然后确定目标的 ...
- Shiro笔记(五)Shiro授权
Shiro授权 也叫访问控制,即在应用中控制谁能访问那些资源(如访问页面.编辑数据.页面操作等).在授权中需要了解几个关键对象:主体(subject).资源(resource).权限(Permissi ...
- Python 解决 :NameError: name 'reload' is not defined 问题
对于 Python 2.X: import sys reload(sys) sys.setdefaultencoding("utf-8") 1 2 3 对于 <= Pytho ...
- Flume配置文件写法总结
一.agent 第一步是定义agent(代理)及agent下的sources.channels.sinks的简称,如下: a1.sources = r1 a1.sinks = k1 a1.channe ...