From 30f53316a0709a058bf145ea583babecd8402a43 Mon Sep 17 00:00:00 2001 From: Nate Wiebe Date: Wed, 30 Dec 2015 15:33:56 -0500 Subject: [PATCH] Trigger events after animation is complete --- js/foundation.accordion.js | 27 ++++++++++++++------------- js/foundation.accordionMenu.js | 27 ++++++++++++++------------- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/js/foundation.accordion.js b/js/foundation.accordion.js index 59a8651a4..9c1ee8333 100644 --- a/js/foundation.accordion.js +++ b/js/foundation.accordion.js @@ -162,7 +162,13 @@ .parent().addClass('is-active'); // Foundation.Move(_this.options.slideSpeed, $target, function(){ - $target.slideDown(_this.options.slideSpeed); + $target.slideDown(_this.options.slideSpeed, function () { + /** + * Fires when the tab is done opening. + * @event Accordion#down + */ + _this.$element.trigger('down.zf.accordion', [$target]); + }); // }); // if(!firstTime){ @@ -172,11 +178,6 @@ 'aria-expanded': true, 'aria-selected': true }); - /** - * Fires when the tab is done opening. - * @event Accordion#down - */ - this.$element.trigger('down.zf.accordion', [$target]); }; /** @@ -195,7 +196,13 @@ } // Foundation.Move(this.options.slideSpeed, $target, function(){ - $target.slideUp(_this.options.slideSpeed); + $target.slideUp(_this.options.slideSpeed, function () { + /** + * Fires when the tab is done collapsing up. + * @event Accordion#up + */ + _this.$element.trigger('up.zf.accordion', [$target]); + }); // }); $target.attr('aria-hidden', true) @@ -205,12 +212,6 @@ 'aria-expanded': false, 'aria-selected': false }); - - /** - * Fires when the tab is done collapsing up. - * @event Accordion#up - */ - this.$element.trigger('up.zf.accordion', [$target]); }; /** diff --git a/js/foundation.accordionMenu.js b/js/foundation.accordionMenu.js index d698a9d8c..70a6b9acc 100644 --- a/js/foundation.accordionMenu.js +++ b/js/foundation.accordionMenu.js @@ -212,13 +212,14 @@ .parent('.has-submenu').attr({'aria-expanded': true, 'aria-selected': true}); Foundation.Move(this.options.slideSpeed, $target, function(){ - $target.slideDown(_this.options.slideSpeed); + $target.slideDown(_this.options.slideSpeed, function () { + /** + * Fires when the menu is done opening. + * @event AccordionMenu#down + */ + _this.$element.trigger('down.zf.accordionMenu', [$target]); + }); }); - /** - * Fires when the menu is done collapsing up. - * @event AccordionMenu#down - */ - this.$element.trigger('down.zf.accordionMenu', [$target]); }; /** @@ -229,7 +230,13 @@ AccordionMenu.prototype.up = function($target) { var _this = this; Foundation.Move(this.options.slideSpeed, $target, function(){ - $target.slideUp(_this.options.slideSpeed); + $target.slideUp(_this.options.slideSpeed, function () { + /** + * Fires when the menu is done collapsing up. + * @event AccordionMenu#up + */ + _this.$element.trigger('up.zf.accordionMenu', [$target]); + }); }); $target.attr('aria-hidden', true) .find('[data-submenu]').slideUp(0).attr('aria-hidden', true).end() @@ -238,12 +245,6 @@ // $target.slideUp(this.options.slideSpeed, function() { // $target.find('[data-submenu]').slideUp(0).attr('aria-hidden', true); // }).attr('aria-hidden', true).parent('.has-submenu').attr({'aria-expanded': false, 'aria-selected': false}); - - /** - * Fires when the menu is done collapsing up. - * @event AccordionMenu#up - */ - this.$element.trigger('up.zf.accordionMenu', [$target]); }; /** -- 2.47.2