Changeset 1021594
- Timestamp:
- 11/07/2014 04:14:26 PM (11 years ago)
- Location:
- smart-image-loader/trunk
- Files:
-
- 2 edited
-
smart_image_loader.js (modified) (2 diffs)
-
smart_image_loader.min.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
smart-image-loader/trunk/smart_image_loader.js
r1018860 r1021594 381 381 } 382 382 383 if ( images_loaded == images_to_load && typeof on_all_visible_load_callback == 'function')383 if ( images_loaded == images_to_load ) 384 384 { 385 on_all_visible_load_callback(); 385 $document.trigger('sil_load_visible'); 386 387 if ( typeof on_all_visible_load_callback == 'function' ) 388 { 389 on_all_visible_load_callback(); 390 } 386 391 } 387 392 … … 432 437 { 433 438 439 $document.trigger('sil_load'); 440 434 441 all_loaded = $wrapped_images.length > 0 ? false : true; 435 442 436 443 if ( all_loaded ) 437 444 { 438 $document.trigger('sil_load ');445 $document.trigger('sil_load_all'); 439 446 } 440 447 -
smart-image-loader/trunk/smart_image_loader.min.js
r1013273 r1021594 1 jQuery(function(N){var ag=window.sil_options||{selector:"img",cleanup:true,responsive_touch:true,emulate_inertia:true,emulate_rubberband:true,meat:100,refresh_resize:true,refresh_scroll:false,enhanced_accuracy:false,lazy_load_at:1024,fade:false,placeholder:"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"}; 2 var af=document,U=window,G=N(af),aa,A,z,u,i,E,Q,h,M,o,l,k,r,a,j,f,H,n,C,Z,I,D,ac,ah,ad,q=/(iPad|iPhone|iPod)/g.test(navigator.userAgent),x=!!(U.matchMedia&&U.matchMedia("(max-device-width: "+ag.lazy_load_at+"px)").matches),V=function(){var w=U,d="inner"; 3 if(!("innerWidth" in U)){d="client";w=af.documentElement||af.body;}return{width:w[d+"Width"],height:w[d+"Height"]};},W=function(d,w){if(window.getComputedStyle){return document.defaultView.getComputedStyle(d,null)[w]; 4 }if(d.currentStyle){return d.currentStyle[w];}},J=function(){return I!==Z;},c=function(){return ac!==D;},ab=function(){return ad!==ah;},R=function(aq){var w,ar,al,aj,am,d,an,ak,at,ap,ao; 5 if(aq.nodeType&&aq.nodeType==1){w=aq;}else{if(this.nodeType&&this.nodeType==1){w=this;}}ar=N(w);al=ar.data("offsetTop");aj=ar.data("offsetLeft");am=ar.data("width"); 6 d=ar.data("height");element_visibile=ar.data("visibility");an=al+d>M-ag.meat;ap=aj+am>o-ag.meat;ak=al<M+Q+ag.meat;at=aj<o+E+ag.meat;return an&&ap&&ak&&at&&element_visibile; 7 },X=function(d){var w,aj;if(d.nodeType&&d.nodeType==1){w=d;}else{if(this.nodeType&&this.nodeType==1){w=this;}}aj=N(w).attr("src");return aj==ag.placeholder||aj==i; 8 },O=function(d){return typeof d.width=="string"&&d.width.match(/^\d+$/)&&typeof d.height=="string"&&d.height.match(/^\d+$/);},e=function(d,w){d=d||A||N("body").find("noscript").prev(ag.selector); 9 d.each(function(){var ak=N(this);ak.data({offsetTop:ak.offset().top,offsetLeft:ak.offset().left,width:ak.width(),height:ak.height(),visibility:W(this,"display")!="none"&&W(this,"visibility")!="hidden"&&W(this,"opacity")!="0"}); 10 });h=N(af).height();if(w){var aj=x?null:v;P(aj,true);}},F=function(){var d,w,aj;U.scrollBy(0,Math.floor(f/2));f*=0.95;d=h<=Q+M+1;w=(M===0);aj=d||w;H=false; 11 if(Math.abs(f)>2&&!r&&!aj){H=true;}else{if(aj&&ag.emulate_rubberband){b(f);}}},b=function(aj){n=aj;var ak=aj<0?1:-1,w=Math.min(Math.abs(aj),U.innerHeight/10)*ak,d=Math.abs(aj*3); 12 d=Math.min(d,200);d=Math.max(d,125);af.body.style.webkitTransition="all "+d/1000*0.5+"s cubic-bezier(0.3, 0.6, 0.6, 1)";af.documentElement.style.backgroundColor="lightgrey"; 13 U.requestAnimationFrame(function(){af.body.style.webkitTransform="translate3d(0px, "+w+"px, 0px)";});U.setTimeout(function(){af.body.style.webkitTransition="all "+d/1000*2+"s cubic-bezier(0.5, 0.03, 0.5, 1)"; 14 U.requestAnimationFrame(function(){af.body.style.webkitTransform="translate3d(0px, 0px, 0px)";});},d*0.5);U.setTimeout(function(){af.body.style.webkitTransform=""; 15 af.body.style.webkitTransition="";af.documentElement.style.backgroundColor="";n=false;},d*2.5);},S=function(aj,w,al){aa=N(aj);var d=aa.attr("data-sil"),ak=u.filter('[data-sil="'+d+'"]'); 16 if(typeof w=="function"){aa.on("load",w);}if(ag.fade&&al){aa.data({opacity:aa.css("opacity")}).css({opacity:"0"});aa.on("load",function(){N(this).fadeTo(500,N(this).data("opacity")); 17 });}aa.attr("src",ak.attr("title"));requestAnimationFrame(function(){if(!O(aj)){e(A,true);}});if(ag.cleanup){ak.parent("span").remove();}},P=function(al,ak){var aj=A.filter(R),d=aj.length,w=0; 18 if(d===0&&typeof al=="function"){al();}else{aj.each(function(am,an){S(an,function(ao){K(ao);w=am+1;if(!O(ao.target)){e(A,true);}if(w==d&&typeof al=="function"){al(); 19 }},ak);A=A.map(function(){if(this!==an){return this;}});});}},v=function(){A.each(function(){var d=this;S(d,K);A=A.map(function(){if(this!==d){return this; 20 }});});},K=function(d){C=A.length>0?false:true;if(C){G.trigger("sil_load");}},ae=function(){e(A,true);},B=function(d){d.preventDefault();D=d;},y=function(){j=0; 21 f=0;l=false;k=false;r=true;H=false;},ai=function(){l=false;k=false;r=false;if(ag.emulate_inertia){H=true;}},T=function(d){Z=d;},t=function(d){ah=d;},s=function(){if(!q){window.requestAnimationFrame(Y); 22 }},p=function(){h=G.height();if(q){U.requestAnimationFrame(Y);}},m=function(){N(U).on("resize",t);N(U).on("load",p);G.on("scroll",T);if(ag.responsive_touch&&q){G.on("touchmove",B); 23 G.on("touchend",ai);G.on("touchstart",y);}G.ready(s);},g=function(){N(U).off("resize",t);G.off("scroll",T);if(ag.responsive_touch&&q){G.off("touchmove",B); 24 G.off("touchend",ai);G.off("touchstart",y);}},L=function(aj){if(J()){M=G.scrollTop();o=G.scrollLeft();if(ag.refresh_scroll){e(A);}if(x){P(null,true);}I=Z; 25 }if(c()){var w=D.originalEvent.layerX-o;var d=D.originalEvent.layerY-M;j=f=0;if(l&&l!==w){j=l-w;}if(k&&k!==d){f=k-d;}l=w;k=d;U.scrollBy(j,f);ac=D;}if(ab()){E=V().width; 26 Q=V().height;e(A);if(ag.refresh_resize){e(A);}if(x){P(null,true);}ad=ah;}if(H){F();}if(!C||H||n){U.requestAnimationFrame(L);}else{g();}},Y=function(){z=N("html, body"); 27 u=N("body").find("noscript[data-sil]");A=N(ag.selector+"[data-sil]");E=V().width;Q=V().height;i=af.location.protocol+"//"+af.location.host+"/";M=G.scrollTop(); 28 o=G.scrollLeft();h=G.height();H=false;n=false;C=A.length>0?false:true;window.sil_refresh=ae;e(A);if(x){P();}else{P(v);}L();};rf_poly();m();});function rf_poly(){var b=0; 29 var c=["webkit","moz"];for(var a=0;a<c.length&&!window.requestAnimationFrame;++a){window.requestAnimationFrame=window[c[a]+"RequestAnimationFrame"];window.cancelAnimationFrame=window[c[a]+"CancelAnimationFrame"]||window[c[a]+"CancelRequestAnimationFrame"]; 1 jQuery(function(O){var ah=window.sil_options||{selector:"img",cleanup:true,responsive_touch:true,emulate_inertia:true,emulate_rubberband:true,meat:100,refresh_resize:true,refresh_scroll:false,enhanced_accuracy:false,lazy_load_at:1024,fade:false,placeholder:"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"}; 2 var ag=document,V=window,H=O(ag),ab,B,A,v,i,F,R,h,N,o,l,k,r,a,j,f,I,n,D,u,aa,J,E,ad,ai,ae,q=/(iPad|iPhone|iPod)/g.test(navigator.userAgent),y=!!(V.matchMedia&&V.matchMedia("(max-device-width: "+ah.lazy_load_at+"px)").matches),W=function(){var w=V,d="inner"; 3 if(!("innerWidth" in V)){d="client";w=ag.documentElement||ag.body;}return{width:w[d+"Width"],height:w[d+"Height"]};},X=function(d,w){if(window.getComputedStyle){return document.defaultView.getComputedStyle(d,null)[w]; 4 }if(d.currentStyle){return d.currentStyle[w];}},K=function(){return J!==aa;},c=function(){return ad!==E;},ac=function(){return ae!==ai;},S=function(ar){var w,at,am,ak,an,d,ao,al,au,aq,ap; 5 if(ar.nodeType&&ar.nodeType==1){w=ar;}else{if(this.nodeType&&this.nodeType==1){w=this;}}at=O(w);am=at.data("offsetTop");ak=at.data("offsetLeft");an=at.data("width"); 6 d=at.data("height");element_visibile=at.data("visibility");ao=am+d>N-ah.meat;aq=ak+an>o-ah.meat;al=am<N+R+ah.meat;au=ak<o+F+ah.meat;return ao&&aq&&al&&au&&element_visibile; 7 },Y=function(d){var w,ak;if(d.nodeType&&d.nodeType==1){w=d;}else{if(this.nodeType&&this.nodeType==1){w=this;}}ak=O(w).attr("src");return ak==ah.placeholder||ak==i; 8 },P=function(d){return typeof d.width=="string"&&d.width.match(/^\d+$/)&&typeof d.height=="string"&&d.height.match(/^\d+$/);},e=function(d,w){d=d||B||O("body").find("noscript").prev(ah.selector); 9 d.each(function(){var al=O(this);al.data({offsetTop:al.offset().top,offsetLeft:al.offset().left,width:al.width(),height:al.height(),visibility:X(this,"display")!="none"&&X(this,"visibility")!="hidden"&&X(this,"opacity")!="0"}); 10 });h=O(ag).height();if(w){var ak=y?null:x;Q(ak,true);}},G=function(){var d,w,ak;V.scrollBy(0,Math.floor(f/2));f*=0.95;d=h<=R+N+1;w=(N===0);ak=d||w;I=false; 11 if(Math.abs(f)>2&&!r&&!ak){I=true;}else{if(ak&&ah.emulate_rubberband){b(f);}}},b=function(ak){n=ak;var al=ak<0?1:-1,w=Math.min(Math.abs(ak),V.innerHeight/10)*al,d=Math.abs(ak*3); 12 d=Math.min(d,200);d=Math.max(d,125);ag.body.style.webkitTransition="all "+d/1000*0.5+"s cubic-bezier(0.3, 0.6, 0.6, 1)";ag.documentElement.style.backgroundColor="lightgrey"; 13 V.requestAnimationFrame(function(){ag.body.style.webkitTransform="translate3d(0px, "+w+"px, 0px)";});V.setTimeout(function(){ag.body.style.webkitTransition="all "+d/1000*2+"s cubic-bezier(0.5, 0.03, 0.5, 1)"; 14 V.requestAnimationFrame(function(){ag.body.style.webkitTransform="translate3d(0px, 0px, 0px)";});},d*0.5);V.setTimeout(function(){ag.body.style.webkitTransform=""; 15 ag.body.style.webkitTransition="";ag.documentElement.style.backgroundColor="";n=false;},d*2.5);},T=function(ak,w,am){ab=O(ak);var d=ab.attr("data-sil"),al=v.filter('[data-sil="'+d+'"]'); 16 if(typeof w=="function"){ab.on("load",w);}if(ah.fade&&am){ab.data({opacity:ab.css("opacity")}).css({opacity:"0"});ab.on("load",function(){O(this).fadeTo(500,O(this).data("opacity")); 17 });}ab.attr("src",al.attr("title"));requestAnimationFrame(function(){if(!P(ak)){e(B,true);}});if(ah.cleanup){al.parent("span").remove();}},Q=function(am,al){var ak=B.filter(S),d=ak.length,w=0; 18 if(d===0&&typeof am=="function"){am();}else{ak.each(function(an,ao){T(ao,function(ap){L(ap);w=an+1;if(!P(ap.target)){e(B,true);}if(w==d){H.trigger("sil_load_visible"); 19 if(typeof am=="function"){am();}}},al);B=B.map(function(){if(this!==ao){return this;}});});}},x=function(){B.each(function(){var d=this;T(d,L);B=B.map(function(){if(this!==d){return this; 20 }});});},L=function(d){H.trigger("sil_load");D=B.length>0?false:true;if(D){H.trigger("sil_load_all");}},af=window.sil_refresh=function(){if(u===true){e(B,true); 21 }},C=function(d){d.preventDefault();E=d;},z=function(){j=0;f=0;l=false;k=false;r=true;I=false;},aj=function(){l=false;k=false;r=false;if(ah.emulate_inertia){I=true; 22 }},U=function(d){aa=d;},t=function(d){ai=d;},s=function(){if(!q){window.requestAnimationFrame(Z);}},p=function(){h=H.height();if(q){V.requestAnimationFrame(Z); 23 }},m=function(){O(V).on("resize",t);O(V).on("load",p);H.on("scroll",U);if(ah.responsive_touch&&q){H.on("touchmove",C);H.on("touchend",aj);H.on("touchstart",z); 24 }H.ready(s);},g=function(){O(V).off("resize",t);H.off("scroll",U);if(ah.responsive_touch&&q){H.off("touchmove",C);H.off("touchend",aj);H.off("touchstart",z); 25 }},M=function(ak){if(K()){N=H.scrollTop();o=H.scrollLeft();if(ah.refresh_scroll){e(B);}if(y){Q(null,true);}J=aa;}if(c()){var w=E.originalEvent.layerX-o; 26 var d=E.originalEvent.layerY-N;j=f=0;if(l&&l!==w){j=l-w;}if(k&&k!==d){f=k-d;}l=w;k=d;V.scrollBy(j,f);ad=E;}if(ac()){F=W().width;R=W().height;e(B);if(ah.refresh_resize){e(B); 27 }if(y){Q(null,true);}ae=ai;}if(I){G();}if(!D||I||n){V.requestAnimationFrame(M);}else{g();}},Z=function(){A=O("html, body");v=O("body").find("noscript[data-sil]"); 28 B=O(ah.selector+"[data-sil]");F=W().width;R=W().height;i=ag.location.protocol+"//"+ag.location.host+"/";N=H.scrollTop();o=H.scrollLeft();h=H.height();I=false; 29 n=false;D=B.length>0?false:true;e(B);if(y){Q();}else{Q(x);}M();u=true;};rf_poly();m();});function rf_poly(){var b=0;var c=["webkit","moz"];for(var a=0; 30 a<c.length&&!window.requestAnimationFrame;++a){window.requestAnimationFrame=window[c[a]+"RequestAnimationFrame"];window.cancelAnimationFrame=window[c[a]+"CancelAnimationFrame"]||window[c[a]+"CancelRequestAnimationFrame"]; 30 31 }if(!window.requestAnimationFrame){window.requestAnimationFrame=function(h,e){var d=new Date().getTime();var f=Math.max(0,16-(d-b));var g=window.setTimeout(function(){h(d+f); 31 32 },f);b=d+f;return g;};}if(!window.cancelAnimationFrame){window.cancelAnimationFrame=function(d){clearTimeout(d);};}}
Note: See TracChangeset
for help on using the changeset viewer.