Skip to content

Commit f26dbf8

Browse files
committed
Passing instance to "backstetch.show" listeners for convenience.
1 parent e152c20 commit f26dbf8

File tree

4 files changed

+21
-12
lines changed

4 files changed

+21
-12
lines changed

README.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,7 @@ Destroy the Backstretch instance. Optionally, you can pass in a Boolean paramete
9393

9494
This method is called automatically when the container (window or block-level element) is resized, however you can always call this manually if needed.
9595

96-
## Events
97-
98-
### backstretch.show
99-
100-
Backstretch will fire a "backstretch.show" event everytime a new image loads. If you listen for that event, you can, for example, coordinate other changes to coincide with your slideshow.
101-
102-
## Images
96+
### Public Variables
10397

10498
Sometimes, you'll want to access Backstretch's images after you've instantiated the plugin. For example, perhaps you'd like to be able add more images to a slideshow. Doing so is easy. You can access the images array as follows:
10599

@@ -123,6 +117,21 @@ Additionally, the current index of a slideshow is available through the instance
123117
$("body").data("backstretch").index;
124118
```
125119

120+
## Events
121+
122+
### backstretch.show
123+
124+
Backstretch will fire a "backstretch.show" event everytime a new image loads, triggering a function that is passed the event and Backstetch instance. If you listen for that event, you can, for example, coordinate other changes to coincide with your slideshow.
125+
126+
```javascript
127+
$(window).on("backstretch.show", function (e, instance) {
128+
// If we wanted to stop the slideshow after it reached the end
129+
if (instance.index === instance.images.length - 1) {
130+
instance.pause();
131+
};
132+
});
133+
```
134+
126135
## Changelog
127136

128137
### Version 2.0

jquery.backstretch.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! Backstretch - v2.0.1 - 2012-10-01
1+
/*! Backstretch - v2.0.2 - 2012-11-27
22
* http://srobbin.com/jquery-plugins/backstretch/
33
* Copyright (c) 2012 Scott Robbin; Licensed MIT */
44

@@ -239,7 +239,7 @@
239239
}
240240

241241
// Trigger the event
242-
self.$container.trigger(evt);
242+
self.$container.trigger(evt, self);
243243
});
244244
})
245245
.appendTo(self.$wrap);

jquery.backstretch.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/jquery.backstretch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@
243243
}
244244

245245
// Trigger the event
246-
self.$container.trigger(evt);
246+
self.$container.trigger(evt, self);
247247
});
248248
})
249249
.appendTo(self.$wrap);

0 commit comments

Comments
 (0)