aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.accordion.js
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2011-07-20 06:30:51 -0700
committerScott González <scott.gonzalez@gmail.com>2011-07-20 06:30:51 -0700
commite2a9b0c5685852e3de50c31f0d842de2e5186292 (patch)
tree9655557cbbbbb5b6b2b84bdaededea39a0c4b3c3 /ui/jquery.ui.accordion.js
parent8224c675e19bf5cb9ed0b00159dc572715ad7727 (diff)
parent5f02a8ff1fb7947c40003208886214203b834ce1 (diff)
downloadjquery-ui-e2a9b0c5685852e3de50c31f0d842de2e5186292.tar.gz
jquery-ui-e2a9b0c5685852e3de50c31f0d842de2e5186292.zip
Merge pull request #368 from kborchers/bug_3532_2
Accordion: Stop current hide animation, jump to last animation and calculate percentages for padding in addition to height. Fixes #3532 - Accordion: Activating a panel during animation fails
Diffstat (limited to 'ui/jquery.ui.accordion.js')
-rw-r--r--ui/jquery.ui.accordion.js24
1 files changed, 13 insertions, 11 deletions
diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js
index acd19c981..4a3f29a61 100644
--- a/ui/jquery.ui.accordion.js
+++ b/ui/jquery.ui.accordion.js
@@ -12,6 +12,8 @@
* jquery.ui.widget.js
*/
(function( $, undefined ) {
+
+var lastToggle = {};
// TODO: use ui-accordion-header-active class and fix styling
$.widget( "ui.accordion", {
@@ -37,8 +39,6 @@ $.widget( "ui.accordion", {
var self = this,
options = self.options;
- self.running = false;
-
self.element.addClass( "ui-accordion ui-widget ui-helper-reset" );
self.headers = self.element.find( options.header )
@@ -321,8 +321,6 @@ $.widget( "ui.accordion", {
event.preventDefault();
if ( options.disabled ||
- // can't switch during an animation
- this.running ||
// click on active header, but not collapsible
( clickedIsActive && !options.collapsible ) ||
// allow canceling activation
@@ -363,7 +361,6 @@ $.widget( "ui.accordion", {
toShow = data.newContent,
toHide = data.oldContent;
- self.running = true;
function complete() {
self._completed( data );
}
@@ -384,6 +381,8 @@ $.widget( "ui.accordion", {
animations[ animation ]({
toShow: toShow,
toHide: toHide,
+ prevShow: lastToggle.toShow,
+ prevHide: lastToggle.toHide,
complete: complete,
down: toShow.length && ( !toHide.length || ( toShow.index() < toHide.index() ) )
}, additional );
@@ -414,8 +413,6 @@ $.widget( "ui.accordion", {
var toShow = data.newContent,
toHide = data.oldContent;
- this.running = false;
-
if ( this.options.heightStyle === "content" ) {
toShow.add( toHide ).css({
height: "",
@@ -437,6 +434,11 @@ $.widget( "ui.accordion", {
$.extend( $.ui.accordion, {
animations: {
slide: function( options, additions ) {
+ if ( options.prevShow || options.prevHide ) {
+ options.prevHide.stop( true, true );
+ options.toHide = options.prevShow;
+ }
+
var showOverflow = options.toShow.css( "overflow" ),
hideOverflow = options.toHide.css( "overflow" ),
percentDone = 0,
@@ -448,6 +450,9 @@ $.extend( $.ui.accordion, {
easing: "swing",
duration: 300
}, options, additions );
+
+ lastToggle = options;
+
if ( !options.toHide.size() ) {
originalWidth = options.toShow[0].style.width;
options.toShow
@@ -504,10 +509,7 @@ $.extend( $.ui.accordion, {
.filter( ":visible" )
.animate( hideProps, {
step: function( now, settings ) {
- // only calculate the percent when animating height
- // IE gets very inconsistent results when animating elements
- // with small values, which is common for padding
- if ( settings.prop == "height" ) {
+ if ( settings.prop == "height" || settings.prop == "paddingTop" || settings.prop == "paddingBottom" ) {
percentDone = ( settings.end - settings.start === 0 ) ? 0 :
( settings.now - settings.start ) / ( settings.end - settings.start );
}