mirror of
https://github.com/jxnblk/mdx-deck.git
synced 2024-11-29 13:58:02 +03:00
Adjust storage focus state
This commit is contained in:
parent
2259a9d270
commit
565929e0ae
@ -4,7 +4,7 @@ const STORAGE_INDEX = 'mdx-slide'
|
||||
const STORAGE_STEP = 'mdx-step'
|
||||
|
||||
export const useLocalStorage = (handler, args = []) => {
|
||||
const [focused, setFocused] = useState(true)
|
||||
const [focused, setFocused] = useState(false)
|
||||
const handleFocus = () => {
|
||||
setFocused(true)
|
||||
}
|
||||
@ -12,6 +12,7 @@ export const useLocalStorage = (handler, args = []) => {
|
||||
setFocused(false)
|
||||
}
|
||||
useEffect(() => {
|
||||
setFocused(document.hasFocus())
|
||||
if (!focused) window.addEventListener('storage', handler)
|
||||
window.addEventListener('focus', handleFocus)
|
||||
window.addEventListener('blur', handleBlur)
|
||||
|
Loading…
Reference in New Issue
Block a user