@threlte/theatre
Version:
Threlte Components for Theatre, an animation library with a professional motion design toolset
21 lines (20 loc) • 588 B
JavaScript
import { getContext } from 'svelte';
/**
* ### `useSequence`
*
* A hook to get the current sequence controller. If a key is provided, it will
* get the sequence controller with that key. Otherwise, it will get the
* "nearest" default sequence controller.
*/
export const useSequence = (key = undefined) => {
let sequence;
if (key) {
sequence = getContext('theatre-sheet').sequences[key];
}
else {
sequence =
getContext('theatre-sequence') ??
getContext('theatre-sheet').sequences['default'];
}
return sequence;
};