Advertisement
skimi07

Untitled

Aug 26th, 2016
1,376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.79 KB | None | 0 0
  1. <script type='text/javascript'>//<![CDATA[
  2. (function(a) {
  3. a.fn.lazyload=function(b){var c={threshold:
  4.  
  5. 0,failurelimit:0,event:"scroll",effect:"show",container:window;
  6. };
  7. if(b) {
  8. a.extend(c,b);
  9. }
  10. var d=this;if("scroll"==c.event) {
  11. a(c.container).bind("scroll",function(b){var e=0;d.each(function(){if
  12.  
  13. (a.abovethetop(this,c)||a.leftofbegin(this,c)){
  14. }
  15. else if(!a.belowthefold(this,c)&&!a.rightoffold(this,c)) {
  16. a(this).trigger("appear");
  17. }
  18. else {
  19. if(e++>c.failurelimit){return false;
  20. }}});
  21. var f=a.grep(d,function(a) {
  22. return!a.loaded;
  23. });
  24. d=a(f);
  25. })}
  26. this.each(function() {
  27. var b=this;if(undefined==a(b).attr("original")){a(b).attr("original",a(b).attr("src"));
  28. }
  29. if("scroll"!=c.event||undefined==a(b).attr("src")||c.placeholder==a(b).attr("src")||
  30.  
  31. a.abovethetop(b,c)||a.leftofbegin(b,c)||a.belowthefold(b,c)||a.rightoffold(b,c)) {
  32. if(c.placeholder){a(b).attr("src",c.placeholder);
  33. }
  34. else {
  35. a(b).removeAttr("src");
  36. }
  37. b.loaded=false;
  38. }
  39. else {
  40. b.loaded=true;
  41. }
  42. a(b).one("appear",function() {
  43. if(!this.loaded){a("<img />").bind("load",function(){a(b).hide().attr("src",a(b).attr
  44.  
  45. ("original"))[c.effect](c.effectspeed);b.loaded=true;
  46. }).attr("src",a(b).attr("original"));
  47. }});
  48. if("scroll"!=c.event) {
  49. a(b).bind(c.event,function(c){if(!b.loaded){a(b).trigger("appear");
  50. }})}});
  51. a(c.container).trigger(c.event);return this;
  52. };
  53. a.belowthefold=function(b,c) {
  54. if(c.container===undefined||c.container===window){var d=a(window).height()+a
  55.  
  56. (window).scrollTop();
  57. }
  58. else {
  59. var d=a(c.container).offset().top+a(c.container).height();
  60. }
  61. return d<=a(b).offset().top-c.threshold;
  62. };
  63. a.rightoffold=function(b,c) {
  64. if(c.container===undefined||c.container===window){var d=a(window).width()+a
  65.  
  66. (window).scrollLeft();
  67. }
  68. else {
  69. var d=a(c.container).offset().left+a(c.container).width();
  70. }
  71. return d<=a(b).offset().left-c.threshold;
  72. };
  73. a.abovethetop=function(b,c) {
  74. if(c.container===undefined||c.container===window){var d=a(window).scrollTop();
  75. }
  76. else {
  77. var d=a(c.container).offset().top;
  78. }
  79. return d>=a(b).offset().top+c.threshold+a(b).height();
  80. };
  81. a.leftofbegin=function(b,c) {
  82. if(c.container===undefined||c.container===window){var d=a(window).scrollLeft();
  83. }
  84. else {
  85. var d=a(c.container).offset().left;
  86. }
  87. return d>=a(b).offset().left+c.threshold+a(b).width();
  88. };
  89. a.extend(a.expr[":"], {
  90. "below-the-fold"
  91. :"$.belowthefold(a, {threshold : 0, container: window})","above-the-fold": "!
  92.  
  93. $.belowthefold(a, {threshold : 0, container: window})","right-of-fold":"$.rightoffold
  94.  
  95. (a, {threshold : 0, container: window})","left-of-fold":"!$.rightoffold(a, {threshold :
  96.  
  97. 0, container: window})";
  98. })})(jQuery);$(function() {
  99. $("img").lazyload({placeholder:
  100.  
  101. "http://i22.servimg.com/u/f22/15/42/72/40/grey10.gif",effect:"fadeIn",threshold:"-50";
  102. })})//]]></script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement