style: add fade-in transition from skeleton to content
Smooth out the jarring visual pop when loading skeletons are replaced by real content. Only animates after an actual skeleton was shown — cached data still renders instantly with no delay.
This commit is contained in:
@@ -32,3 +32,19 @@ export function useMinimumLoading(loading: boolean, minMs = 300): boolean {
|
||||
|
||||
return show
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 'animate-fade-in' when transitioning from skeleton to content,
|
||||
* empty string otherwise. Prevents the jarring visual "pop" when skeletons
|
||||
* are replaced by real content, without adding unnecessary animation when
|
||||
* data loads from cache (no skeleton shown).
|
||||
*/
|
||||
export function useSkeletonFade(showSkeleton: boolean): string {
|
||||
const wasEverLoading = useRef(false)
|
||||
|
||||
if (showSkeleton) {
|
||||
wasEverLoading.current = true
|
||||
}
|
||||
|
||||
return !showSkeleton && wasEverLoading.current ? 'animate-fade-in' : ''
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user