If I run something like so:
var div1 = document.getElementById('div1'),
div2 = document.getElementById('div2');
function setAnimation() {
div1.style.webkitTransform = 'matrix(1,0,0,1,1200,0)';
div2.style.webkitTransform = 'matrix(1,0,0,1,0,0)';
div1.style.webkitTransition = div2.style.webkitTransition = '-webkit-transform 2s ease';
}
function startAnimation() {
div1.style.webkitTransform = 'matrix(1,0,0,1,0,0)';
div2.style.webkitTransform = 'matrix(1,0,0,1,-1200,0)';
}
setAnimation();
startAnimation();?
div2 animates offscreen just fine, yet div1 remains in it's place at 0,0 and a change is never seen.
If I remove startAnimation altogether and change setAnimation to:
function setAnimation() {
div1.style.webkitTransform = 'matrix(1,0,0,1,500,0)';
div2.style.webkitTransform = 'matrix(1,0,0,1,-500,0)';
div1.style.webkitTransition = div2.style.webkitTransition = '-webkit-transform 2s ease';
}
I would see both elements animate to those positions, both starting from 0,0.
It looks like an initial translation cannot be set dynamically within the same call stack as the setting of the transition? Or, more clearly, if a transition and transform are both set within the same call stack, transition will always take precedence.
Why is this?
See Question&Answers more detail:
os