The specific functionality that you asked for is outlined below. I tried to drive what I thought you were trying to accomplish so it may not be exactly what you wanted but I think it is close. There seemed to be a clash of the .toggleClass()
instantaneous behavior and the CSS code timing so I put it in a JavaScript setTimeout()
method to avoid the issue.
You can un-comment the //$menuImg.toggleClass('start');
to observe the behavior when the start
class is removed.
var $menuShell = $('div#features > div'), $menuImg = $menuShell.find('img'), $featOverDiv = $menuShell.find('div.feat-overlay'), $sisterDivs = $menuShell.siblings();
var yesAnimate, noAnimate;
function startTimer() {
yesAnimate = setTimeout(function() {
//$menuImg.toggleClass('start');
$featOverDiv.toggleClass('start');
}, 600);
}
function leaveTimer() {
noAnimate = setTimeout(function() {
//$menuImg.toggleClass('start');
$featOverDiv.toggleClass('start');
}, 0);
}
$menuShell.not($sisterDivs).on('mouseenter', function() {
startTimer();
$menuImg.toggleClass('start-hover');
$featOverDiv.toggleClass('start-hover');
});
$menuShell.not($sisterDivs).on('mouseleave', function() {
leaveTimer();
$menuImg.toggleClass('start-hover');
$featOverDiv.toggleClass('start-hover');
});
Fiddle Example