Skip to content

Commit

Permalink
fix: show / hide default video controls on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
bbohlender committed Jun 25, 2024
1 parent d949959 commit c6f2e3f
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions packages/kits/default/src/video.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,16 @@ export const Video: (props: VideoProperties & RefAttributes<VideoInternals>) =>
const moving = useMemo(() => signal(false), [])
const handlers = useMemo<EventHandlers>(() => {
let timeoutRef: NodeJS.Timeout | undefined
const cancelTimeout = () => {
if (timeoutRef == null) {
return
const onInteract = () => {
moving.value = true
if (timeoutRef != null) {
clearTimeout(timeoutRef)
}
clearTimeout(timeoutRef)
timeoutRef = undefined
timeoutRef = setTimeout(() => (moving.value = false), 2000)
}
return {
onPointerMove: () => {
moving.value = true
cancelTimeout()
timeoutRef = setTimeout(() => (moving.value = false), 2000)
},
onPointerOut: () => {
moving.value = false
cancelTimeout
},
onPointerMove: onInteract,
onPointerDown: onInteract,
}
}, [moving])
return (
Expand Down

0 comments on commit c6f2e3f

Please sign in to comment.