fix: Flash of incorrect cursor when hover preview opens
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import { m } from "framer-motion";
|
||||||
import { transparentize } from "polished";
|
import { transparentize } from "polished";
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { Portal } from "react-portal";
|
import { Portal } from "react-portal";
|
||||||
@@ -10,7 +11,6 @@ import useMobile from "~/hooks/useMobile";
|
|||||||
import useOnClickOutside from "~/hooks/useOnClickOutside";
|
import useOnClickOutside from "~/hooks/useOnClickOutside";
|
||||||
import useRequest from "~/hooks/useRequest";
|
import useRequest from "~/hooks/useRequest";
|
||||||
import useStores from "~/hooks/useStores";
|
import useStores from "~/hooks/useStores";
|
||||||
import { fadeAndSlideDown } from "~/styles/animations";
|
|
||||||
import { client } from "~/utils/ApiClient";
|
import { client } from "~/utils/ApiClient";
|
||||||
import HoverPreviewDocument from "./HoverPreviewDocument";
|
import HoverPreviewDocument from "./HoverPreviewDocument";
|
||||||
import HoverPreviewMention from "./HoverPreviewMention";
|
import HoverPreviewMention from "./HoverPreviewMention";
|
||||||
@@ -146,9 +146,11 @@ function HoverPreviewInternal({ element, onClose }: Props) {
|
|||||||
>
|
>
|
||||||
<div ref={cardRef}>
|
<div ref={cardRef}>
|
||||||
{isVisible ? (
|
{isVisible ? (
|
||||||
<Animate>
|
<Animate
|
||||||
|
initial={{ opacity: 0, y: -20, pointerEvents: "none" }}
|
||||||
|
animate={{ opacity: 1, y: 0, pointerEvents: "auto" }}
|
||||||
|
>
|
||||||
<Card fadeOut={data.type !== UnfurlType.Mention}>
|
<Card fadeOut={data.type !== UnfurlType.Mention}>
|
||||||
<Margin />
|
|
||||||
<CardContent>
|
<CardContent>
|
||||||
{data.type === UnfurlType.Mention ? (
|
{data.type === UnfurlType.Mention ? (
|
||||||
<HoverPreviewMention
|
<HoverPreviewMention
|
||||||
@@ -186,23 +188,12 @@ function HoverPreview({ element, ...rest }: Props) {
|
|||||||
return <HoverPreviewInternal {...rest} element={element} />;
|
return <HoverPreviewInternal {...rest} element={element} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Animate = styled.div`
|
const Animate = styled(m.div)`
|
||||||
animation: ${fadeAndSlideDown} 150ms ease;
|
|
||||||
|
|
||||||
@media print {
|
@media print {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
// fills the gap between the card and pointer to avoid a dead zone
|
|
||||||
const Margin = styled.div`
|
|
||||||
position: absolute;
|
|
||||||
top: -11px;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
height: 11px;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const CardContent = styled.div`
|
const CardContent = styled.div`
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
max-height: 20em;
|
max-height: 20em;
|
||||||
@@ -227,6 +218,16 @@ const Card = styled.div<{ fadeOut?: boolean }>`
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fills the gap between the card and pointer to avoid a dead zone
|
||||||
|
&::before {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
top: -10px;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
height: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
${(props) =>
|
${(props) =>
|
||||||
props.fadeOut !== false
|
props.fadeOut !== false
|
||||||
? `&:after {
|
? `&:after {
|
||||||
|
|||||||
Reference in New Issue
Block a user