2016-10-14 16:23:52 +08:00
|
|
|
;layui.define("jquery",function(o){"use strict";var e=layui.jquery,i=function(o){},t='<i class="layui-anim layui-anim-rotate layui-anim-loop layui-icon "></i>';i.prototype.load=function(o){var i,l,n,r,a=this,c=1;o=o||{};var u=e(o.elem);if(u[0]){var f=e(o.scrollElem||document),m=o.mb||50,s=!("isAuto"in o)||o.isAuto,y=!("isShowEnd"in o)||o.isShowEnd,h=o.scrollElem&&o.scrollElem!==document,v="<cite>加载更多</cite>",d=e('<div class="layui-flow-more"><a href="javascript:;">'+v+"</a></div>");u.find(".layui-flow-more")[0]||u.append(d);var p=function(o,t){o=e(o),d.before(o),t=0==t||null,t?d.html(y?"没有更多了":""):d.find("a").html(v),l=t,i=null,n&&n()},g=function(){i=!0,d.find("a").html(t),"function"==typeof o.done&&o.done(++c,p)};if(d.find("a").on("click",function(){e(this);l||i||g()}),o.isLazyimg)var n=a.lazyimg({elem:o.elem+" img",scrollElem:f});return s?(f.on("scroll",function(){var o=e(this),t=o.scrollTop();r&&clearTimeout(r),l||(r=setTimeout(function(){var l=h?o.height():e(window).height(),n=h?o.prop("scrollHeight"):document.documentElement.scrollHeight;n-t-l<=m&&(i||g())},100))}),a):a}},i.prototype.lazyimg=function(o){var i,t=this,l=0;o=o||{};var n=e(o.scrollElem||document),r=o.elem||"img",a=o.scrollElem&&o.scrollElem!==document,c=function(o,e){var i=n.scrollTop(),r=i+e,c=a?function(){return o.offset().top-n.offset().top+i}():o.offset().top;if(c>=i&&c<=r&&!o.attr("src")){var f=o.attr("lay-src");layui.img(f,function(){var e=t.lazyimg.elem.eq(l);o.attr("src",f).removeAttr("lay-src"),e[0]&&u(e),l++})}},u=function(o,i){var u=a?(i||n).height():e(window).height(),f=n.scrollTop(),m=f+u;if(t.lazyimg.elem=e(r),o)c(o,u);else for(var s=0;s<t.lazyimg.elem.length;s++){var y=t.lazyimg.elem.eq(s),h=a?function(){return y.offset().top-n.offset().top+f}():y.offset().top;if(c(y,u),l=s,h>m)break}};if(u(),!i){var f;n.on("scroll",function(){var o=e(this);f&&clearTimeout(f),f=setTimeout(function(){u(null,o)},100)}),i=!0}return u},o("flow",new i)});
|