From ed0a147fc0f9934a4a4b74ae05e1ad2adbdf2ae9 Mon Sep 17 00:00:00 2001 From: zurbchris Date: Fri, 20 Nov 2015 16:35:33 -0800 Subject: [PATCH] fixes dropdown hover/click state issue --- js/foundation.dropdown.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/js/foundation.dropdown.js b/js/foundation.dropdown.js index 947b7a6f1..9426c6e08 100644 --- a/js/foundation.dropdown.js +++ b/js/foundation.dropdown.js @@ -190,12 +190,21 @@ }); 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) { @@ -300,6 +309,7 @@ */ Dropdown.prototype.toggle = function(){ if(this.$element.hasClass('is-open')){ + if(this.$anchor.data('hover')) return; this.close(); }else{ this.open(); -- 2.47.2