Enhance RAF
This PR modifies the existing RAF draw mechanism in the following ways:
-
use RAF and keep bouncing turning it off so that its not running if nothing needs to be repainted. This allows at both have the advantages of RAF without the cost of having it running when not needed.
-
Have only one RAF servicing all elements CS is handling
-
add a mechanism to register for callbacks from the RAF (
addDrawCallbackandremoveDrawCallback). Tools such asPlayClipcan now simply register for RAF callback, switch the image on the element and return without needing to maintain their ownsetTimeoutmechanisms -
drawImage now registers for the
visibilitychangeHTML event so that ie when a tab that lost focus regains it RAF wil start again
I didn't test it, but I don't have any objections based on the implementation. IMHO, It's far better than the last proposal. 👍
Any news on this ?