Skip to content

Commit aa5fc0a

Browse files
committed
1.7.2
- fixed possible problems with jQuery 3's new async ready state - added 'main' field to package.json - changed '.error()' to '.trigger("error")' - new 'picture' plugin - new 'vimeo' plugin - added cross domain / CORS hedaers to 'iframe' plugin - corrected error response of 'youtube' plugin
1 parent ed4d037 commit aa5fc0a

16 files changed

+467
-25
lines changed

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ Some examples below:
5757
Lazy and all plugins are available over [cdnjs](http://cdnjs.com) and [jsDelivr](http://jsdelivr.com) CDN and can directly included to every page.
5858
```HTML
5959
<!-- jsDeliver -->
60-
<script type="text/javascript" src="//cdn.jsdelivr.net/jquery.lazy/1.7.1/jquery.lazy.min.js"></script>
61-
<script type="text/javascript" src="//cdn.jsdelivr.net/jquery.lazy/1.7.1/jquery.lazy.plugins.min.js"></script>
60+
<script type="text/javascript" src="//cdn.jsdelivr.net/jquery.lazy/1.7.2/jquery.lazy.min.js"></script>
61+
<script type="text/javascript" src="//cdn.jsdelivr.net/jquery.lazy/1.7.2/jquery.lazy.plugins.min.js"></script>
6262

6363
<!-- cdnjs -->
64-
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery.lazy/1.7.1/jquery.lazy.min.js"></script>
65-
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery.lazy/1.7.1/jquery.plugins.min.js"></script>
64+
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery.lazy/1.7.2/jquery.lazy.min.js"></script>
65+
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery.lazy/1.7.2/jquery.plugins.min.js"></script>
6666
```
6767

6868
#### Self-Hosted

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "jquery-lazy",
33
"description": "Lazy is a fast, feature-rich and lightweight delayed content loading plugin for jQuery and Zepto. It's designed to speed up page loading times and decrease traffic to your users by only loading the content in view. You can use Lazy in all vertical and horizontal scroll ways. It supports images in 'img' tags and backgrounds, supplied with css like 'background-image', by default. On those elements Lazy can set an default image or a placeholder while loading and supports retina displays as well. But Lazy is even able to load any other content you want by plugins and custom loaders.",
4-
"version": "1.7.1",
4+
"version": "1.7.2",
55
"main": "jquery.lazy.min.js",
66
"license": [
77
"MIT",

jquery.lazy.js

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* jQuery & Zepto Lazy - v1.7.1
2+
* jQuery & Zepto Lazy - v1.7.2
33
* http://jquery.eisbehr.de/lazy/
44
*
55
* Copyright 2012 - 2016, Daniel 'Eisbehr' Kern
@@ -25,7 +25,13 @@
2525
* unique plugin instance id counter
2626
* @type {number}
2727
*/
28-
lazyInstanceId = 0;
28+
lazyInstanceId = 0,
29+
30+
/**
31+
* helper to register window load for jQuery 3
32+
* @type {boolean}
33+
*/
34+
windowLoaded = false;
2935

3036
/**
3137
* make lazy available to jquery - and make it a bit more case-insensitive :)
@@ -409,7 +415,7 @@
409415
element.off(_error);
410416
errorCallback();
411417
}
412-
})) element.error();
418+
})) element.trigger(_error);
413419
}
414420

415421
// handle images
@@ -601,8 +607,8 @@
601607
return false;
602608
}
603609

604-
// if event driven don't wait for page loading
605-
if( config.bind == "event" )
610+
// if event driven or window is already loaded don't wait for page loading
611+
if( config.bind == "event" || windowLoaded )
606612
_initialize();
607613

608614
// otherwise load initial items and start lazy after page load
@@ -787,4 +793,8 @@
787793
onError : undefined,
788794
onFinishedAll : undefined
789795
};
796+
797+
// register window load event globally to prevent not loading elements
798+
// since jQuery 3.X ready state is fully async and may be executed after 'load'
799+
$(window).on("load", function() { windowLoaded = true; });
790800
})(window);

jquery.lazy.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)