Skip to content

Commit

Permalink
Add 3rd param for in beforeStart, afterEnd callbacks with btnGo/btnPr…
Browse files Browse the repository at this point in the history
…ev/btnNext info

Closes gh-46.
  • Loading branch information
kswedberg committed Feb 16, 2015
1 parent 740861e commit 044b073
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 60 deletions.
2 changes: 1 addition & 1 deletion bower.json
@@ -1,6 +1,6 @@
{
"name": "jquery.jcarousellite",
"version": "1.9.2",
"version": "1.9.3",
"title": "jCarousel Lite",
"description": "A jQuery carousel plugin based on jCarouselLite by Ganeshji Marwaha",
"author": {
Expand Down
81 changes: 41 additions & 40 deletions index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion jcarousellite.jquery.json
Expand Up @@ -2,7 +2,7 @@
"name": "jcarousellite",
"title": "jCarousel Lite",
"description": "A jQuery carousel plugin based on jCarouselLite by Ganeshji Marwaha",
"version": "1.9.2",
"version": "1.9.3",
"homepage": "http://kswedberg.github.com/jquery-carousel-lite/",
"author": {
"name": "Karl Swedberg",
Expand Down
18 changes: 11 additions & 7 deletions jcarousellite.js
@@ -1,15 +1,15 @@
/*!
* jCarousel Lite - v1.9.2 - 2014-08-18
* jCarousel Lite - v1.9.3 - 2015-02-16
* http://kswedberg.github.com/jquery-carousel-lite/
* Copyright (c) 2014 Karl Swedberg
* Copyright (c) 2015 Karl Swedberg
* based on the original by Ganeshji Marwaha (gmarwaha.com)
* Licensed MIT (http://kswedberg.github.com/jquery-carousel-lite/blob/master/LICENSE-MIT)
*/


(function($) {
$.jCarouselLite = {
version: '1.9.2',
version: '1.9.3',
curr: 0
};

Expand Down Expand Up @@ -98,7 +98,11 @@
$btnsGo.each(function(i) {
$(this).bind('click.jc', function(event) {
event.preventDefault();
return go(o.circular ? visibleNum + i : i);
var btnInfo = {
btnGo: this,
btnGoIndex: i
};
return go(o.circular ? visibleNum + i : i, btnInfo);
});
});
activeBtnTypes.go = 1;
Expand Down Expand Up @@ -319,7 +323,7 @@
offset = settings.offset || 0;

if (o.beforeStart) {
o.beforeStart.call(div, vis(), direction);
o.beforeStart.call(div, vis(), direction, settings);
}

// If circular and we are in first or last, then go to the other end
Expand Down Expand Up @@ -376,7 +380,7 @@

if (prev === curr && !settings.force) {
if (o.afterEnd) {
o.afterEnd.call(div, vis(), direction);
o.afterEnd.call(div, vis(), direction, settings);
}
return curr;
}
Expand All @@ -386,7 +390,7 @@
aniProps[animCss] = -(curr * styles.liSize);
ul.anim(aniProps, speed, o.easing, function() {
if (o.afterEnd) {
o.afterEnd.call(div, vis(), direction);
o.afterEnd.call(div, vis(), direction, settings);
}
running = false;
});
Expand Down
6 changes: 3 additions & 3 deletions jcarousellite.min.js

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

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -2,7 +2,7 @@
"name": "jcarousellite",
"title": "jCarousel Lite",
"description": "A jQuery carousel plugin based on jCarouselLite by Ganeshji Marwaha",
"version": "1.9.2",
"version": "1.9.3",
"author": {
"name": "Karl Swedberg",
"email": "kswedberg@gmail.com",
Expand Down
5 changes: 3 additions & 2 deletions readme.md
Expand Up @@ -2,7 +2,7 @@

By [Karl Swedberg](http://www.learningjquery.com/), based on the original by [Ganeshji Marwaha](gmarwaha.com).

This jQuery plugin creates a carousel-style navigation widget for images, or any content, from simple HTML markup. Check out a [bare-bones demo](http://plugins.learningjquery.com/jcarousellite/demo/).
This jQuery plugin creates a carousel-style navigation widget for images, or any content, from simple HTML markup.

## Getting Started

Expand Down Expand Up @@ -424,10 +424,11 @@ $('div.carousel').jCarouselLite({
If you want to do some logic before the slide starts and after the slide ends,
you can register these 2 callbacks. Inside the functions, `this` is the
div on which the .jCarouselLite() method is called.
The functions will be passed two arguments:
The functions will be passed three arguments:

1. Array of elements that are visible at the time of callback.
2. Boolean indicating whether the direction is forward (`true`) or backward (`false`);
3. Object containing information that differs depending on what triggered the advance. If triggered by clicking one of the `btnGo` elements, for example, the object has two properties: `btnGo`, which references the clicked DOM element, and `btnGoIndex`, presenting the index of the clicked DOM element in relation to the other "btnGo" buttons.

```javascript
$('div.carousel').jCarouselLite({
Expand Down

0 comments on commit 044b073

Please sign in to comment.