Skip to content

Commit f77f8ea

Browse files
committed
1.7.5
- strict checks for all comparisons - fixed bug with 'filter' for Zepto on 'force' function - fixed examples in picture plugin file - added 'jshint' for dependencies - fixed version for bower - fixed version in plugins file - updated year in all files
1 parent 96e0e9d commit f77f8ea

23 files changed

+100
-94
lines changed

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ Some examples below:
6565
Lazy and all plugins are available over [cdnjs](http://cdnjs.com) and [jsDelivr](http://jsdelivr.com) CDN and can directly included to every page.
6666
```HTML
6767
<!-- jsDeliver -->
68-
<script type="text/javascript" src="//cdn.jsdelivr.net/jquery.lazy/1.7.4/jquery.lazy.min.js"></script>
69-
<script type="text/javascript" src="//cdn.jsdelivr.net/jquery.lazy/1.7.4/jquery.lazy.plugins.min.js"></script>
68+
<script type="text/javascript" src="//cdn.jsdelivr.net/jquery.lazy/1.7.5/jquery.lazy.min.js"></script>
69+
<script type="text/javascript" src="//cdn.jsdelivr.net/jquery.lazy/1.7.5/jquery.lazy.plugins.min.js"></script>
7070

7171
<!-- cdnjs -->
72-
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery.lazy/1.7.4/jquery.lazy.min.js"></script>
73-
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery.lazy/1.7.4/jquery.lazy.plugins.min.js"></script>
72+
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery.lazy/1.7.5/jquery.lazy.min.js"></script>
73+
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery.lazy/1.7.5/jquery.lazy.plugins.min.js"></script>
7474
```
7575

7676
#### 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.3",
4+
"version": "1.7.5",
55
"main": "jquery.lazy.min.js",
66
"license": [
77
"MIT",

jquery.lazy.js

+17-12
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*!
2-
* jQuery & Zepto Lazy - v1.7.4
2+
* jQuery & Zepto Lazy - v1.7.5
33
* http://jquery.eisbehr.de/lazy/
44
*
5-
* Copyright 2012 - 2016, Daniel 'Eisbehr' Kern
5+
* Copyright 2012 - 2017, Daniel 'Eisbehr' Kern
66
*
77
* Dual licensed under the MIT and GPL-2.0 licenses:
88
* http://www.opensource.org/licenses/mit-license.php
@@ -224,7 +224,12 @@
224224
events.f = function(forcedItems) {
225225
for( var i = 0; i < forcedItems.length; i++ ) {
226226
// only handle item if available in current instance
227-
var item = items.filter(forcedItems[i]);
227+
// use a compare function, because Zepto can't handle object parameter for filter
228+
// var item = items.filter(forcedItems[i]);
229+
/* jshint loopfunc: true */
230+
var item = items.filter(function() {
231+
return this === forcedItems[i];
232+
});
228233

229234
if( item.length ) {
230235
_lazyLoadItems(false, item);
@@ -274,19 +279,19 @@
274279
elementImageBase = element.attr(config.imageBaseAttribute) || imageBase;
275280

276281
// generate and update source set if an image base is set
277-
if( tag == _img && elementImageBase && element.attr(srcsetAttribute) )
282+
if( tag === _img && elementImageBase && element.attr(srcsetAttribute) )
278283
element.attr(srcsetAttribute, _getCorrectedSrcSet(element.attr(srcsetAttribute), elementImageBase));
279284

280285
// add loader to forced element types
281286
if( forcedTags[tag] !== undefined && !element.attr(loaderAttribute) )
282287
element.attr(loaderAttribute, forcedTags[tag]);
283288

284289
// set default image on every element without source
285-
if( tag == _img && defaultImage && !element.attr(_src) )
290+
if( tag === _img && defaultImage && !element.attr(_src) )
286291
element.attr(_src, defaultImage);
287292

288293
// set placeholder on every element without background image
289-
else if( tag != _img && placeholder && (!element.css(_backgroundImage) || element.css(_backgroundImage) == "none") )
294+
else if( tag !== _img && placeholder && (!element.css(_backgroundImage) || element.css(_backgroundImage) === "none") )
290295
element.css(_backgroundImage, "url('" + placeholder + "')");
291296
}
292297
}
@@ -332,9 +337,9 @@
332337
// and image source or source set attribute is available
333338
(attribute || element.attr(srcsetAttribute)) && (
334339
// and is image tag where attribute is not equal source or source set
335-
(tag == _img && (elementImageBase + attribute != element.attr(_src) || element.attr(srcsetAttribute) != element.attr(_srcset))) ||
340+
(tag === _img && (elementImageBase + attribute !== element.attr(_src) || element.attr(srcsetAttribute) !== element.attr(_srcset))) ||
336341
// or is non image tag where attribute is not equal background
337-
(tag != _img && elementImageBase + attribute != element.css(_backgroundImage))
342+
(tag !== _img && elementImageBase + attribute !== element.css(_backgroundImage))
338343
) ||
339344
// or custom loader is available
340345
customLoader ))
@@ -446,7 +451,7 @@
446451

447452
// set image back to element
448453
// do it as single 'attr' calls, to be sure 'src' is set after 'srcset'
449-
if( tag == _img )
454+
if( tag === _img )
450455
element.attr(_sizes, imageObj.attr(_sizes))
451456
.attr(_srcset, imageObj.attr(_srcset))
452457
.attr(_src, imageObj.attr(_src));
@@ -509,8 +514,8 @@
509514
// check if element is even in loadable area from right
510515
(-threshold < elementBound.right);
511516

512-
if( direction == "vertical" ) return vertical;
513-
else if( direction == "horizontal" ) return horizontal;
517+
if( direction === "vertical" ) return vertical;
518+
else if( direction === "horizontal" ) return horizontal;
514519

515520
return vertical && horizontal;
516521
}
@@ -621,7 +626,7 @@
621626
}
622627

623628
// if event driven or window is already loaded don't wait for page loading
624-
if( config.bind == "event" || windowLoaded )
629+
if( config.bind === "event" || windowLoaded )
625630
_initialize();
626631

627632
// otherwise load initial items and start lazy after page load

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)