Skip to content

Commit

Permalink
Allow all options for animation jQuery.animate() accepts (removes the…
Browse files Browse the repository at this point in the history
… easing option)
  • Loading branch information
jsor committed Apr 7, 2011
1 parent 67a8907 commit e14b018
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
10 changes: 2 additions & 8 deletions README.markdown
Expand Up @@ -135,15 +135,9 @@ jCarousel accepts a list of options to control the behaviour of the carousel. He
</tr>
<tr>
<td>animation</td>
<td>mixed</td>
<td>integer|string|object</td>
<td>&quot;normal&quot;</td>
<td>The speed of the scroll animation as string in jQuery terms (<code>"slow"</code> or <code>"fast"</code>) or milliseconds as integer (See the <a href="http://api.jquery.com/animate">jQuery Documentation</a>). If set to 0, animation is turned off.</td>
</tr>
<tr>
<td>easing</td>
<td>string</td>
<td>&quot;swing&quot;</td>
<td>The name of the easing effect that you want to use (See the <a href="http://api.jquery.com/animate#easing">jQuery Documentation</a>).</td>
<td>The speed of the scroll animation as string in jQuery terms (<code>"slow"</code> or <code>"fast"</code>) or milliseconds as integer (See the <a href="http://api.jquery.com/animate">jQuery Documentation</a>). If set to 0, animation is turned off. Alternatively, this can be a map of options like the one [jQuery.animate](http://api.jquery.com/animate/#animate-properties-options) accepts as second argument.</td>
</tr>
<tr>
<td>wrap</td>
Expand Down
15 changes: 11 additions & 4 deletions src/jquery.jcarousel.js
Expand Up @@ -339,10 +339,18 @@
this.list.css(properties);
this.onAnimationComplete(callback);
} else {
var self = this;
this.list.animate(properties, this.options.animation, this.options.easing, function() {
var self = this,
opts = typeof this.options.animation === 'object' ? this.options.animation : {duration: this.options.animation},
oldcomplete = opts.complete;

opts.complete = function() {
if ($.isFunction(oldcomplete)) {
oldcomplete.call(this);
}
self.onAnimationComplete(callback);
});
};

this.list.animate(properties, opts);
}

return this;
Expand Down Expand Up @@ -509,7 +517,6 @@
start: 0,
scroll: 1,
animation: 'normal',
easing: 'swing',
wrap: null
},
itemData: ['first', 'last', 'visible'],
Expand Down
7 changes: 5 additions & 2 deletions test/functional/animation.html
Expand Up @@ -36,8 +36,11 @@
animation: 'fast'
});
$('#jcarousel2').jcarousel({
animation: 1000,
easing: 'BounceEaseOut'
animation: {
duration: 1000,
easing: 'BounceEaseOut'
},
wrap: 'circular'
});
});

Expand Down

0 comments on commit e14b018

Please sign in to comment.