[Video] Add disable autoplay for native, more tweaking (#5178)
This commit is contained in:
parent
bdff8752fb
commit
60182cd874
5 changed files with 84 additions and 63 deletions
|
@ -1,17 +1,20 @@
|
|||
import React from 'react'
|
||||
|
||||
export const useDedupe = () => {
|
||||
export const useDedupe = (timeout = 250) => {
|
||||
const canDo = React.useRef(true)
|
||||
|
||||
return React.useCallback((cb: () => unknown) => {
|
||||
if (canDo.current) {
|
||||
canDo.current = false
|
||||
setTimeout(() => {
|
||||
canDo.current = true
|
||||
}, 250)
|
||||
cb()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}, [])
|
||||
return React.useCallback(
|
||||
(cb: () => unknown) => {
|
||||
if (canDo.current) {
|
||||
canDo.current = false
|
||||
setTimeout(() => {
|
||||
canDo.current = true
|
||||
}, timeout)
|
||||
cb()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
},
|
||||
[timeout],
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue