You've already forked EasyImages2.0
mirror of
https://github.com/icret/EasyImages2.0.git
synced 2025-12-13 11:43:58 +08:00
v2.7.2 dev
* 2023-02-03 v2.7.2 dev - 增加 [web-indexr](https://github.com/rehiy/web-indexr) 文件管理 - - web-indexr处于实验中,作为Tinyfilemanager的替代 - 优化排版
This commit is contained in:
@@ -1,20 +0,0 @@
|
||||
|
||||
(function(){var root=(typeof self=='object'&&self.self==self&&self)||(typeof global=='object'&&global.global==global&&global)||this||{};Function.prototype.bind=Function.prototype.bind||function(context){if(typeof this!=="function"){throw new Error("Function.prototype.bind - what is trying to be bound is not callable");}
|
||||
var self=this;var args=Array.prototype.slice.call(arguments,1);var fNOP=function(){};var fBound=function(){var bindArgs=Array.prototype.slice.call(arguments);self.apply(this instanceof fNOP?this:context,args.concat(bindArgs));}
|
||||
fNOP.prototype=this.prototype;fBound.prototype=new fNOP();return fBound;}
|
||||
var util={extend:function(target){for(var i=1,len=arguments.length;i<len;i++){for(var prop in arguments[i]){if(arguments[i].hasOwnProperty(prop)){target[prop]=arguments[i][prop]}}}
|
||||
return target},addEvent:function(elem,type,fn){if(document.addEventListener){elem.addEventListener(type,fn,false);return fn;}else if(document.attachEvent){var bound=function(){return fn.apply(elem,arguments)}
|
||||
elem.attachEvent('on'+type,bound);return bound;}},removeEvent:function(elem,type,fn){if(document.removeEventListener){elem.removeEventListener(type,fn,false)}
|
||||
else{elem.detachEvent("on"+type,fn)}}}
|
||||
function Lazy(opts){this.opts=util.extend({},this.constructor.defaultOpts,opts)
|
||||
this.init();}
|
||||
Lazy.VERSION='1.0.0';Lazy.defaultOpts={delay:250,useDebounce:false}
|
||||
var proto=Lazy.prototype;proto.init=function(){this.calulateView();this.bindScrollEvent();};proto.calulateView=function(){this.view={top:0-(parseInt(this.opts.top,10)||0),bottom:(root.innerHeight||document.documentElement.clientHeight)+(parseInt(this.opts.bottom,10)||0),left:0-(parseInt(this.opts.left,10)||0),right:(root.innerWidth||document.documentElement.clientWidth)+(parseInt(this.opts.right,10)||0)}};proto.bindScrollEvent=function(){var scrollEvent=util.addEvent(root,'scroll',this.handleLazyLoad.bind(this))
|
||||
var loadEvent=util.addEvent(root,'load',this.handleLazyLoad.bind(this))
|
||||
this.event={scrollEvent:scrollEvent,loadEvent:loadEvent}};var timer=null;proto.handleLazyLoad=function(){var self=this;if(!this.opts.useDebounce&&!!timer){return;}
|
||||
clearTimeout(timer);timer=setTimeout(function(){timer=null;self.render()},this.opts.delay);};proto.isHidden=function(element){return(element.offsetParent===null);};proto.checkInView=function(element){if(this.isHidden(element)){return false;}
|
||||
var rect=element.getBoundingClientRect();return(rect.right>=this.view.left&&rect.bottom>=this.view.top&&rect.left<=this.view.right&&rect.top<=this.view.bottom);};proto.render=function(){var nodes=document.querySelectorAll('[data-image], [data-lazy-background]');var length=nodes.length;for(var i=0;i<length;i++){elem=nodes[i];if(this.checkInView(elem)){if(elem.getAttribute('data-lazy-background')!==null){elem.style.backgroundImage='url('+elem.getAttribute('data-lazy-background')+')';}else if(elem.src!==(src=elem.getAttribute('data-image'))){elem.src=src;}
|
||||
elem.removeAttribute('data-image');elem.removeAttribute('data-lazy-background');if(this.opts.onload&&typeof this.opts.onload==='function'){this.opts.onload(elem);}}}
|
||||
if(!length){this.unbindScrollEvent();}};proto.unbindScrollEvent=function(){util.removeEvent(root,'scroll',this.event.scrollEvent)
|
||||
util.removeEvent(root,'load',this.event.loadEvent)};if(typeof exports!='undefined'&&!exports.nodeType){if(typeof module!='undefined'&&!module.nodeType&&module.exports){exports=module.exports=Lazy;}
|
||||
exports.Lazy=Lazy;}else{root.Lazy=Lazy;}}());
|
||||
5
public/static/lazyload/lazyload.min.js
vendored
Normal file
5
public/static/lazyload/lazyload.min.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/*!
|
||||
* 懒加载 - 因兼容问题将 data-lazy-src 替换为data-image
|
||||
* https://github.com/mqyqingfeng/LazyLoad
|
||||
*/
|
||||
!function(){function t(t){this.opts=n.extend({},this.constructor.defaultOpts,t),this.init()}var e="object"==typeof self&&self.self==self&&self||"object"==typeof global&&global.global==global&&global||this||{};Function.prototype.bind=Function.prototype.bind||function(t){if("function"!=typeof this)throw new Error("Function.prototype.bind - what is trying to be bound is not callable");var e=this,n=Array.prototype.slice.call(arguments,1),o=function(){},i=function(){var i=Array.prototype.slice.call(arguments);e.apply(this instanceof o?this:t,n.concat(i))};return o.prototype=this.prototype,i.prototype=new o,i};var n={extend:function(t){for(var e=1,n=arguments.length;e<n;e++)for(var o in arguments[e])arguments[e].hasOwnProperty(o)&&(t[o]=arguments[e][o]);return t},addEvent:function(t,e,n){if(document.addEventListener)return t.addEventListener(e,n,!1),n;if(document.attachEvent){var o=function(){return n.apply(t,arguments)};return t.attachEvent("on"+e,o),o}},removeEvent:function(t,e,n){document.removeEventListener?t.removeEventListener(e,n,!1):t.detachEvent("on"+e,n)}};t.VERSION="1.0.0",t.defaultOpts={delay:250,useDebounce:!1};var o=t.prototype;o.init=function(){this.calulateView(),this.bindScrollEvent()},o.calulateView=function(){this.view={top:0-(parseInt(this.opts.top,10)||0),bottom:(e.innerHeight||document.documentElement.clientHeight)+(parseInt(this.opts.bottom,10)||0),left:0-(parseInt(this.opts.left,10)||0),right:(e.innerWidth||document.documentElement.clientWidth)+(parseInt(this.opts.right,10)||0)}},o.bindScrollEvent=function(){var t=n.addEvent(e,"scroll",this.handleLazyLoad.bind(this)),o=n.addEvent(e,"load",this.handleLazyLoad.bind(this));this.event={scrollEvent:t,loadEvent:o}};var i=null;o.handleLazyLoad=function(){var t=this;!this.opts.useDebounce&&i||(clearTimeout(i),i=setTimeout(function(){i=null,t.render()},this.opts.delay))},o.isHidden=function(t){return null===t.offsetParent},o.checkInView=function(t){if(this.isHidden(t))return!1;var e=t.getBoundingClientRect();return e.right>=this.view.left&&e.bottom>=this.view.top&&e.left<=this.view.right&&e.top<=this.view.bottom},o.render=function(){for(var t=document.querySelectorAll("[data-image], [data-lazy-background]"),e=t.length,n=0;n<e;n++)elem=t[n],this.checkInView(elem)&&(null!==elem.getAttribute("data-lazy-background")?elem.style.backgroundImage="url("+elem.getAttribute("data-lazy-background")+")":elem.src!==(src=elem.getAttribute("data-image"))&&(elem.src=src),elem.removeAttribute("data-image"),elem.removeAttribute("data-lazy-background"),this.opts.onload&&"function"==typeof this.opts.onload&&this.opts.onload(elem));e||this.unbindScrollEvent()},o.unbindScrollEvent=function(){n.removeEvent(e,"scroll",this.event.scrollEvent),n.removeEvent(e,"load",this.event.loadEvent)},"undefined"==typeof exports||exports.nodeType?e.Lazy=t:("undefined"!=typeof module&&!module.nodeType&&module.exports&&(exports=module.exports=t),exports.Lazy=t)}();
|
||||
Reference in New Issue
Block a user