From 6961e4118bacb10bb40e4a03fb5c08f2333a008d Mon Sep 17 00:00:00 2001 From: jlukic Date: Thu, 23 Apr 2015 18:06:02 -0400 Subject: [PATCH] Fixed animation reset issue with accordion and hideOthers --- src/definitions/modules/accordion.js | 105 ++++++++++++++------------- 1 file changed, 56 insertions(+), 49 deletions(-) diff --git a/src/definitions/modules/accordion.js b/src/definitions/modules/accordion.js index fe2cf4856..d10386342 100644 --- a/src/definitions/modules/accordion.js +++ b/src/definitions/modules/accordion.js @@ -153,55 +153,59 @@ $.fn.accordion = function(parameters) { $activeContent = $activeTitle.next($content), isAnimating = $activeContent.hasClass(className.animating), isActive = $activeContent.hasClass(className.active), - isUnopen = (!isActive && !isAnimating) + isOpen = (isActive || isAnimating) ; - if(isUnopen) { - module.debug('Opening accordion content', $activeTitle); - settings.onOpening.call($activeContent); - if(settings.exclusive) { - module.closeOthers.call($activeTitle); + if(isOpen) { + module.debug('Accordion already open, skipping', $activeContent); + return; + } + module.debug('Opening accordion content', $activeTitle); + settings.onOpening.call($activeContent); + if(settings.exclusive) { + module.closeOthers.call($activeTitle); + } + $activeTitle + .addClass(className.active) + ; + $activeContent + .stop(true, true) + .addClass(className.animating) + ; + if(settings.animateChildren) { + if($.fn.transition !== undefined && $module.transition('is supported')) { + $activeContent + .children() + .transition({ + animation : 'fade in', + queue : false, + useFailSafe : true, + debug : settings.debug, + verbose : settings.verbose, + duration : settings.duration + }) + ; } - $activeTitle - .addClass(className.active) - ; - $activeContent.addClass(className.animating); - if(settings.animateChildren) { - if($.fn.transition !== undefined && $module.transition('is supported')) { - $activeContent - .children() - .transition({ - animation : 'fade in', - queue : false, - useFailSafe : true, - debug : settings.debug, - verbose : settings.verbose, - duration : settings.duration - }) - ; - } - else { - $activeContent - .children() - .stop(true) - .animate({ - opacity: 1 - }, settings.duration, module.resetOpacity) - ; - } + else { + $activeContent + .children() + .stop(true, true) + .animate({ + opacity: 1 + }, settings.duration, module.resetOpacity) + ; } - $activeContent - .stop(true) - .slideDown(settings.duration, settings.easing, function() { - $activeContent - .removeClass(className.animating) - .addClass(className.active) - ; - module.reset.display.call(this); - settings.onOpen.call(this); - settings.onChange.call(this); - }) - ; } + $activeContent + .slideDown(settings.duration, settings.easing, function() { + $activeContent + .removeClass(className.animating) + .addClass(className.active) + ; + module.reset.display.call(this); + settings.onOpen.call(this); + settings.onChange.call(this); + }) + ; }, close: function(query) { @@ -224,6 +228,7 @@ $.fn.accordion = function(parameters) { .removeClass(className.active) ; $activeContent + .stop(true, true) .addClass(className.animating) ; if(settings.animateChildren) { @@ -243,7 +248,7 @@ $.fn.accordion = function(parameters) { else { $activeContent .children() - .stop(true) + .stop(true, true) .animate({ opacity: 0 }, settings.duration, module.resetOpacity) @@ -251,7 +256,6 @@ $.fn.accordion = function(parameters) { } } $activeContent - .stop(true) .slideUp(settings.duration, settings.easing, function() { $activeContent .removeClass(className.animating) @@ -293,6 +297,10 @@ $.fn.accordion = function(parameters) { $openTitles .removeClass(className.active) ; + $openContents + .removeClass(className.animating) + .stop(true, true) + ; if(settings.animateChildren) { if($.fn.transition !== undefined && $module.transition('is supported')) { $openContents @@ -309,7 +317,7 @@ $.fn.accordion = function(parameters) { else { $openContents .children() - .stop() + .stop(true, true) .animate({ opacity: 0 }, settings.duration, module.resetOpacity) @@ -317,7 +325,6 @@ $.fn.accordion = function(parameters) { } } $openContents - .stop() .slideUp(settings.duration , settings.easing, function() { $(this).removeClass(className.active); module.reset.display.call(this);