Skip to content

Commit

Permalink
Add load handling for extra methods
Browse files Browse the repository at this point in the history
  • Loading branch information
auscaster committed Feb 8, 2017
1 parent 4827a5d commit 21bceac
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "jquery-recliner",
"version": "0.2.4",
"version": "0.2.5",
"description": "Lightweight plugin for lazy loading images and dynamic content",
"main": "recliner.js",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion recliner.jquery.json
Expand Up @@ -7,7 +7,7 @@
"lazy load",
"jquery-plugin"
],
"version": "0.2.4",
"version": "0.2.5",
"author": {
"name": "Sourcey",
"url": "http://sourcey.com"
Expand Down
23 changes: 12 additions & 11 deletions recliner.js
Expand Up @@ -32,21 +32,22 @@
source = $e.attr(options.attrib),
type = $e.prop('tagName');
if (source) {
$e.addClass('lazy-loading');
if (type == 'IMG' || type == 'IFRAME') {
$e.attr('src', source);
$e[0].onload = function(ev) { onload($e); };
}
else if (options.getScript === true) {
$.getScript(source, function(ev) { onload($e); });
}
else {

// ajax load non image and iframe elements
$e.addClass('lazy-loading');
$e.load(source, function(ev) {
onload($e);
});
return;
$e.load(source, function(ev) { onload($e); });
}
}

onload($e);
else {
onload($e); // set as loaded if no action taken
}
}

// handle element load complete
Expand Down Expand Up @@ -121,9 +122,9 @@
window
.matchMedia('print')
.addListener(function (mql) {
if (mql.matches) {
$(selector).trigger('lazyload');
}
if (mql.matches) {
$(selector).trigger('lazyload');
}
});
}

Expand Down
2 changes: 1 addition & 1 deletion recliner.min.js

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

0 comments on commit 21bceac

Please sign in to comment.