Re: Efficient Script Yielding - First Editors Draft

Another use-case for efficient script yielding that I wanted to bring up:

For CSS transitions, if you for instance have a transition that's supposed 
to run for 1sec that does an ease-in fade for the background-color change of 
an element, and you want it to go from red to blue, you'd think you could 
do:

elem.style.backgroundColor = "red";
elem.style.backgroundColor = "blue";

Unfortunately, this doesn't work because the style changes are batched 
together by the browser, so it goes right to blue, no transition. The only 
known workaround is:

elem.style.backgroundColor = "red";
setTimeout(function(){ elem.style.backgroundColor = "blue"; },0);

Seems like this is a good use case for script yielding as well.


--Kyle

Received on Friday, 1 July 2011 12:50:41 UTC