Skip to content

Commit

Permalink
0.6.2
Browse files Browse the repository at this point in the history
- added new parameter 'imageBase'
- removed `lazy.jquery.json` because plugin registry is dead :(
- reformatted 'bower.json' and 'package.json'
- fixed cdnjs source link
  • Loading branch information
dkern committed Nov 12, 2015
1 parent 72810ab commit 549b7ff
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 178 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ First of all, you will need a copy of [jQuery](http://jquery.com) to use Lazy su
Lazy is available over [cdnjs](http://cdnjs.com) and [jsDelivr](http://jsdelivr.com) CDN and can directly included to every page.
```HTML
<!-- cdnjs -->
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery.lazy/0.6.1/jquery.lazy.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery.lazy/0.6.2/jquery.lazy.min.js"></script>

<!-- jsDeliver -->
<script type="text/javascript" src="//cdn.jsdelivr.net/jquery.lazy/0.6.1/jquery.lazy.min.js"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/jquery.lazy/0.6.2/jquery.lazy.min.js"></script>
```

#### Self-Hosted
Expand Down Expand Up @@ -172,6 +172,7 @@ threshold | *integer* | *500* | <sub>Amount of pixels below the v
visibleOnly | *boolean* | *false* | <sub>Determine if only visible elements should be load.</sub>
appendScroll | *integer* | *window* | <sub>An element to listen on for scroll events, useful when images are stored in a container.</sub>
scrollDirection | *string* | *both* | <sub>Determines the handles scroll direction. Possible values are `both`, `vertical` and `horizontal`.</sub>
imageBase | *string* | *null* | <sub>If defined this will be used as base path for all images loaded by this instance.</sub>
defaultImage | *string* | *blank image* | <sub>Base64 image string, set as default image source for every image without a predefined source attribute.</sub>
placeholder | *string* | *null* | <sub>Base64 image string, set a background on every element as loading placeholder.</sub>
delay | *integer* | *-1* | <sub>If you want to load all elements at once after page load, then you can specify a delay time in milliseconds.</sub>
Expand Down
98 changes: 45 additions & 53 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,54 +1,46 @@
{
"name": "jquery-lazy",
"description": "Lazy is a fast, feature-rich and lightweight delayed content loading plugin for jQuery. 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 or any other content by custom loaders. On images Lazy can set an default image or a placeholder while loading and supports retina displays as well.",
"version": "0.6.1",
"main": "jquery.lazy.min.js",
"license":
[
"MIT",
"GPL-2.0"
],
"ignore":
[
"*.md",
"*.json"
],
"keywords":
[
"lazy",
"lazyload",
"load",
"loader",
"image",
"images",
"background",
"content",
"speed",
"delay",
"delayed",
"pageload",
"performance",
"retina",
"placeholder",
"jquery",
"jquery-plugin"
],
"authors":
[
{
"name": "Daniel 'Eisbehr' Kern",
"email": "[email protected]",
"homepage": "http://www.eisbehr.de/"
}
],
"homepage": "http://jquery.eisbehr.de/lazy/",
"repository":
{
"type": "git",
"url": "git://github.com/eisbehr-/jquery.lazy.git"
},
"dependencies":
{
"jquery": ">=1.7.0"
}
}
"name": "jquery-lazy",
"description": "Lazy is a fast, feature-rich and lightweight delayed content loading plugin for jQuery. 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 or any other content by custom loaders. On images Lazy can set an default image or a placeholder while loading and supports retina displays as well.",
"version": "0.6.2",
"main": "jquery.lazy.min.js",
"license": [
"MIT",
"GPL-2.0"
],
"ignore": [
"*.md",
"*.json"
],
"keywords": [
"lazy",
"lazyload",
"load",
"loader",
"image",
"images",
"background",
"content",
"speed",
"delay",
"delayed",
"pageload",
"performance",
"retina",
"placeholder",
"jquery",
"jquery-plugin"
],
"authors": [{
"name": "Daniel 'Eisbehr' Kern",
"email": "[email protected]",
"homepage": "http://www.eisbehr.de/"
}],
"homepage": "http://jquery.eisbehr.de/lazy/",
"repository": {
"type": "git",
"url": "git://github.com/eisbehr-/jquery.lazy.git"
},
"dependencies": {
"jquery": ">=1.7.0"
}
}
23 changes: 15 additions & 8 deletions jquery.lazy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* jQuery Lazy - v0.6.1
* jQuery Lazy - v0.6.2
* http://jquery.eisbehr.de/lazy/
*
* Copyright 2012 - 2015, Daniel 'Eisbehr' Kern
Expand Down Expand Up @@ -170,13 +170,17 @@
{
// destroy instance if option is enabled
if( configuration("autoDestroy") )
// noinspection JSUnresolvedFunction
instance.destroy();

return;
}

// helper to see if something was changed
var loadTriggered = false;
var loadTriggered = false,

// get image base once, not on every image loop
imageBase = configuration("imageBase") ? configuration("imageBase") : "";

// loop all available items
for( var i = 0; i < items.length; i++ )
Expand All @@ -187,7 +191,7 @@
{
var element = $(item),
tag = item.tagName.toLowerCase(),
attribute = element.attr(configuration("attribute")),
attribute = imageBase + element.attr(configuration("attribute")),
customLoader;

// is not already handled
Expand All @@ -208,7 +212,7 @@
element.data(configuration("handledName"), true);

// load item
_handleItem(element, tag, customLoader);
_handleItem(element, tag, imageBase, customLoader);
}
}
})(items[i]);
Expand All @@ -226,10 +230,11 @@
* @access private
* @param {object} element
* @param {string} tag
* @param {string} imageBase
* @param {function} [customLoader]
* @return void
*/
function _handleItem(element, tag, customLoader)
function _handleItem(element, tag, imageBase, customLoader)
{
// increment count of items waiting for after load
++_awaitingAfterLoad;
Expand Down Expand Up @@ -309,7 +314,7 @@
});

// set source
imageObj.attr("src", element.attr(configuration(_isRetinaDisplay && element.attr(configuration("retinaAttribute")) ? "retinaAttribute" : "attribute")));
imageObj.attr("src", imageBase + element.attr(configuration(_isRetinaDisplay && element.attr(configuration("retinaAttribute")) ? "retinaAttribute" : "attribute")));

// call after load even on cached image
if( imageObj.complete ) imageObj.load();
Expand Down Expand Up @@ -554,14 +559,17 @@
_instance.destroy = function ()
{
// unbind instance generated events
// noinspection JSUnresolvedFunction
$(_instance.config("appendScroll")).off("." + _instance.name, _events.e);

// clear events
_events = {};
};

// start using lazy and return all elements to be chainable or instance for further use
// noinspection JSUnresolvedVariable
_executeLazy(_instance, _instance.config, elements, _events);
// noinspection JSUnresolvedFunction
return _instance.config("chainable") ? elements : _instance;
}

Expand Down Expand Up @@ -590,10 +598,9 @@
visibleOnly : false,
appendScroll : window,
scrollDirection : "both",
imageBase : null,
defaultImage : "data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==",
placeholder : null,

// delay
delay : -1,
combined : false,

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.

56 changes: 0 additions & 56 deletions lazy.jquery.json

This file was deleted.

Loading

0 comments on commit 549b7ff

Please sign in to comment.