原文: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的更多相关文章

  1. A Xamarin.Forms Infinite Scrolling ListView

    from:http://www.codenutz.com/lac09-xamarin-forms-infinite-scrolling-listview/ The last few months ha ...

  2. 在线浏览PDF之PDF.JS (附demo)

    平台之大势何人能挡? 带着你的Net飞奔吧!:http://www.cnblogs.com/dunitian/p/4822808.html#skill 下载地址:http://mozilla.gith ...

  3. echarts.js使用心得--demo

    首先要感谢一下我的公司,因为公司需求上面的新颖(奇葩)的需求,让我有幸可以学习到一些好玩有趣的前端技术. 废话不多时 , 直接开始. 第一步: 导入echarts.js文件 下载地址:http://e ...

  4. 使用IDEA+vue.js+easyUI的demo

    最近,随便写了几个开发的小例子,自己总结下,留个纪念. 例子1:使用EasyUI做了一个简单界面,服务器和客户端在一起. @Controller @RequestMapping("/demo ...

  5. 值得H5前端学习的60个JS插件(含DEMO演示)

    下面也可以说是H5前端学习的js插件大全.基本包含了大部分的前端最前沿的js插件和库. 布局 SuperEmbed.js- 是一个Javascript库,可检测出网页上的内嵌视频并使他们能够变成响应式 ...

  6. Android和jS互调技术Demo实现

    package com.loaderman.webviewdemo; import android.os.Bundle; import android.support.v7.app.AppCompat ...

  7. 微信JS SDK PHP Demo

    一.JSSDK类定义 <?php class JSSDK { private $appId; private $appSecret; public function __construct($a ...

  8. RSA JS 加密解密DEMO

    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script&g ...

  9. jcFlexible.js的小Demo

    ;(function(win, lib) { var doc = win.document; var docEl = doc.documentElement; var metaEl = doc.que ...

随机推荐

  1. POJ 1273 Drainage Ditches【最大流模版】

    题意:现在有m个池塘(从1到m开始编号,1为源点,m为汇点),及n条有向水渠,给出这n条水渠所连接的点和所能流过的最大流量,求从源点到汇点能流过的最大流量 Dinic #include<iost ...

  2. signal() 和 sigaction()

    [摘自<Linux/Unix系统编程手册>] Unix系统提供了两种方式来改变信号处置:signal() 和 sigaction(). signal() 的行为在不同Unix实现间存在差异 ...

  3. centos7 yum install redis

    直接yum 安装的redis 不是最新版本 yum install redis 如果要安装最新的redis,需要安装Remi的软件源,官网地址:http://rpms.famillecollet.co ...

  4. window与linux文件共享解决方案

    我的系统是windows7 x64,虚拟机上的linux系统是centos6.5 方法一: 1.在win7系统上建立一个用户 2.在f盘建立一个文件夹linuxshare,然后右击-属性-共享-高级共 ...

  5. php通过CURL模拟post提交请求

    <?php header("Content-type:text/html;charset=utf-8"); class Test{ public function reque ...

  6. Python--os的常见方法

    1.os.getcwd()+'/filename'------>相当于在当前运行文件的目录下创建一个以filename命名的文件 2.os.path.realpath(__file__)---- ...

  7. spring cloud 详解

    https://www.cnblogs.com/qdhxhz/p/9601170.html SpringCloud(8)---zuul权限校验.接口限流 https://blog.csdn.net/c ...

  8. python与mysql交互中的各种坑

    开始学python 交互MySQLdb,踩了很多坑 第一个 %d format: a number is required, not str 参照以下博客: https://blog.csdn.net ...

  9. shell 日期加减,日期大小比较的方法

    1 日期加减方法可实现当天的日期加减,指定日期的加减,天周月年. 只判断yymmdd的秒 twoDayAgoTime=`date -d \`date -d "-2 day" +%Y ...

  10. asp.net core 依赖注入实现全过程粗略剖析(2)

    接着 上篇 目前也算是交代清楚了相关的类.那么框架具体是如何来实例化的呢?整个的流程是怎么样的. 我们参考源码中的Test文件夹来看看: var collection = new ServiceCol ...