mirror of
https://github.com/RealKai42/qwerty-learner.git
synced 2026-04-05 14:29:04 +08:00
Merge branch 'fix/blur' into dev
fix/blur
This commit is contained in:
@@ -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])
|
||||
|
||||
Reference in New Issue
Block a user