-
-
Notifications
You must be signed in to change notification settings - Fork 592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add useDuration
helper
#226
feat: add useDuration
helper
#226
Conversation
```ts | ||
useScene().timeEvents.register('event') | ||
``` | ||
|
||
This registers a Time Event called `event`. | ||
Then we can grab the duration of said event as follows: | ||
|
||
```ts | ||
const duration = useScene().timeEvents.get('event').offset; | ||
``` | ||
|
||
And finally we can use this `duration` to animate the circle: | ||
|
||
```ts | ||
yield* circle().scale(2, duration); | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an internal implementation detail, I don't think we should include it in the docs.
I'd simply say:
Aside from specifying _when_ something should happen, time events can be used to
control _how long_ something should last. You can use the
[`useDuration`](/api/core/utils#useDuration) function to retrieve the duration of an event
and use it in your animation:
```ts
yield* circle().scale(2, useDuration('event'));
```
@@ -48,3 +48,36 @@ it. This is useful when you want to extend or shorten a pause in your voiceover | |||
because correcting the first time event after the pause will also fix all events | |||
after it. You can hold `SHIFT` when editing an event to prevent this from | |||
happening. | |||
|
|||
## Controlling animation duration with Time Events |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The entire section is about time events so I think it could be just:
## Controlling animation duration with Time Events | |
## Controlling animation duration |
Thanks for the PR! |
What has changed?
This Pull Request adds a new helper / utility function that allows for easier creation and usage of
TimeEvent
s for animations.Furthermore, the documentation has been extended and now features a subsection ("Controlling animation duration with Time Events") under the
Time Events
chapter.Closes: #171
Example
Let's look at the following example where we want to animate the
scale
of acircle
:In the example a
TimeEvent
calledevent
is registered and its duration gets used to controlthe
duration
of the circle'sscale
animation.With the new
useDuration
function, this can be reduced to a single line of code as follows: