This commit is contained in:
IndieKKY
2023-05-17 16:37:56 +08:00
commit 858f83a45c
59 changed files with 8855 additions and 0 deletions

20
src/hooks/useSubtitle.ts Normal file
View File

@@ -0,0 +1,20 @@
import {useAppDispatch} from './redux'
import React, {useCallback} from 'react'
import {setNeedScroll} from '../redux/envReducer'
const useSubtitle = () => {
const dispatch = useAppDispatch()
const move = useCallback((time: number) => {
window.parent.postMessage({type: 'move', time}, '*')
}, [])
const scrollIntoView = useCallback((ref: React.RefObject<HTMLDivElement>) => {
ref.current?.scrollIntoView({behavior: 'smooth', block: 'center'})
dispatch(setNeedScroll(false))
}, [dispatch])
return {move, scrollIntoView}
}
export default useSubtitle