Skip to content

Commit

Permalink
Switch bind to one.
Browse files Browse the repository at this point in the history
From the jQuery docs:

> As of jQuery 1.7, the .on() method is the preferred method for
> attaching event handlers to a document. For earlier versions, the
> .bind() method is used for attaching an event handler directly to
> elements
  • Loading branch information
samccone committed Jun 30, 2015
1 parent ecf32fa commit 5712b52
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions jquery.lazyload.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@

/* Fire one scroll event per scroll. Not one scroll event per image. */
if (0 === settings.event.indexOf("scroll")) {
$container.bind(settings.event, function() {
$container.on(settings.event, function() {
return update();
});
}
Expand Down Expand Up @@ -134,7 +134,7 @@
/* When wanted event is triggered load original image */
/* by triggering appear. */
if (0 !== settings.event.indexOf("scroll")) {
$self.bind(settings.event, function() {
$self.on(settings.event, function() {
if (!self.loaded) {
$self.trigger("appear");
}
Expand All @@ -143,14 +143,14 @@
});

/* Check if something appears when window is resized. */
$window.bind("resize", function() {
$window.on("resize", function() {
update();
});

/* With IOS5 force loading images when navigating with back button. */
/* Non optimal workaround. */
if ((/(?:iphone|ipod|ipad).*os 5/gi).test(navigator.appVersion)) {
$window.bind("pageshow", function(event) {
$window.on("pageshow", function(event) {
if (event.originalEvent && event.originalEvent.persisted) {
elements.each(function() {
$(this).trigger("appear");
Expand Down

0 comments on commit 5712b52

Please sign in to comment.