Transition: Avoid possible forced layout
This commit is contained in:
parent
f049b50e5e
commit
384e216e5f
@ -237,12 +237,14 @@ const Transition: FC<TransitionProps> = ({
|
|||||||
const container = containerRef.current!;
|
const container = containerRef.current!;
|
||||||
const activeElement = container.querySelector<HTMLDivElement>(`.${classNames.active}`)
|
const activeElement = container.querySelector<HTMLDivElement>(`.${classNames.active}`)
|
||||||
|| container.querySelector<HTMLDivElement>('.from');
|
|| container.querySelector<HTMLDivElement>('.from');
|
||||||
|
const clientHeight = activeElement?.clientHeight;
|
||||||
if (activeElement) {
|
if (!clientHeight) {
|
||||||
activeElement.style.height = 'auto';
|
return;
|
||||||
container.style.height = `${activeElement.clientHeight}px`;
|
|
||||||
container.style.flexBasis = `${activeElement.clientHeight}px`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
activeElement.style.height = 'auto';
|
||||||
|
container.style.height = `${clientHeight}px`;
|
||||||
|
container.style.flexBasis = `${clientHeight}px`;
|
||||||
}
|
}
|
||||||
}, [shouldRestoreHeight, children]);
|
}, [shouldRestoreHeight, children]);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user