We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d42629d commit 951208fCopy full SHA for 951208f
1 file changed
src/useSynchronizedAnimation.ts
@@ -1,11 +1,14 @@
1
import { useLayoutEffect, useRef } from 'react'
2
3
-export const useSynchronizedAnimation = (options?: GetAnimationsOptions) => {
4
- const ref = useRef<HTMLElement>()
+export const useSynchronizedAnimation = <E extends HTMLElement>(
+ options?: GetAnimationsOptions
5
+) => {
6
+ const ref = useRef<E | null>(null)
7
useLayoutEffect(() => {
8
+ const currentTime = document.timeline?.currentTime ?? 0
9
ref.current
10
?.getAnimations(options)
- .forEach(a => (a.currentTime = document.timeline.currentTime))
11
+ .forEach(a => (a.currentTime = currentTime))
12
}, [options])
13
return ref
14
}
0 commit comments