Skip to content

Commit

Permalink
Add configurable effect and it's speed.
Browse files Browse the repository at this point in the history
  • Loading branch information
tuupola committed Mar 8, 2008
1 parent f8dcbf6 commit cf9419c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions jquery.lazyload.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
var settings = {
threshold : 0,
failurelimit : 0,
event : "scroll"
event : "scroll",
effect : "show"
};

if(options) {
Expand Down Expand Up @@ -51,7 +52,7 @@
return this.each(function() {
var self = this;

/* TODO: why to use attr? Possible memory leak. */
/* TODO: use .data() instead of .attr() */
$(self).attr("original", $(self).attr("src"));
if ("scroll" != settings.event
|| $.belowthefold(self, settings)
Expand All @@ -66,19 +67,21 @@
self.loaded = true;
}

/* When appear is triggered load original image. */
$(self).bind("appear", function() {
// console.log("appear");
$("<img>")
.attr("src", $(self).attr("original"))
.bind("load", function() {
$(self)
// .hide()
.attr("src", $(self).attr("original"));
// .fadeIn("fast");
.hide()
.attr("src", $(self).attr("original"))
[settings.effect](settings.effectspeed);
self.loaded = true;
});
});

/* When wanted event is triggered load original image */
/* by triggering appear. */
if ("scroll" != settings.event) {
$(self).bind(settings.event, function(event) {
if (!self.loaded) {
Expand Down

0 comments on commit cf9419c

Please sign in to comment.