function clearAnimation( element ) { if( typeof element.style.webkitTransform !== 'undefined' && element.style.webkitTransform ) { // 2nd conditional fixes bug in Chrome on windows element.style.webkitTransition = ''; element.style.webkitTransform = ''; } }This will prevent any overlap when switching between animatiions and instant repositioning.
A collection of handy code snippets in the languages that I use on a daily basis.
January 19, 2011
Javascript: Clear a webkitTransition animation
I was animating an html element with Webkit transitions via javascript, and after the animation was done, I applied non-animated webkitTransform positioning to the same element. It animated instead of immediately displaying the new style. I came up with the following function to clear any previous Webkit animation values:
Subscribe to:
Post Comments (Atom)
dude!
ReplyDeleteit's been sitting here for years and now it saved me!!!
thank you so much!