MCPcopy Create free account
hub / github.com/adobe/react-spectrum / animate

Function animate

packages/dev/s2-docs/pages/react-aria/home/utils.ts:35–59  ·  view source on GitHub ↗
(steps: {time: number; perform: () => void}[])

Source from the content-addressed store, hash-verified

33animationQueue.next(); // advance to first yield
34
35export function animate(steps: {time: number; perform: () => void}[]): () => void {
36 let cancelCurrentStep;
37 async function run() {
38 for (let step of steps) {
39 try {
40 step.perform();
41 let {promise, cancel} = sleep(step.time);
42 cancelCurrentStep = cancel;
43 await promise;
44 } catch {
45 break;
46 }
47 }
48 }
49
50 let job = {isCanceled: false, run};
51 animationQueue.next(job);
52
53 return () => {
54 job.isCanceled = true;
55 if (cancelCurrentStep) {
56 cancelCurrentStep();
57 }
58 };
59}
60
61function sleep(ms: number) {
62 let timeout;

Callers 8

startAnimationFunction · 0.90
MouseAnimationFunction · 0.90
onSelectionChangeFunction · 0.90
A11yFunction · 0.90
ListBoxExampleFunction · 0.90
MobileFunction · 0.90
startAnimationFunction · 0.90
PressAnimationFunction · 0.90

Calls 1

nextMethod · 0.80

Tested by

no test coverage detected