JQuery: stop repeating animation with multiple rollovers?

I'm having trouble stopping the animation ... if I scroll through the link to open the window 5 times and come off. The "Show" effect occurs 5 times ... since I am torn from it I only want it to show once ....

Basically, it seems to be stuck in a loop ....

Any ideas on how to stop multiple instances?

jQuery(document).ready(function(){
    jQuery('.ttip').hover(
        function() {
            var offset = jQuery(this).offset();
            console.log(offset)
            var width = jQuery(this).outerWidth();
            var tooltipId = jQuery(this).attr("rel");
            jQuery('#tooltip-container').empty().load('tooltips.html' + tooltipId).fadeIn(500);
            jQuery('#tooltip-container').css({top:offset.top, left:offset.left + width + 10}).show();
        },
        function() {
          jQuery('#tooltip-container').fadeOut(500);
        });
});
+2
source share
2 answers

You must use stop(true).

See http://api.jquery.com/stop

+6
source

As Stefan says, to make the animation jump to the end with a stop (true), like this example, using your code:

jQuery(document).ready(function(){
jQuery('.ttip').hover(
    function() {
        var offset = jQuery(this).offset();
        console.log(offset)
        var width = jQuery(this).outerWidth();
        var tooltipId = jQuery(this).attr("rel");
        jQuery('#tooltip-container').empty().load('tooltips.html' + tooltipId).stop(true).fadeIn(500);
        jQuery('#tooltip-container').css({top:offset.top, left:offset.left + width + 10}).show();
    },
    function() {
      jQuery('#tooltip-container').stop(true).fadeOut(500);
    });
});
+1

All Articles