actuate icon indicating copy to clipboard operation
actuate copied to clipboard

Add option to delay overwrite until tween initialization

Open chatziko opened this issue 6 years ago • 0 comments

An annoying aspect of Actuate is that sequencing doesn't work out of the box:

Actuate.tween(target, 1, { x: 10 });
Actuate.tween(target, 1, { x: 20, y: 20 }).delay(1);

false needs to be manually added to the second .tween to prevent overwriting the first one. One would expect that it's trivial for Actuate to detect that the second tween will start after the first finishes. But in fact it's tricky, cause the overwrite happens before the .delay(1) modifier is even called!

A simple and natural solution is to perform the overwrite not when the tween is created, but when it actually starts (that is, after the delay).

Pros:

  • simple solution
  • consistent with the current semantics (and no change in the semantics at all unless the tween is delayed)
  • no overhead
  • less risky than passing false to tween

This PR implements this feature, I'm experimenting with it so I thought to share.

(For simplicity, I added a global Actuate.delayOverwrite flag controling this behaviour, but of course there are more flexible ways.)

chatziko avatar Jan 22 '19 19:01 chatziko