-
-
Notifications
You must be signed in to change notification settings - Fork 575
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): add waitTransition (#983)
- Loading branch information
1 parent
6bd072a
commit 27f24e1
Showing
3 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import {waitFor} from '../flow'; | ||
import {SignalValue} from '../signals'; | ||
import {ThreadGenerator} from '../threading'; | ||
import {useTransition} from './useTransition'; | ||
|
||
/** | ||
* Perform a transition that doesn't do anything. | ||
* | ||
* @remarks | ||
* This is useful when you want to achieve a transition effect by animating | ||
* objects in the scenes. It will overlay the scenes on top of each other for | ||
* the duration of the transition. | ||
* | ||
* @param duration - The duration of the transition. | ||
* @param previousOnTop - Whether the previous scene should be rendered on top. | ||
*/ | ||
export function* waitTransition( | ||
duration = 0.6, | ||
previousOnTop: SignalValue<boolean> = true, | ||
): ThreadGenerator { | ||
const endTransition = useTransition( | ||
() => { | ||
// do nothing | ||
}, | ||
undefined, | ||
previousOnTop, | ||
); | ||
|
||
yield* waitFor(duration); | ||
endTransition(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters