Skip to content

Commit

Permalink
don't apply lazy loading if device is iPad or Android and container i…
Browse files Browse the repository at this point in the history
…s window
  • Loading branch information
jney committed Nov 7, 2010
1 parent 01a9cd2 commit e36935b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
21 changes: 14 additions & 7 deletions jquery.lazyload.js
Expand Up @@ -38,6 +38,13 @@
, namespace = settings.namespace
, event = settings.event + namespace
, appear = 'appear' + namespace;

// don't apply lazy loading if device is iPad or Android
// and container is window
if ( navigator.userAgent.match(/Android|iPad/)
&& container[0] !== window ) {
return this;
}

var isInViewport = function (element) {
element = $(element);
Expand Down Expand Up @@ -74,9 +81,9 @@
if (!e) return false;

var top = 0
, left = 0
, width = e.offsetWidth
, height = e.offsetHeight;
, left = 0
, width = e.offsetWidth
, height = e.offsetHeight;

do {
e.offsetParent;
Expand Down Expand Up @@ -123,9 +130,9 @@
if (isInViewport($(self))) {
self.loaded = TRUE;
} else if ( settings.event !== SCROLL
|| !$(self).attr(SRC)
|| settings.placeholder === $(self).attr(SRC)
|| (!isInViewport($(self)))) {
|| !$(self).attr(SRC)
|| settings.placeholder === $(self).attr(SRC)
|| (!isInViewport($(self)))) {

settings.placeholder
? $(self).attr(SRC, settings.placeholder)
Expand All @@ -137,7 +144,7 @@
/* When appear is triggered load original image. */
$(self).one(appear, function() {
if (!this.loaded) {
$("<img />").bind("load", function() {
$("<img />").load(function() {
$(self)
.hide()
.attr(SRC, $(self).data(ORIGINAL))
Expand Down
2 changes: 1 addition & 1 deletion jquery.lazyload.min.js

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

0 comments on commit e36935b

Please sign in to comment.