mirror of https://github.com/buster-so/buster.git
Optimize dragging animation
This commit is contained in:
parent
6b46d218b8
commit
e66f26f7a2
|
@ -3,7 +3,7 @@ import { Card, CardHeader } from '@/components/ui/card/CardBase';
|
||||||
import { useDashboardMetric } from './useDashboardMetric';
|
import { useDashboardMetric } from './useDashboardMetric';
|
||||||
import { MetricTitle } from './MetricTitle';
|
import { MetricTitle } from './MetricTitle';
|
||||||
import { createBusterRoute, BusterRoutes } from '@/routes';
|
import { createBusterRoute, BusterRoutes } from '@/routes';
|
||||||
import { useMemoizedFn, useMount } from '@/hooks';
|
import { useMemoizedFn } from '@/hooks';
|
||||||
import { cn } from '@/lib/classMerge';
|
import { cn } from '@/lib/classMerge';
|
||||||
import { BusterChart } from '@/components/ui/charts/BusterChart';
|
import { BusterChart } from '@/components/ui/charts/BusterChart';
|
||||||
|
|
||||||
|
@ -70,6 +70,10 @@ const DashboardMetricItemBase: React.FC<{
|
||||||
setInitialAnimationEnded(metricId);
|
setInitialAnimationEnded(metricId);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const hideChart = useMemo(() => {
|
||||||
|
return isDragOverlay && data && data.length > 50;
|
||||||
|
}, [isDragOverlay, data?.length]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
ref={conatinerRef}
|
ref={conatinerRef}
|
||||||
|
@ -96,19 +100,23 @@ const DashboardMetricItemBase: React.FC<{
|
||||||
isTable ? '' : 'p-3',
|
isTable ? '' : 'p-3',
|
||||||
isDragOverlay ? 'pointer-events-none' : 'pointer-events-auto'
|
isDragOverlay ? 'pointer-events-none' : 'pointer-events-auto'
|
||||||
)}>
|
)}>
|
||||||
{renderChart && chartOptions && (
|
{renderChart &&
|
||||||
<BusterChart
|
chartOptions &&
|
||||||
data={data}
|
(!hideChart ? (
|
||||||
loading={loading}
|
<BusterChart
|
||||||
error={error}
|
data={data}
|
||||||
onInitialAnimationEnd={onInitialAnimationEndPreflight}
|
loading={loading}
|
||||||
animate={!isDragOverlay && animate}
|
error={error}
|
||||||
animateLegend={false}
|
onInitialAnimationEnd={onInitialAnimationEndPreflight}
|
||||||
columnMetadata={metricData?.data_metadata?.column_metadata}
|
animate={!isDragOverlay && animate}
|
||||||
readOnly={true}
|
animateLegend={false}
|
||||||
{...chartOptions}
|
columnMetadata={metricData?.data_metadata?.column_metadata}
|
||||||
/>
|
readOnly={true}
|
||||||
)}
|
{...chartOptions}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<div className="bg-gray-light/10 h-full w-full rounded" />
|
||||||
|
))}
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue