]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
ref #7413 - use timeout to prevent repeated animation on fast toggling
authorTvrtko <tvrtkom@gmail.com>
Sun, 6 Dec 2015 00:00:57 +0000 (01:00 +0100)
committerTvrtko <tvrtkom@gmail.com>
Sun, 6 Dec 2015 00:00:57 +0000 (01:00 +0100)
js/foundation.accordionMenu.js

index 81e279bc162efaf3332ae29ce48402ad0439329a..bc98969c51651c0eb1471845979ec509602acdf7 100644 (file)
    * @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();
     }
   };
   /**