Skip to main content
The 2024 Developer Survey results are live! See the results
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

I was thrilled when I first came across the .animate function of jQuery. But if I e.g. change the color of a box with this function on .mouseover, it will (of course) complete the animation, although the mouse has already left the box and another animation that reverses the color was called on .mouseleave.

This leads e.g. to flapping if you hover over the box multiple times with your mouse and the animation is repeated 20 times or something.

To stop an animation / to reverse the color change if the mouse is not longer on the box you can use e.g. this combination of functions of this question that has already been asked: jQuery - Animation transition interrupted by hoverjQuery - Animation transition interrupted by hover

Here is the example code for this question for a similar animation: http://jsfiddle.net/B9wx8/30/

$('.box1,.box2').mouseenter(function () {
    $('.box2').stop().animate({
        top: 0
    }, 'slow');
}).mouseleave(function () {
    $('.box2').stop().animate({
        top: '-200px'
    }, 'slow');
});

This seems not very elegant and complicated. Is there some jQuery function that is pretty much like .animate, but reverses the animation after e.g. the mouse is not longer in the box?

Something like:

$('.myClass').animate_and_reverse_animation_if_hover_ends( {...} , 500 );

I was thrilled when I first came across the .animate function of jQuery. But if I e.g. change the color of a box with this function on .mouseover, it will (of course) complete the animation, although the mouse has already left the box and another animation that reverses the color was called on .mouseleave.

This leads e.g. to flapping if you hover over the box multiple times with your mouse and the animation is repeated 20 times or something.

To stop an animation / to reverse the color change if the mouse is not longer on the box you can use e.g. this combination of functions of this question that has already been asked: jQuery - Animation transition interrupted by hover

Here is the example code for this question for a similar animation: http://jsfiddle.net/B9wx8/30/

$('.box1,.box2').mouseenter(function () {
    $('.box2').stop().animate({
        top: 0
    }, 'slow');
}).mouseleave(function () {
    $('.box2').stop().animate({
        top: '-200px'
    }, 'slow');
});

This seems not very elegant and complicated. Is there some jQuery function that is pretty much like .animate, but reverses the animation after e.g. the mouse is not longer in the box?

Something like:

$('.myClass').animate_and_reverse_animation_if_hover_ends( {...} , 500 );

I was thrilled when I first came across the .animate function of jQuery. But if I e.g. change the color of a box with this function on .mouseover, it will (of course) complete the animation, although the mouse has already left the box and another animation that reverses the color was called on .mouseleave.

This leads e.g. to flapping if you hover over the box multiple times with your mouse and the animation is repeated 20 times or something.

To stop an animation / to reverse the color change if the mouse is not longer on the box you can use e.g. this combination of functions of this question that has already been asked: jQuery - Animation transition interrupted by hover

Here is the example code for this question for a similar animation: http://jsfiddle.net/B9wx8/30/

$('.box1,.box2').mouseenter(function () {
    $('.box2').stop().animate({
        top: 0
    }, 'slow');
}).mouseleave(function () {
    $('.box2').stop().animate({
        top: '-200px'
    }, 'slow');
});

This seems not very elegant and complicated. Is there some jQuery function that is pretty much like .animate, but reverses the animation after e.g. the mouse is not longer in the box?

Something like:

$('.myClass').animate_and_reverse_animation_if_hover_ends( {...} , 500 );
added 1 character in body
Source Link
marc_s
  • 748k
  • 180
  • 1.4k
  • 1.5k

I was thrilled when I first came across the .animate function of jQuryjQuery. But if I e.g. change the color of a box with this function on .mouseover, it will (of course) complete the animation, although the mouse has already left the box and another animation that reverses the color was called on .mouseleave.

This leads e.g. to flapping if you hover over the box multiple times with your mouse and the animation is repeated 20 times or something.

To stop an animation / to reverse the color change if the mouse is not longer on the box you can use e.g. this combination of functions of this question that has already been asked: jQuery - Animation transition interrupted by hover

Here is the example code for this question for a similar animation: http://jsfiddle.net/B9wx8/30/

$('.box1,.box2').mouseenter(function () {
    $('.box2').stop().animate({
        top: 0
    }, 'slow');
}).mouseleave(function () {
    $('.box2').stop().animate({
        top: '-200px'
    }, 'slow');
});

This seems not very elegant and complicated. Is there some jQuery function that is pretty much like .animate, but reverses the animation after e.g. the mouse is not longer in the box?

Something like:

$('.myClass').animate_and_reverse_animation_if_hover_ends( {...} , 500 );

I was thrilled when I first came across the .animate function of jQury. But if I e.g. change the color of a box with this function on .mouseover, it will (of course) complete the animation, although the mouse has already left the box and another animation that reverses the color was called on .mouseleave.

This leads e.g. to flapping if you hover over the box multiple times with your mouse and the animation is repeated 20 times or something.

To stop an animation / to reverse the color change if the mouse is not longer on the box you can use e.g. this combination of functions of this question that has already been asked: jQuery - Animation transition interrupted by hover

Here is the example code for this question for a similar animation: http://jsfiddle.net/B9wx8/30/

$('.box1,.box2').mouseenter(function () {
    $('.box2').stop().animate({
        top: 0
    }, 'slow');
}).mouseleave(function () {
    $('.box2').stop().animate({
        top: '-200px'
    }, 'slow');
});

This seems not very elegant and complicated. Is there some jQuery function that is pretty much like .animate, but reverses the animation after e.g. the mouse is not longer in the box?

Something like:

$('.myClass').animate_and_reverse_animation_if_hover_ends( {...} , 500 );

I was thrilled when I first came across the .animate function of jQuery. But if I e.g. change the color of a box with this function on .mouseover, it will (of course) complete the animation, although the mouse has already left the box and another animation that reverses the color was called on .mouseleave.

This leads e.g. to flapping if you hover over the box multiple times with your mouse and the animation is repeated 20 times or something.

To stop an animation / to reverse the color change if the mouse is not longer on the box you can use e.g. this combination of functions of this question that has already been asked: jQuery - Animation transition interrupted by hover

Here is the example code for this question for a similar animation: http://jsfiddle.net/B9wx8/30/

$('.box1,.box2').mouseenter(function () {
    $('.box2').stop().animate({
        top: 0
    }, 'slow');
}).mouseleave(function () {
    $('.box2').stop().animate({
        top: '-200px'
    }, 'slow');
});

This seems not very elegant and complicated. Is there some jQuery function that is pretty much like .animate, but reverses the animation after e.g. the mouse is not longer in the box?

Something like:

$('.myClass').animate_and_reverse_animation_if_hover_ends( {...} , 500 );
added 19 characters in body
Source Link

I was thrilled when I first came across the .animate function of jQury. But if I e.g. change the color of a box with this function on .mouseover, it will (of course) complete the animation, although the mouse has already left the box and another animation that reverses the color was called on .mouseleave.

This leads e.g. to flapping if you hover over the box multiple times with your mouse and the animation is repeated 20 times or something.

To stop an animation / to reverse the color change if the mouse is not longer on the box you can use e.g. this combination of functions of this question that has already been asked: jQuery - Animation transition interrupted by hover

Here is the example code for this question for a similar animation: http://jsfiddle.net/B9wx8/30/

$('.box1,.box2').mouseenter(function () {
    $('.box2').stop().animate({
        top: 0
    }, 'slow');
}).mouseleave(function () {
    $('.box2').stop().animate({
        top: '-200px'
    }, 'slow');
});

This seems not very elegant and complicated. Is there some jQuery function that is pretty much like .animate, but reverses the animation after e.g. the mouse is not longer in the box?

Something like:

$('.myClass').animate_and_reverse_animation_if_hover_ends( {...} , 500 );

I was thrilled when I first came across the .animate function of jQury. But if I e.g. change the color of a box with this function on .mouseover, it will (of course) complete the animation, although the mouse has already left the box and another animation that reverses the color was called on .mouseleave.

This leads e.g. to flapping if you hover over the box multiple times with your mouse and the animation is repeated 20 times or something.

To stop an animation / to reverse the color change if the mouse is not longer on the box you can use e.g. this combination of functions of this question that has already been asked: jQuery - Animation transition interrupted by hover

Here is the example code: http://jsfiddle.net/B9wx8/30/

$('.box1,.box2').mouseenter(function () {
    $('.box2').stop().animate({
        top: 0
    }, 'slow');
}).mouseleave(function () {
    $('.box2').stop().animate({
        top: '-200px'
    }, 'slow');
});

This seems not very elegant and complicated. Is there some jQuery function that is pretty much like .animate, but reverses the animation after e.g. the mouse is not longer in the box?

Something like:

$('.myClass').animate_and_reverse_animation_if_hover_ends( {...} , 500 );

I was thrilled when I first came across the .animate function of jQury. But if I e.g. change the color of a box with this function on .mouseover, it will (of course) complete the animation, although the mouse has already left the box and another animation that reverses the color was called on .mouseleave.

This leads e.g. to flapping if you hover over the box multiple times with your mouse and the animation is repeated 20 times or something.

To stop an animation / to reverse the color change if the mouse is not longer on the box you can use e.g. this combination of functions of this question that has already been asked: jQuery - Animation transition interrupted by hover

Here is the example code for this question for a similar animation: http://jsfiddle.net/B9wx8/30/

$('.box1,.box2').mouseenter(function () {
    $('.box2').stop().animate({
        top: 0
    }, 'slow');
}).mouseleave(function () {
    $('.box2').stop().animate({
        top: '-200px'
    }, 'slow');
});

This seems not very elegant and complicated. Is there some jQuery function that is pretty much like .animate, but reverses the animation after e.g. the mouse is not longer in the box?

Something like:

$('.myClass').animate_and_reverse_animation_if_hover_ends( {...} , 500 );
Source Link
Loading