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. Zabbix-proxy安装部署

    原文链接:https://www.cnblogs.com/irockcode/p/6754659.html 环境: 因为公司需要监控远程客户机,但server端无法主动连接agent端,客户端可以连接 ...

  2. 深挖JDK动态代理(一)

     最近在研究RPC框架,避免不了的就是在RPC调用中使用最多的则是动态代理的机制了,基于此,我们先来研究一下JDK动态代理 我们先来尝试着编写一下JDK动态代理的代码 1. 由于JDK动态代理是基于接 ...

  3. Ubuntu 18.04 安装微信(Linux通用)

    Linux相关的知识:https://www.cnblogs.com/dunitian/p/4822808.html#linux 新增谷歌浏览器添加到桌面的彻底删除:https://www.cnblo ...

  4. C# winfrom 递归(城市名)

    递归的定以:递归在运行过程中,自己调用自己的过程: List<ChinaStates> list = new ChinaData().SelectAll();//查询所有中国的城市的方法: ...

  5. A1141. PAT Ranking of Institutions

    After each PAT, the PAT Center will announce the ranking of institutions based on their students' pe ...

  6. 【洛谷P2709】小B的询问

    题目大意:给定一个长度为 N 的序列,M 个询问,静态查询区间 [l,r] 内的不同颜色数的平方和. 题解:直接莫队即可. 代码如下 #include <bits/stdc++.h> #d ...

  7. MyQR库自动为网址生成二维码

    首先安装MyQR库: pip install MyQR #导包 from MyQR import myqr #生成二维码 words=你要为那个网址生成二维码 save_name=保存后的图片名 pi ...

  8. 笔记:用标准c写 com dll

    在 [XXX.idl] 中 1. 如果想在脚本语言中传递一个值,并且在dll(c代码)中修改这个值并返回的话, 这个参数必须写为:[in, out] VARIANT* 如果写成 [in, out] i ...

  9. Unity Shader基本例子

    Unity中,对于一个物体我们想要改变其的外观,就需要给其增加一个材质,即Matiral 一般的Matiral采用的是标准的Shader,而标准的Shader并不是最好的渲染物体表明的效果,那么我们就 ...

  10. HTML学习笔记Day9

    一.宽高自适应 网页布局中经常要定义元素的宽和高:但很多时候我们希望元素的大小能够根据窗口或父元素自动调整,这就是自适应,元素自适应在网页布局中非常重要,tanenggou它能够使网页显示更灵活,可以 ...