infinite scroll

类似一些网站, 例如京东搜索商品, 浏览到最后一页,自动加载新的商品。

一则可以加快首页响应速度, 二则减轻带宽和服务器荷载。 这么多商品信息一次性返回给客户端也是不可行的。

An infinite scrolling plugin for jQuery

https://github.com/pklauzinski/jscroll

http://jscroll.com/

jScroll is a jQuery plugin for infinite scrolling, written by Philip Klauzinski. Infinite scrolling; also known as lazy loading, endless scrolling, autopager, endless pages, etc.; is the ability to load content via AJAX within the current page or content area as you scroll down. The new content can be loaded automatically each time you scroll to the end of the existing content, or it can be triggered to load by clicking a navigation link at the end of the existing content.

An example of infinite scrolling is your Facebook "News Feed" page. You may notice that when you scroll to the bottom of this page, new content will often load automatically, or you will be given a link to "Older Posts" which will load more content when clicked.

demo: http://jscroll.com/

Recliner.js

https://github.com/sourcey/recliner

Recliner is a super lightweight (1KB) jQuery plugin for lazy loading images, iframes and other dynamic (AJAX) content. Being lazy never felt so good, just hook it up, and start sippin' those margaritas!

The script was born out of necessity when one of our clients came to us with massive scroll lag on one of their media heavy mobile news sites. It turned out that lazy-load-xt was the culprit, so naturally we tested the other lazy load scripts out there but none of them met our simple criteria:

  • Lightweight
  • Sets stateful CSS classes on elements
  • Ability to override event callbacks for custom behaviour
  • Can load any dynamic content (images, iframes, AJAX)
  • Mobile friendly
  • Printer friendly

Recliner is currently used on some very high traffic sites, so it's well tested and production ready.

demo:

https://sourcey.com/recliner/

代码示例:

其它:

https://github.com/metafizzy/infinite-scroll

20 jQuery Lazy Load Plugins for Improve Page Load Time

http://smashfreakz.com/2016/06/jquery-lazy-load-plugins/

如何实现infinite scroll?

https://www.quora.com/How-do-websites-only-load-part-of-the-page-and-then-load-more-as-you-scroll-down

检测位置, 发起ajax。

<script type="text/javascript">
$(document).ready(function(){
    var ajax_once = false;
    function last_msg_funtion()
    {
   
        var ID=$(".message_box:last").attr("id");
        $('div#last_msg_loader').html('<img src="Page on localhost">');
        $.post("welcome/index/get/"+ID,
        function(data){
            if (data != "") {
                $(".message_box:last").after(data);
            }
            $('div#last_msg_loader').empty();
        }).done(function(data) {
            /* use the data */
            ajax_once = false;
        });
    }; 
       
    $(window).scroll(function(){
        if (ajax_once)
        return;
        if  ($(window).scrollTop() == $(document).height() - $(window).height()){
           last_msg_funtion();
        }
    });
});
</script>

网页浏览 infinite scroll效果知识的更多相关文章

  1. Infinite Scroll - jQuery & WP 无限滚动插件

    无限滚动(Infinite Scroll)也称为自动分页.滚动分页和无限分页.常用在图片.文章或其它列表形式的网页中,用来在滚动网页的时候自动加载下一页的内容.Infinite Scroll  这款  ...

  2. Infinite Scroll–无限分页

    一.前言 现在有很多网站都有这样的交互 1.当你往下浏览页面时,页面会自动去异步加载数据. 无限分页效果 infinite scroll 效果图 –ifxoxo.com 2.在页面下方有一个“点击加载 ...

  3. JavaScript Infinite scroll & Masonry

    // infinitescroll() is called on the element that surrounds // the items you will be loading more of ...

  4. WPF 图片浏览 伪3D效果

    原文:WPF 图片浏览 伪3D效果 首先上效果图: 因项目要求,需要把图片以"好看"."炫"的效果展示出来,特地研究了一下WPF关于3D方面的制作,奈何最终成果 ...

  5. 微信网页悬浮窗交互效果的web实现

    一.微信的悬浮窗交互效果 微信更新后,发现多了个悬浮窗功能.公众号阅读,网页浏览回退后默认会出现.再点击,可以回到刚才阅读的地方.于是,再也不会遇到回复老婆的信息,再切换回来重新找刚才阅读东西的麻烦了 ...

  6. JS实现网页换肤功能效果

    网页换肤的基本原理 使用 JS 切换对应的 CSS 样式表.例如hao123首页的右上方就有网页换肤功能.除了切换 CSS 样式表文件之外,通常的网页换肤还需要通过 Cookie 来记录用户之前更换过 ...

  7. 使用 history 对象和 location 对象中的属性和方法制作一个简易的网页浏览工具

    查看本章节 查看作业目录 需求说明: 使用 history 对象和 location 对象中的属性和方法制作一个简易的网页浏览工具 实现思路: 使用history对象中的 forward() 方法和 ...

  8. Android -- 真正的 高仿微信 打开网页的进度条效果

    (本博客为原创,http://www.cnblogs.com/linguanh/) 目录: 一,为什么说是真正的高仿? 二,为什么要搞缓慢效果? 三,我的实现思路 四,代码,内含注释 五,使用方法与截 ...

  9. Java学习-033-JavaWeb_002 -- 网页标记语言JSP基础知识

    JSP 是 Sun 公司提倡的一门网页技术标准.在 HTML 文件中,加入 Java 代码就构成了 JSP 网页,当 Web 服务器访问 JSP 请求的时候,首先执行其中的 Java 程序源码,然后以 ...

随机推荐

  1. luogu3674 小清新人渣的本愿 (bitset+莫队)

    对于加减,用bitset维护当前每个数有没有 对于乘,暴力枚举约数 然后莫队 复杂度$O(m(\sqrt{n}+\frac{c}{64}))$ #include<bits/stdc++.h> ...

  2. 2017蓝桥杯 省赛D题(方格分割)

    6x6的方格,沿着格子的边线剪开成两部分.要求这两部分的形状完全相同. 如图:p1.png, p2.png, p3.png 就是可行的分割法.    试计算:包括这3种分法在内,一共有多少种不同的分割 ...

  3. AtCoder arc061C Snuke's Subway Trip

    大意: 给你一张无向图,边有种类. 当你第一次/重新进入某种边时费用 + 1 在同一种边之间行走无费用. 求 1 到 n 的最小费用. 嗯...乍一看有一个很直观的想法:记录每个点的最短路的上一条边的 ...

  4. 【洛谷P3455】ZAP-Queries

    题目大意:求 \[\sum\limits_{i=1}^a\sum\limits_{j=1}^b[gcd(i,j)=c]\] 题解:学会了狄利克雷卷积. \[\epsilon=\mu \ast 1\] ...

  5. SpringCloud-初识

    说道SpringCloud,原来就去了解过,也有很大兴趣,只是当初不知道这是个什么东西.在它之前,我学习Spring,在官网肆无忌惮的逛的时候,发现了SpringBoot,那个时候就打算开始学习Spr ...

  6. (栈)leetcode496. Next Greater Element I

    You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of n ...

  7. Java父类与子类方法调用顺序

    父类 FatherClass package 父类与子类方法调用顺序; /** * 父类 * @author shundong * */ public class FatherClass { priv ...

  8. consul介绍

    consul 是一个支持多数据中心分布式高可用,用于服务发现和配置共享的工具. consul与其它工具的不同,官方介绍如下: https://www.consul.io/intro/vs/index. ...

  9. 使用二进制安装包的方式单机部署MySQL8.0.13

    使用二进制安装包的方式单机部署MySQL8.0.13 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 关于MySQL的介绍我这里就不多做赘述了,如何下载MySQL详情请参考:MySQ ...

  10. C#设计模式(9)——代理模式

    1.代理模式介绍 在软件开发中有时会遇到不能直接使用对象的问题,如我们要使用的对象在进程外,甚至在远程的机器上,但是我们要使用这个对象的功能怎么办呢?代理模式就可以用来解决这个问题.举一个生活中的例子 ...