lazyload

mls: m/component/lazyLoad.js
document.elementFromPoint(x, y)

jquery.lazyload.js
https://github.com/tuupola/jquery_lazyload
http://www.cnblogs.com/yangjunhua/p/3871763.html
内部原理
首先选中的img元素都绑定了一个appear事件(处理img显示真实的图片地址),方便以后满足条件时触发该事件;在配置对象中有一个container属性配置,默认为window,如果img元素在该container容器视口中,则触发appear事件;为了判断img元素是否在container容器视口范围中,造了如下四个轮子:

$.belowthefold = function(element, settings) {}; // 在视口下方
$.rightoffold = function(element, settings) {}; // 在视口右方
$.abovethetop = function(element, settings) {}; // 在视口上方
$.leftofbegin = function(element, settings) {}; // 在视口左方

https://xiejiancong.com/post-239.html
http://ujipin.com/tag/18e6c0aff8ed4a089513b677b2a642e7

实现一个图片懒加载插件有多难?

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容