Closed aaronjolson closed 1 year ago
The second parameter of to()
is the duration of the tween.
You can use wait()
to synchronize chains together:
yield* all(
myCircle().position.x(300, 1).wait(1).to(-300, 1),
myCircle().fill('#550000', 1).to('#000055', 1).to('#005500', 1).to('#555555', 1),
delay(1, myCircle().position.y(300, 1).wait(1).to(-300, 1)),
);
// the same code reformatted to highlight synchronization:
yield* all(
myCircle().position.x(300, 1) .wait( 1) .to(-300, 1),
myCircle().fill('#550000', 1) .to('#000055', 1) .to('#005500', 1) .to('#555555', 1),
delay(1, myCircle().position .y(300, 1) .wait( 1) .to(-300, 1)),
);
Or, alternatively, you can animate the entire position instead of individual components. But in this case, you'll have to repeat certain values in multiple palces:
yield* all(
myCircle().position([300, 0], 1).to([300, 300], 1).to([-300, 300], 1).to([-300, -300], 1),
myCircle().fill('#550000', 1).to('#000055', 1).to('#005500', 1).to('#555555', 1),
);
// the same code reformatted to highlight synchronization:
yield* all(
myCircle().position([300, 0], 1) .to([300, 300], 1) .to([-300, 300], 1) .to([-300, -300], 1),
myCircle().fill('#550000', 1) .to('#000055', 1) .to('#005500', 1) .to('#555555', 1),
);
Thank you! This was very helpful!
Hello, I am trying to wrap my head around the action chaining behaviors in this library. Using the default example from the docs, I expanded it a bit to have the circle move around in a square pattern.
My question is, is there a better, or more concise way of doing this? I had originally tried chaining .to() statements inside of a single yield* all(), eg,
But this does not work how I was thinking it might. I was thinking that the .to() method would chain, and use the second parameter to break up the steps, but it does not.