]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
fixes dropdown hover/click state issue
authorzurbchris <chris@zurb.com>
Sat, 21 Nov 2015 00:35:33 +0000 (16:35 -0800)
committerzurbchris <chris@zurb.com>
Sat, 21 Nov 2015 00:35:33 +0000 (16:35 -0800)
js/foundation.dropdown.js

index 947b7a6f14a7a9151e923f4d8e714cca74db6311..9426c6e084610f046c9a10c5e1947579070e7555 100644 (file)
     });
 
     if(this.options.hover){
-      clearTimeout(_this.timeout);
-      this.$anchor.on('mouseenter.zf.dropdown mouseleave.zf.dropdown', function(){
-        _this.timeOut = setTimeout(function(){
-          _this.toggle();
-        }, _this.options.hoverDelay);
-      });
+      this.$anchor.off('mouseenter.zf.dropdown mouseleave.zf.dropdown')
+          .on('mouseenter.zf.dropdown', function(){
+            console.log('hover');
+            clearTimeout(_this.timeout);
+            _this.timeOut = setTimeout(function(){
+              _this.open();
+              _this.$anchor.data('hover', true);
+            }, _this.options.hoverDelay);
+          }).on('mouseleave.zf.dropdown', function(){
+            clearTimeout(_this.timeout);
+            _this.timeOut = setTimeout(function(){
+              _this.close();
+              _this.$anchor.data('hover', false);
+            }, _this.options.hoverDelay);
+          });
     }
     this.$anchor.add(this.$element).on('keydown.zf.dropdown', function(e) {
 
    */
   Dropdown.prototype.toggle = function(){
     if(this.$element.hasClass('is-open')){
+      if(this.$anchor.data('hover')) return;
       this.close();
     }else{
       this.open();