From d0337c85eb911cf76fd4d977618d3bb1ef32688b Mon Sep 17 00:00:00 2001 From: Tvrtko Date: Sun, 6 Dec 2015 01:00:57 +0100 Subject: [PATCH 1/3] ref #7413 - use timeout to prevent repeated animation on fast toggling --- js/foundation.accordionMenu.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/js/foundation.accordionMenu.js b/js/foundation.accordionMenu.js index 81e279bc16..bc98969c51 100644 --- a/js/foundation.accordionMenu.js +++ b/js/foundation.accordionMenu.js @@ -187,11 +187,20 @@ * @param {jQuery} $target - the submenu to toggle */ AccordionMenu.prototype.toggle = function($target){ + var _this = this; + var setHideTimeout = function() { + $target.data('toggleTimeout', setTimeout(function () { + _this.down($target); + }, 200)); + }; if (!$target.is(':hidden')) { + clearTimeout($target.data('toggleTimeout')); this.up($target); } else { - this.down($target); + if (typeof $target.data('toggleTimeout') !== 'undefined') + clearTimeout($target.data('toggleTimeout')); + setHideTimeout(); } }; /** From a5ee97386c6558a6c36d6c23932bd921daf5dad5 Mon Sep 17 00:00:00 2001 From: Tvrtko Date: Sun, 6 Dec 2015 01:39:11 +0100 Subject: [PATCH 2/3] fixes #7413 - check if target is animating then run animation for toggle --- js/foundation.accordionMenu.js | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/js/foundation.accordionMenu.js b/js/foundation.accordionMenu.js index bc98969c51..ef366c6865 100644 --- a/js/foundation.accordionMenu.js +++ b/js/foundation.accordionMenu.js @@ -188,19 +188,11 @@ */ AccordionMenu.prototype.toggle = function($target){ var _this = this; - var setHideTimeout = function() { - $target.data('toggleTimeout', setTimeout(function () { - _this.down($target); - }, 200)); - }; - if (!$target.is(':hidden')) { - clearTimeout($target.data('toggleTimeout')); - this.up($target); + if (!$target.is(':hidden') && !$target.is(':animated')) { + _this.up($target); } - else { - if (typeof $target.data('toggleTimeout') !== 'undefined') - clearTimeout($target.data('toggleTimeout')); - setHideTimeout(); + else if(!$target.is(':animated')) { + _this.down($target); } }; /** From 822dceab4bb92ddfedacb34020e4ff30acd84366 Mon Sep 17 00:00:00 2001 From: Tvrtko Date: Mon, 7 Dec 2015 23:18:10 +0100 Subject: [PATCH 3/3] #7413 - refactor toggle --- js/foundation.accordionMenu.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/js/foundation.accordionMenu.js b/js/foundation.accordionMenu.js index ef366c6865..bea5eb4c0d 100644 --- a/js/foundation.accordionMenu.js +++ b/js/foundation.accordionMenu.js @@ -187,12 +187,13 @@ * @param {jQuery} $target - the submenu to toggle */ AccordionMenu.prototype.toggle = function($target){ - var _this = this; - if (!$target.is(':hidden') && !$target.is(':animated')) { - _this.up($target); - } - else if(!$target.is(':animated')) { - _this.down($target); + if(!$target.is(':animated')) { + if (!$target.is(':hidden')) { + this.up($target); + } + else { + this.down($target); + } } }; /**