Permalink
Browse files

2.0.5

  • Loading branch information...
1 parent aad8521 commit e5139a836826ed89ef75bf7de577bf5dac301997 @vvo committed Jul 21, 2013
Showing with 23 additions and 48 deletions.
  1. +1 −1 bower.json
  2. +13 −37 build/lazyload.js
  3. +7 −8 build/lazyload.min.js
  4. +1 −1 lazyload.js
  5. +1 −1 package.json
View
@@ -1,7 +1,7 @@
{
"name": "lazyload",
"description": "Image lazy loading",
- "version": "2.0.4",
+ "version": "2.0.5",
"main": "lazyload.js",
"ignore": [
"**/.*",
View
@@ -1,10 +1,11 @@
/**
-* @license in-viewport v0.2.6 | github.com/vvo/in-viewport#license
+* @license in-viewport v0.3.0 | github.com/vvo/in-viewport#license
*/
(function(win, doc){
var instances = [];
- win["inViewport"] = inViewport;
+
+ win['inViewport'] = inViewport;
function inViewport(elt, params, cb) {
var opts = {
@@ -26,9 +27,9 @@
}
}
- var newInstance = createInViewport(container);
- instances.push(newInstance);
- return newInstance.inViewport(elt, offset, cb);
+ return instances[
+ instances.push(createInViewport(container)) - 1
+ ].inViewport(elt, offset, cb)
}
function addEvent( el, type, fn ) {
@@ -75,7 +76,7 @@
function createInViewport(container) {
var watches = [];
var scrollContainer = container === doc.body ? win : container;
- var debouncedCheck = debounce(checkImages, 15);
+ var debouncedCheck = debounce(checkElements, 15);
addEvent(scrollContainer, 'scroll', debouncedCheck);
@@ -141,7 +142,7 @@
}
}
- function checkImages() {
+ function checkElements() {
var cb;
while(cb = watches.shift()) {
cb();
@@ -156,20 +157,15 @@
})(window, document);
/**
-* @license lazyload v2.0.4 | github.com/vvo/lazyload#license
+* @license lazyload v2.0.5 | github.com/vvo/lazyload#license
*/
(function(window, document){
- var pageHasLoaded = false;
var lazyAttrs = ['data-src'];
window['lazyload'] = lazyload;
- window['lzld'] = lzld();
-
- addEvent(window, 'load', function() {
- pageHasLoaded = true;
- });
+ window['lzld'] = lazyload();
// Provide libs using getAttribute early to get the good src
// and not the fake data-src
@@ -182,26 +178,14 @@
}
}
- function lzld() {
- var instance;
-
- return function(element) {
- if (instance === undefined) {
- instance = lazyload();
- }
-
- instance(element);
- }
- }
-
function lazyload(opts) {
if (arguments.length > 1) {
return inViewport.apply(undefined, arguments);
}
opts = merge({
- 'offset': 200,
+ 'offset': 333,
'src': 'data-src',
'container': false
}, opts || {});
@@ -280,18 +264,10 @@
return opts;
}
- function addEvent( el, type, fn ) {
- if (el.attachEvent) {
- el.attachEvent( 'on' + type, fn );
- } else {
- el.addEventListener( type, fn, false );
- }
- }
-
// http://webreflection.blogspot.fr/2011/06/partial-polyfills.html
- var indexOf = [].indexOf || function (value) {
+ function indexOf(value) {
for (var i = this.length; i-- && this[i] !== value;);
return i;
- };
+ }
}(window, document))
View
@@ -1,10 +1,9 @@
/*
- in-viewport v0.2.6 | github.com/vvo/in-viewport#license
- lazyload v2.0.4 | github.com/vvo/lazyload#license
+ in-viewport v0.3.0 | github.com/vvo/in-viewport#license
+ lazyload v2.0.5 | github.com/vvo/lazyload#license
*/
-(function(g,k){function h(a,b,d){a.attachEvent?a.attachEvent("on"+b,d):a.addEventListener(b,d,!1)}function p(a){var b;return function(){var d=this,c=arguments;clearTimeout(b);b=setTimeout(function(){b=null;a.apply(d,c)},15)}}function q(a){function b(b,c,e){if(!l(k.documentElement,b)||!l(k.documentElement,a))return setTimeout(d(b,c,e),0);var f=b.getBoundingClientRect(),g=a.getBoundingClientRect(),h=f.left,f=f.top,m=c,n=c;a===k.body?(m+=k.documentElement.clientWidth,n+=k.documentElement.clientHeight):
-(h-=g.left,f-=g.top,m+=a.clientWidth,n+=a.clientHeight);if(h>=-c&&h<=m&&f>=-c&&f<=n)if(e)e(b);else return!0;else if(e)setTimeout(d(b,c,e),0);else return!1}function d(a,d,e){return function(){c.push(function(){b(a,d,e)})}}var c=[],e=a===k.body?g:a,f=p(function(){for(var a;a=c.shift();)a()});h(e,"scroll",f);e===g&&h(g,"resize",f);return{b:a,a:b}}var f=[];g.inViewport=function(a,b,d){var c=k.body;if(void 0===b||"function"===typeof b)d=b,b={};c=b.container||c;b=b.offset||0;for(var e=0;e<f.length;e++)if(f[e].b===
-c)return f[e].a(a,b,d);c=q(c);f.push(c);return c.a(a,b,d)};var l=document.documentElement.compareDocumentPosition?function(a,b){return!!(a.compareDocumentPosition(b)&16)}:document.documentElement.contains?function(a,b){return a!==b&&(a.contains?a.contains(b):!1)}:function(a,b){for(;b=b.parentNode;)if(b===a)return!0;return!1}})(window,document);
-(function(g){function k(a){-1===l.call(f,a)&&f.push(a)}function h(a){function b(b){var e="function"===typeof a.src?a.src(b):b.getAttribute(a.src);e&&(b.src=e);b["data-lzled"]=!0;d[l.call(d,b)]=null}if(1<arguments.length)return inViewport.apply(void 0,arguments);a=q(a||{});"string"===typeof a.src&&k(a.src);var d=[];return function(c){c.onload=null;c.removeAttribute("onload");-1===l.call(d,c)&&inViewport(c,a,b)}}function p(a){a="HTML"+a+"Element";if(!1!==a in g){var b=g[a].prototype.getAttribute;g[a].prototype.getAttribute=
-function(a){if("src"===a){for(var c,e=0,g=f.length;e<g&&!(c=b.call(this,f[e]));e++);return c||b.call(this,a)}return b.call(this,a)}}}function q(a){var b={offset:200,src:"data-src",container:!1},d;for(d in b)void 0===a[d]&&(a[d]=b[d]);return a}var f=["data-src"];g.lazyload=h;g.lzld=function(){var a;return function(b){void 0===a&&(a=h());a(b)}}();(function(a,b,d){a.attachEvent?a.attachEvent("on"+b,d):a.addEventListener(b,d,!1)})(g,"load",function(){});p("Image");p("IFrame");var l=[].indexOf||function(a){for(var b=
-this.length;b--&&this[b]!==a;);return b}})(window,document);
+(function(g,k){function h(a,b,f){a.attachEvent?a.attachEvent("on"+b,f):a.addEventListener(b,f,!1)}function p(a){var b;return function(){var f=this,d=arguments;clearTimeout(b);b=setTimeout(function(){b=null;a.apply(f,d)},15)}}function q(a){function b(b,d,e){if(!l(k.documentElement,b)||!l(k.documentElement,a))return setTimeout(f(b,d,e),0);var c=b.getBoundingClientRect(),g=a.getBoundingClientRect(),h=c.left,c=c.top,m=d,n=d;a===k.body?(m+=k.documentElement.clientWidth,n+=k.documentElement.clientHeight):
+(h-=g.left,c-=g.top,m+=a.clientWidth,n+=a.clientHeight);if(h>=-d&&h<=m&&c>=-d&&c<=n)if(e)e(b);else return!0;else if(e)setTimeout(f(b,d,e),0);else return!1}function f(a,f,e){return function(){d.push(function(){b(a,f,e)})}}var d=[],e=a===k.body?g:a,c=p(function(){for(var a;a=d.shift();)a()});h(e,"scroll",c);e===g&&h(g,"resize",c);return{b:a,a:b}}var c=[];g.inViewport=function(a,b,f){var d=k.body;if(void 0===b||"function"===typeof b)f=b,b={};d=b.container||d;b=b.offset||0;for(var e=0;e<c.length;e++)if(c[e].b===
+d)return c[e].a(a,b,f);return c[c.push(q(d))-1].a(a,b,f)};var l=document.documentElement.compareDocumentPosition?function(a,b){return!!(a.compareDocumentPosition(b)&16)}:document.documentElement.contains?function(a,b){return a!==b&&(a.contains?a.contains(b):!1)}:function(a,b){for(;b=b.parentNode;)if(b===a)return!0;return!1}})(window,document);
+(function(g){function k(a){-1===c.call(l,a)&&l.push(a)}function h(a){function b(b){var e="function"===typeof a.src?a.src(b):b.getAttribute(a.src);e&&(b.src=e);b["data-lzled"]=!0;f[c.call(f,b)]=null}if(1<arguments.length)return inViewport.apply(void 0,arguments);a=q(a||{});"string"===typeof a.src&&k(a.src);var f=[];return function(d){d.onload=null;d.removeAttribute("onload");-1===c.call(f,d)&&inViewport(d,a,b)}}function p(a){a="HTML"+a+"Element";if(!1!==a in g){var b=g[a].prototype.getAttribute;g[a].prototype.getAttribute=
+function(a){if("src"===a){for(var d,e=0,c=l.length;e<c&&!(d=b.call(this,l[e]));e++);return d||b.call(this,a)}return b.call(this,a)}}}function q(a){var b={offset:333,src:"data-src",container:!1},c;for(c in b)void 0===a[c]&&(a[c]=b[c]);return a}function c(a){for(var b=this.length;b--&&this[b]!==a;);return b}var l=["data-src"];g.lazyload=h;g.lzld=h();p("Image");p("IFrame")})(window,document);
View
@@ -1,5 +1,5 @@
/**
-* @license lazyload v2.0.4 | github.com/vvo/lazyload#license
+* @license lazyload v2.0.5 | github.com/vvo/lazyload#license
*/
(function(window, document){
View
@@ -1,6 +1,6 @@
{
"name": "lazyload",
- "version": "2.0.4",
+ "version": "2.0.5",
"description": "Image lazy loading",
"main": "build/lazyload.min.js",
"scripts": {

0 comments on commit e5139a8

Please sign in to comment.