-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(story-footer): slide in story footer on mouse move (#327)
* feat(story-footer): fade in story footer on hover * feat(story-footer): hide footer when mouse stops moving * feat(story-footer): clean up event listener * style(story-footer): add empty line before return
- Loading branch information
1 parent
5fd31e2
commit 92f9602
Showing
3 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {useEffect, useState} from 'react'; | ||
|
||
export const useMouseMove = () => { | ||
const [mouseMove, setMouseMove] = useState(true); | ||
|
||
useEffect(() => { | ||
let timer = 0; | ||
const handleMouseMove = () => { | ||
setMouseMove(true); | ||
timer = window.setTimeout(() => setMouseMove(false), 5000); | ||
}; | ||
window.addEventListener('mousemove', handleMouseMove); | ||
|
||
return () => { | ||
window.removeEventListener('mousemove', handleMouseMove); | ||
clearTimeout(timer); | ||
}; | ||
}, []); | ||
|
||
return mouseMove; | ||
}; |