Optimize dragging animation

This commit is contained in:
Nate Kelley 2025-05-09 14:24:27 -06:00
parent 6b46d218b8
commit e66f26f7a2
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
1 changed files with 22 additions and 14 deletions

View File

@ -3,7 +3,7 @@ import { Card, CardHeader } from '@/components/ui/card/CardBase';
import { useDashboardMetric } from './useDashboardMetric';
import { MetricTitle } from './MetricTitle';
import { createBusterRoute, BusterRoutes } from '@/routes';
import { useMemoizedFn, useMount } from '@/hooks';
import { useMemoizedFn } from '@/hooks';
import { cn } from '@/lib/classMerge';
import { BusterChart } from '@/components/ui/charts/BusterChart';
@ -70,6 +70,10 @@ const DashboardMetricItemBase: React.FC<{
setInitialAnimationEnded(metricId);
});
const hideChart = useMemo(() => {
return isDragOverlay && data && data.length > 50;
}, [isDragOverlay, data?.length]);
return (
<Card
ref={conatinerRef}
@ -96,19 +100,23 @@ const DashboardMetricItemBase: React.FC<{
isTable ? '' : 'p-3',
isDragOverlay ? 'pointer-events-none' : 'pointer-events-auto'
)}>
{renderChart && chartOptions && (
<BusterChart
data={data}
loading={loading}
error={error}
onInitialAnimationEnd={onInitialAnimationEndPreflight}
animate={!isDragOverlay && animate}
animateLegend={false}
columnMetadata={metricData?.data_metadata?.column_metadata}
readOnly={true}
{...chartOptions}
/>
)}
{renderChart &&
chartOptions &&
(!hideChart ? (
<BusterChart
data={data}
loading={loading}
error={error}
onInitialAnimationEnd={onInitialAnimationEndPreflight}
animate={!isDragOverlay && animate}
animateLegend={false}
columnMetadata={metricData?.data_metadata?.column_metadata}
readOnly={true}
{...chartOptions}
/>
) : (
<div className="bg-gray-light/10 h-full w-full rounded" />
))}
</div>
</Card>
);