chore: all hide logic to hooks
parent
018e32e355
commit
9822445c1e
@ -0,0 +1,40 @@
|
|||||||
|
import { useCallback, useState } from 'react'
|
||||||
|
import useFoldAnimInto from './use-fold-anim-into'
|
||||||
|
|
||||||
|
const useHideLogic = (onClose: () => void) => {
|
||||||
|
const {
|
||||||
|
modalClassName,
|
||||||
|
foldIntoAnim: doFoldAnimInto,
|
||||||
|
clearCountDown,
|
||||||
|
countDownFoldIntoAnim,
|
||||||
|
} = useFoldAnimInto(onClose)
|
||||||
|
|
||||||
|
const [isInstalling, doSetIsInstalling] = useState(false)
|
||||||
|
const setIsInstalling = useCallback((isInstalling: boolean) => {
|
||||||
|
if (!isInstalling)
|
||||||
|
clearCountDown()
|
||||||
|
doSetIsInstalling(isInstalling)
|
||||||
|
}, [clearCountDown])
|
||||||
|
|
||||||
|
const foldAnimInto = useCallback(() => {
|
||||||
|
if (isInstalling) {
|
||||||
|
doFoldAnimInto()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
onClose()
|
||||||
|
}, [doFoldAnimInto, isInstalling, onClose])
|
||||||
|
|
||||||
|
const handleStartToInstall = useCallback(() => {
|
||||||
|
setIsInstalling(true)
|
||||||
|
countDownFoldIntoAnim()
|
||||||
|
}, [countDownFoldIntoAnim, setIsInstalling])
|
||||||
|
|
||||||
|
return {
|
||||||
|
modalClassName,
|
||||||
|
foldAnimInto,
|
||||||
|
setIsInstalling,
|
||||||
|
handleStartToInstall,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default useHideLogic
|
||||||
Loading…
Reference in New Issue