as title implies, there proper way set initial css properties (or class) , tell browser transition these value? for example ( fiddle ): var el = document.queryselector('div'), st = el.style; st.opacity = 0; st.transition = 'opacity 2s'; st.opacity = 1; this not animate opacity of element in chrome 29/firefox 23. because ( source ): [...] you’ll find if apply both sets of properties, 1 after other, browser tries optimize property changes, ignoring initial properties , preventing transition. behind scenes, browsers batch property changes before painting which, while speeding rendering, can have adverse affects. the solution force redraw between applying 2 sets of properties. simple method of doing accessing dom element’s offsetheight property [...] in fact, hack work in current chrome/firefox versions. updated code ( fiddle - click run after opening fiddle run animation again): var el = document.queryselector('div'
Comments
Post a Comment