Last active
August 29, 2015 14:05
-
-
Save megazalrock/acf2e8e2fff8b8e54ff9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//ダメな実装 | |
$('#gnav li') | |
.each(function(){ | |
$(this) | |
.hover(function(){ | |
}, function(){ | |
$('body') | |
.on('mousemove', function(){ | |
//このmousemoveはmouseleaveする度にバインドされて、一度に複数回実行されることになる | |
}); | |
}); | |
}); | |
//ダメじゃない実装 | |
var isMouseOver = false; | |
$('#gnav li') | |
.each(function(){ | |
$(this) | |
.hover(function(){ | |
isMouseOver = true; | |
}, function(){ | |
isMouseOver = false; | |
}); | |
}); | |
$('body') | |
.on('mousemove', function(){ | |
if(!isMouseOver){ | |
//mouseOver時でないとき | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment