Reader: nav hover reveals transiently, restores pre-hover state on leave
Previously hover both revealed (on enter) AND hid (on leave) via the persistent showUI state — so tapping the nav visible and then moving the mouse away would hide it. Now hover toggles a separate transient hoveringNav state; the nav is visible when (showUI || hoveringNav). On mouseleave, hoveringNav clears and the nav returns to whatever showUI was before — visible if the user tapped to show it, hidden if it was scroll-auto-hidden. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
f3d71a5423
commit
6eff1f68fc
@ -83,6 +83,7 @@ export function PageReader({
|
|||||||
// scrolled) doesn't overwrite prior bookmark for a different chapter.
|
// scrolled) doesn't overwrite prior bookmark for a different chapter.
|
||||||
const hasScrolledRef = useRef(false);
|
const hasScrolledRef = useRef(false);
|
||||||
const [canHover, setCanHover] = useState(false);
|
const [canHover, setCanHover] = useState(false);
|
||||||
|
const [hoveringNav, setHoveringNav] = useState(false);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setCanHover(window.matchMedia("(hover: hover)").matches);
|
setCanHover(window.matchMedia("(hover: hover)").matches);
|
||||||
}, []);
|
}, []);
|
||||||
@ -543,18 +544,18 @@ export function PageReader({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="min-h-dvh bg-background">
|
<div className="min-h-dvh bg-background">
|
||||||
{canHover && !showUI && (
|
{canHover && !showUI && !hoveringNav && (
|
||||||
<div
|
<div
|
||||||
className="fixed top-0 left-0 right-0 h-16 z-40"
|
className="fixed top-0 left-0 right-0 h-16 z-40"
|
||||||
onMouseEnter={() => setShowUI(true)}
|
onMouseEnter={() => setHoveringNav(true)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<div
|
<div
|
||||||
className={`sticky top-0 z-50 bg-background backdrop-blur-sm shadow-sm transition-transform duration-300 pt-safe ${
|
className={`sticky top-0 z-50 bg-background backdrop-blur-sm shadow-sm transition-transform duration-300 pt-safe ${
|
||||||
showUI ? "translate-y-0" : "-translate-y-full"
|
showUI || hoveringNav ? "translate-y-0" : "-translate-y-full"
|
||||||
}`}
|
}`}
|
||||||
onMouseEnter={canHover ? () => setShowUI(true) : undefined}
|
onMouseEnter={canHover ? () => setHoveringNav(true) : undefined}
|
||||||
onMouseLeave={canHover ? () => setShowUI(false) : undefined}
|
onMouseLeave={canHover ? () => setHoveringNav(false) : undefined}
|
||||||
>
|
>
|
||||||
<div className="flex items-center gap-3 px-4 h-12 max-w-4xl mx-auto">
|
<div className="flex items-center gap-3 px-4 h-12 max-w-4xl mx-auto">
|
||||||
<Link
|
<Link
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user