jquery - Slide in on Hover, Slide out on Leave -
i have contact form slide out when mouse hovers on button, , make form stay long mouse hovering on .hoverclass (the button , form itself). however, i've accomplished in making weird stuff instead.
<div id="contact-wrapper"> <div class="floating-contact-inner hoverclass" id="floating-contact-wrap"> <div id="contact-btn" class="hoverclass"> </div> <div id="result"></div> <form action="#" method="post" id="floating-contact" > <!-- lalala --> </form> </div> </div> var jq = jquery.noconflict(); var floatbox = jq("#floating-contact-wrap"); jq('.hoverclass').hover( function(e){ if (!jq(floatbox).hasclass('visiable')){ floatbox.animate({"right":"-294px"}, "slow").addclass('visiable'); } }, function(e){ floatbox.animate({"right":"0px"}, "slow").removeclass('visiable'); } ); thanks having look!
demo - if hover event makes element visible, switching order of callbacks produce you're looking for,hover(in, out). using jquery stop() function prevents animation stutter.
floatbox.hover( function(e){ floatbox.stop(true).animate({"right":"0px"}, "slow"); }, function(e){ floatbox.animate({"right":"-294px"}, "slow"); } ); this eliminates need adding , removing classes , relies on hover determine it's state
Comments
Post a Comment