Skip to content

Commit

Permalink
1.7.5
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
dkern committed Apr 26, 2017
1 parent 96e0e9d commit f77f8ea
Show file tree
Hide file tree
Showing 23 changed files with 100 additions and 94 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ Some examples below:
Lazy and all plugins are available over [cdnjs](http://cdnjs.com) and [jsDelivr](http://jsdelivr.com) CDN and can directly included to every page.
```HTML
<!-- jsDeliver -->
<script type="text/javascript" src="//cdn.jsdelivr.net/jquery.lazy/1.7.4/jquery.lazy.min.js"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/jquery.lazy/1.7.4/jquery.lazy.plugins.min.js"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/jquery.lazy/1.7.5/jquery.lazy.min.js"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/jquery.lazy/1.7.5/jquery.lazy.plugins.min.js"></script>

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

#### Self-Hosted
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jquery-lazy",
"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.",
"version": "1.7.3",
"version": "1.7.5",
"main": "jquery.lazy.min.js",
"license": [
"MIT",
Expand Down
29 changes: 17 additions & 12 deletions jquery.lazy.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*!
* jQuery & Zepto Lazy - v1.7.4
* jQuery & Zepto Lazy - v1.7.5
* http://jquery.eisbehr.de/lazy/
*
* Copyright 2012 - 2016, Daniel 'Eisbehr' Kern
* Copyright 2012 - 2017, Daniel 'Eisbehr' Kern
*
* Dual licensed under the MIT and GPL-2.0 licenses:
* http://www.opensource.org/licenses/mit-license.php
Expand Down Expand Up @@ -224,7 +224,12 @@
events.f = function(forcedItems) {
for( var i = 0; i < forcedItems.length; i++ ) {
// only handle item if available in current instance
var item = items.filter(forcedItems[i]);
// use a compare function, because Zepto can't handle object parameter for filter
// var item = items.filter(forcedItems[i]);
/* jshint loopfunc: true */
var item = items.filter(function() {
return this === forcedItems[i];
});

if( item.length ) {
_lazyLoadItems(false, item);
Expand Down Expand Up @@ -274,19 +279,19 @@
elementImageBase = element.attr(config.imageBaseAttribute) || imageBase;

// generate and update source set if an image base is set
if( tag == _img && elementImageBase && element.attr(srcsetAttribute) )
if( tag === _img && elementImageBase && element.attr(srcsetAttribute) )
element.attr(srcsetAttribute, _getCorrectedSrcSet(element.attr(srcsetAttribute), elementImageBase));

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

// set default image on every element without source
if( tag == _img && defaultImage && !element.attr(_src) )
if( tag === _img && defaultImage && !element.attr(_src) )
element.attr(_src, defaultImage);

// set placeholder on every element without background image
else if( tag != _img && placeholder && (!element.css(_backgroundImage) || element.css(_backgroundImage) == "none") )
else if( tag !== _img && placeholder && (!element.css(_backgroundImage) || element.css(_backgroundImage) === "none") )
element.css(_backgroundImage, "url('" + placeholder + "')");
}
}
Expand Down Expand Up @@ -332,9 +337,9 @@
// and image source or source set attribute is available
(attribute || element.attr(srcsetAttribute)) && (
// and is image tag where attribute is not equal source or source set
(tag == _img && (elementImageBase + attribute != element.attr(_src) || element.attr(srcsetAttribute) != element.attr(_srcset))) ||
(tag === _img && (elementImageBase + attribute !== element.attr(_src) || element.attr(srcsetAttribute) !== element.attr(_srcset))) ||
// or is non image tag where attribute is not equal background
(tag != _img && elementImageBase + attribute != element.css(_backgroundImage))
(tag !== _img && elementImageBase + attribute !== element.css(_backgroundImage))
) ||
// or custom loader is available
customLoader ))
Expand Down Expand Up @@ -446,7 +451,7 @@

// set image back to element
// do it as single 'attr' calls, to be sure 'src' is set after 'srcset'
if( tag == _img )
if( tag === _img )
element.attr(_sizes, imageObj.attr(_sizes))
.attr(_srcset, imageObj.attr(_srcset))
.attr(_src, imageObj.attr(_src));
Expand Down Expand Up @@ -509,8 +514,8 @@
// check if element is even in loadable area from right
(-threshold < elementBound.right);

if( direction == "vertical" ) return vertical;
else if( direction == "horizontal" ) return horizontal;
if( direction === "vertical" ) return vertical;
else if( direction === "horizontal" ) return horizontal;

return vertical && horizontal;
}
Expand Down Expand Up @@ -621,7 +626,7 @@
}

// if event driven or window is already loaded don't wait for page loading
if( config.bind == "event" || windowLoaded )
if( config.bind === "event" || windowLoaded )
_initialize();

// otherwise load initial items and start lazy after page load
Expand Down
4 changes: 2 additions & 2 deletions jquery.lazy.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f77f8ea

Please sign in to comment.