Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript 2 images activate the same animation, how would you ensure that the animation happens only once? Re: 2 images activate the same animation, how would you ensure that the animation happens only once?

#137751
leongaban
Member

Found the answer!
http://stackoverflow.com/questions/16943491/jquery-hover-how-to-activate-fade-animation-once-with-hover-activated-via-2-ov

Updated code:
$(‘.home-content .iphone’).click(function() {
window.location = home.itunesLink + this.id;
}).hoverIntent(phoneToggleFade);

$(‘.home-content .tryme’).click(function() {
window.location = home.itunesLink + this.id;
}).hoverIntent(tryToggleFade);

function phoneToggleFade(){$(‘.home-content .tryme’).find(“img:last”).fadeToggle().stop}
function tryToggleFade(){$(this).find(“img:last”).fadeToggle().stop}

Also now that I’m looking at this again, I think I could just create an invisible div over BOTH graphics and just put the hover / animation code on that. Eliminating the need for another plugin.