Skip to content Skip to sidebar Skip to footer

Can't Transition Between Scale 0 And 1 With Css Transitions

I want to make an image begin scaled all the way down in x in, and then animate all the way up in x when classes are added (via javascript). The pattern that I am using works well

Solution 1:

The problem is, it never gets a chance to get the start class and it goes straight to the end class. Putting the end class change into a timeout (even zero milliseconds!) will trick it into doing the both class changes:

functionanim(){
    a = document.querySelector('#myDiv');
    a.className = 'scaleXStart';
    setTimeout(function(){a.className = 'scaleXEnd';}, 0)
}
functionanim2(){
    a = document.querySelector('#myDiv');
    a.className = 'scaleXStart';
    a.className = 'scaleXEnd';
}

See what I mean here: http://jsfiddle.net/shomz/nzJ8j/

Post a Comment for "Can't Transition Between Scale 0 And 1 With Css Transitions"