wait a sec before showing card (#3516)
parent
cefa0a55e8
commit
7d01ff90d3
|
@ -62,22 +62,25 @@ export function ProfileHoverCardInner(props: ProfileHoverCardProps) {
|
||||||
const targetHovered = React.useRef(false)
|
const targetHovered = React.useRef(false)
|
||||||
const cardHovered = React.useRef(false)
|
const cardHovered = React.useRef(false)
|
||||||
const targetClicked = React.useRef(false)
|
const targetClicked = React.useRef(false)
|
||||||
|
const showTimeout = React.useRef<NodeJS.Timeout>()
|
||||||
|
|
||||||
const onPointerEnterTarget = React.useCallback(() => {
|
const onPointerEnterTarget = React.useCallback(() => {
|
||||||
targetHovered.current = true
|
showTimeout.current = setTimeout(async () => {
|
||||||
|
targetHovered.current = true
|
||||||
|
|
||||||
|
if (prefetchedProfile.current) {
|
||||||
|
// if we're navigating
|
||||||
|
if (targetClicked.current) return
|
||||||
|
setHovered(true)
|
||||||
|
} else {
|
||||||
|
await prefetchProfileQuery(props.did)
|
||||||
|
|
||||||
if (prefetchedProfile.current) {
|
|
||||||
// if we're navigating
|
|
||||||
if (targetClicked.current) return
|
|
||||||
setHovered(true)
|
|
||||||
} else {
|
|
||||||
prefetchProfileQuery(props.did).then(() => {
|
|
||||||
if (targetHovered.current) {
|
if (targetHovered.current) {
|
||||||
setHovered(true)
|
setHovered(true)
|
||||||
}
|
}
|
||||||
prefetchedProfile.current = true
|
prefetchedProfile.current = true
|
||||||
})
|
}
|
||||||
}
|
}, 350)
|
||||||
}, [props.did, prefetchProfileQuery])
|
}, [props.did, prefetchProfileQuery])
|
||||||
const onPointerEnterCard = React.useCallback(() => {
|
const onPointerEnterCard = React.useCallback(() => {
|
||||||
cardHovered.current = true
|
cardHovered.current = true
|
||||||
|
@ -86,6 +89,7 @@ export function ProfileHoverCardInner(props: ProfileHoverCardProps) {
|
||||||
setHovered(true)
|
setHovered(true)
|
||||||
}, [])
|
}, [])
|
||||||
const onPointerLeaveTarget = React.useCallback(() => {
|
const onPointerLeaveTarget = React.useCallback(() => {
|
||||||
|
clearTimeout(showTimeout.current)
|
||||||
targetHovered.current = false
|
targetHovered.current = false
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (cardHovered.current) return
|
if (cardHovered.current) return
|
||||||
|
|
Loading…
Reference in New Issue