Jquery PlugIn for lazy loading items.
来源:互联网 发布:淘宝好的男装店 编辑:程序博客网 时间:2024/05/22 04:44
//lazy load image(function ($) {$.fn.onScroll = function (options) {var defaultOpt = {callback: null,params: null,reserve: 0};var opt = $.extend({}, defaultOpt, options);var $this = $(this);var _checkScreen = function(ignoreCache){var scrolltop = $(window).scrollTop();var wheight = $(window).height();var offsetTop = $this.offset().top;if (offsetTop >= scrolltop && offsetTop <= (scrolltop + wheight + (ignoreCache === true ?0:opt.reserve))) {if ($.isFunction(opt.callback)) {opt.callback($this, opt.params);} else {$(document).trigger(opt.callback, [$this, opt.params]);}}}$(document).on('dom.scroll', _checkScreen);_checkScreen(true);};$(document).on('dom.load', function () {$("[data-onscroll]").each(function () {var $this = $(this);$this.onScroll({callback: $this.attr('data-onscroll'),params: $this.attr('data-onscroll-params'),reserve: Number($this.attr('data-reserve')) || 0})$this.removeAttr("data-onscroll");});});})(jQuery);
PlugIn for lazy loading items.
Usage:
<iframe class="shown" data-onscroll="informaScrollToEvent" data-src="<%= informaUrl %>" width="100%" frameborder="0" height="500px" style="border:1px solid #d7d7d7;"></iframe>
$(document).one('informaScrollToEvent', function (e, iframe, params) { var url = $(iframe).attr('data-src'); $(iframe).attr('src', url); $(iframe).removeAttr('data-src'); });
阅读全文
0 0
- Jquery PlugIn for lazy loading items.
- lazy load plugin for jQuery
- jquery lazy loading
- Lazy Load Images jQuery Plugin
- 网页图片延迟加载的jQuery插件-Lazy Load Plugin for JQuery
- lazy loading
- lazy loading
- Jquery for table plugin
- 支持Lazy loading的图片画廊jQuery插件 - Least.js
- 支持Lazy loading的图片画廊jQuery插件 - Least.js
- 本文翻译自 Lazy Load Plugin for jQuery, 介绍一个 jQuery 插件, 它提供懒汉式加载页面图片的功能.
- File Style Plugin for jQuery
- Lazy Loading Asyncronous Javascript
- javascript的lazy loading
- C# Lazy Loading
- Lazy Loading In AngularJS
- Lazy Loading Singletons|Classloader
- MyBatis Lazy Loading
- 常用正则表达式
- 【python 爬虫】selenium爬虫模块 phantomjs如何加代理IP
- struts2框架学习笔记02
- Java编程思想之字符串
- python基础--tuple()
- Jquery PlugIn for lazy loading items.
- 设计模式-单例模式
- 《战狼》背后的大数据分析
- 安装Sphinx 2.0.4时出现的以下几个错误处理方法 WARNING: compat_sphinxql_magics=1 is deprecated;
- Adb常用命令集合
- JDBC
- popupwindow
- HDU 2546饭卡 【01背包水题】
- linux oracle rac 备份到本地