Reduce hovercard false positives, add them to display names and handles (#3739)
* Don't trigger hovercards on scroll * Add display name / handle hovercards * Increase hovercard delayzio/stable
parent
74cd1d4458
commit
3b4848ba59
|
@ -72,10 +72,10 @@ type Action =
|
||||||
| 'unhovered-long-enough'
|
| 'unhovered-long-enough'
|
||||||
| 'finished-animating-hide'
|
| 'finished-animating-hide'
|
||||||
|
|
||||||
const SHOW_DELAY = 400
|
const SHOW_DELAY = 500
|
||||||
const SHOW_DURATION = 300
|
const SHOW_DURATION = 300
|
||||||
const HIDE_DELAY = 150
|
const HIDE_DELAY = 150
|
||||||
const HIDE_DURATION = 150
|
const HIDE_DURATION = 200
|
||||||
|
|
||||||
export function ProfileHoverCardInner(props: ProfileHoverCardProps) {
|
export function ProfileHoverCardInner(props: ProfileHoverCardProps) {
|
||||||
const {refs, floatingStyles} = useFloating({
|
const {refs, floatingStyles} = useFloating({
|
||||||
|
@ -244,12 +244,20 @@ export function ProfileHoverCardInner(props: ProfileHoverCardProps) {
|
||||||
}
|
}
|
||||||
}, [prefetchProfileQuery, props.did])
|
}, [prefetchProfileQuery, props.did])
|
||||||
|
|
||||||
const onPointerEnterTarget = React.useCallback(() => {
|
const didFireHover = React.useRef(false)
|
||||||
|
const onPointerMoveTarget = React.useCallback(() => {
|
||||||
prefetchIfNeeded()
|
prefetchIfNeeded()
|
||||||
dispatch('hovered-target')
|
// Conceptually we want something like onPointerEnter,
|
||||||
|
// but we want to ignore entering only due to scrolling.
|
||||||
|
// So instead we hover on the first onPointerMove.
|
||||||
|
if (!didFireHover.current) {
|
||||||
|
didFireHover.current = true
|
||||||
|
dispatch('hovered-target')
|
||||||
|
}
|
||||||
}, [prefetchIfNeeded])
|
}, [prefetchIfNeeded])
|
||||||
|
|
||||||
const onPointerLeaveTarget = React.useCallback(() => {
|
const onPointerLeaveTarget = React.useCallback(() => {
|
||||||
|
didFireHover.current = false
|
||||||
dispatch('unhovered-target')
|
dispatch('unhovered-target')
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
@ -280,7 +288,7 @@ export function ProfileHoverCardInner(props: ProfileHoverCardProps) {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
ref={refs.setReference}
|
ref={refs.setReference}
|
||||||
onPointerEnter={onPointerEnterTarget}
|
onPointerMove={onPointerMoveTarget}
|
||||||
onPointerLeave={onPointerLeaveTarget}
|
onPointerLeave={onPointerLeaveTarget}
|
||||||
onMouseUp={onPress}
|
onMouseUp={onPress}
|
||||||
style={{
|
style={{
|
||||||
|
|
|
@ -11,6 +11,7 @@ import {sanitizeHandle} from 'lib/strings/handles'
|
||||||
import {niceDate} from 'lib/strings/time'
|
import {niceDate} from 'lib/strings/time'
|
||||||
import {TypographyVariant} from 'lib/ThemeContext'
|
import {TypographyVariant} from 'lib/ThemeContext'
|
||||||
import {isAndroid, isWeb} from 'platform/detection'
|
import {isAndroid, isWeb} from 'platform/detection'
|
||||||
|
import {ProfileHoverCard} from '#/components/ProfileHoverCard'
|
||||||
import {TextLinkOnWebOnly} from './Link'
|
import {TextLinkOnWebOnly} from './Link'
|
||||||
import {Text} from './text/Text'
|
import {Text} from './text/Text'
|
||||||
import {TimeElapsed} from './TimeElapsed'
|
import {TimeElapsed} from './TimeElapsed'
|
||||||
|
@ -58,37 +59,39 @@ let PostMeta = (opts: PostMetaOpts): React.ReactNode => {
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
<Text
|
<ProfileHoverCard inline did={opts.author.did}>
|
||||||
numberOfLines={1}
|
<Text
|
||||||
style={[styles.maxWidth, pal.textLight, opts.displayNameStyle]}>
|
numberOfLines={1}
|
||||||
<TextLinkOnWebOnly
|
style={[styles.maxWidth, pal.textLight, opts.displayNameStyle]}>
|
||||||
type={opts.displayNameType || 'lg-bold'}
|
<TextLinkOnWebOnly
|
||||||
style={[pal.text]}
|
type={opts.displayNameType || 'lg-bold'}
|
||||||
lineHeight={1.2}
|
style={[pal.text]}
|
||||||
disableMismatchWarning
|
lineHeight={1.2}
|
||||||
text={
|
disableMismatchWarning
|
||||||
<>
|
text={
|
||||||
{sanitizeDisplayName(
|
<>
|
||||||
displayName,
|
{sanitizeDisplayName(
|
||||||
opts.moderation?.ui('displayName'),
|
displayName,
|
||||||
)}
|
opts.moderation?.ui('displayName'),
|
||||||
</>
|
)}
|
||||||
}
|
</>
|
||||||
href={profileLink}
|
}
|
||||||
onBeforePress={onBeforePress}
|
href={profileLink}
|
||||||
onPointerEnter={onPointerEnter}
|
onBeforePress={onBeforePress}
|
||||||
/>
|
onPointerEnter={onPointerEnter}
|
||||||
<TextLinkOnWebOnly
|
/>
|
||||||
type="md"
|
<TextLinkOnWebOnly
|
||||||
disableMismatchWarning
|
type="md"
|
||||||
style={[pal.textLight, {flexShrink: 4}]}
|
disableMismatchWarning
|
||||||
text={'\xa0' + sanitizeHandle(handle, '@')}
|
style={[pal.textLight, {flexShrink: 4}]}
|
||||||
href={profileLink}
|
text={'\xa0' + sanitizeHandle(handle, '@')}
|
||||||
onBeforePress={onBeforePress}
|
href={profileLink}
|
||||||
onPointerEnter={onPointerEnter}
|
onBeforePress={onBeforePress}
|
||||||
anchorNoUnderline
|
onPointerEnter={onPointerEnter}
|
||||||
/>
|
anchorNoUnderline
|
||||||
</Text>
|
/>
|
||||||
|
</Text>
|
||||||
|
</ProfileHoverCard>
|
||||||
{!isAndroid && (
|
{!isAndroid && (
|
||||||
<Text
|
<Text
|
||||||
type="md"
|
type="md"
|
||||||
|
|
Loading…
Reference in New Issue