Mike Boutin
Mike Boutin

Reputation: 5347

Create a jquery fixed animation without some overlapping animation

I have this animation http://codepen.io/DWboutin/pen/DFJze

When i go fast over these tabs, the animations makes really weirds things.

How can i stop that? I tried .stop(true,true), i tried to create queue but i can make this cleaner.

This function is triggered when mouseenter

var becomeBigger = function(element){
    deplace(element.index(),function(){
        element.dequeue();
        element.queue(function(){
            $(this).animate({top: '118px', height: '435px',width: '248px'},settings.timeAnimIn,settings.easingIn,function(){
                $(this).addClass('active');
                deplace(element.index());
            });
            $(this).children('.img').children('.noiretblanc').animate({'opacity':0},settings.timeAnimIn,settings.easingIn);
            $(this).children('.img').children('.couleur').animate({opacity: 1, top: '-321px'},settings.timeAnimIn,settings.easingIn);
            $(this).children('.img').animate({height: '321px'},settings.timeAnimIn,settings.easingIn);
            $(this).children('.titre').animate({height: '57px', width: '228px', backgroundColor: '#4696a7'},settings.timeAnimIn,settings.easingIn);
            $(this).children('.titre').children('h2').animate({fontSize : '22px'},settings.timeAnimIn,settings.easingIn);
            $(this).children('.titre').children('h3').animate({fontSize : '18px'},settings.timeAnimIn,settings.easingIn);
            $(this).children('.btn-verso').css({backgroundPosition : '0 0'});
            $(this).dequeue();
        });
    });

}

And this one on mouseleave

var recoverSize = function(element){
    replace(element.index(),function(){
        element.queue(function(){
            $(this).removeClass('active');
            $(this).animate({top: '148px',height: '385px',width: '214px'},settings.timeAnimOut,settings.easingOut);
            $(this).children('.img').children('.noiretblanc').animate({'opacity':1},settings.timeAnimOut,settings.easingOut);
            $(this).children('.img').children('.couleur').animate({opacity: 0, top: '-277px'},settings.timeAnimOut,settings.easingOut);
            $(this).children('.img').animate({height: '277px'},settings.timeAnimOut,settings.easingOut);
            $(this).children('.titre').animate({height: '50px', width: '194px', backgroundColor: '#959595'},settings.timeAnimOut,settings.easingOut);
            $(this).children('.titre').children('h2').animate({fontSize : '20px'},settings.timeAnimOut,settings.easingOut);
            $(this).children('.titre').children('h3').animate({fontSize : '16px'},settings.timeAnimOut,settings.easingOut);
            $(this).children('.btn-verso').css({backgroundPosition : '0 -72px'});
            $(this).dequeue();
        });
    });

}

Thank you for all your help

Upvotes: 0

Views: 356

Answers (2)

algorhythm
algorhythm

Reputation: 8728

you can use

.stop(false, true).animate(...);

or something with clearQueue()

http://api.jquery.com/clearQueue/

Upvotes: 1

Lowkase
Lowkase

Reputation: 5699

You need to stop all animations before you start the current animation, this is easy to do with jQuery:

stop()

Upvotes: 1

Related Questions