Merge branch 'fix/blur' into dev

fix/blur
This commit is contained in:
KaiyiWing
2021-02-01 12:27:13 +08:00

View File

@@ -97,6 +97,19 @@ const App: React.FC = () => {
}
}, [isStart])
// When users turn to other tabs or apps, we will stop the timer.
useEffect(() => {
const onBlur = () => {
if (isStart) {
setIsStart(false)
}
}
if (isStart) {
window.addEventListener('blur', onBlur)
}
return () => window.removeEventListener('blur', onBlur)
}, [isStart])
useEffect(() => {
setChapterListLength(Math.ceil(dict.length / chapterLength))
}, [dict])