mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 17:15:38 +08:00
31 lines
780 B
TypeScript
31 lines
780 B
TypeScript
import { useEffect, useRef } from "react";
|
|
|
|
export const Smoother: React.FC = ({ children }) => {
|
|
const self = useRef<HTMLDivElement>(null);
|
|
useEffect(() => {
|
|
if (typeof window.getComputedStyle == "undefined") return;
|
|
const element = self.current;
|
|
if (!element) return;
|
|
var height = window.getComputedStyle(element).height;
|
|
element.style.transition = "none";
|
|
element.style.height = "auto";
|
|
var targetHeight = window.getComputedStyle(element).height;
|
|
element.style.height = height;
|
|
|
|
setTimeout(() => {
|
|
element.style.transition = "height .5s";
|
|
element.style.height = targetHeight;
|
|
}, 0);
|
|
});
|
|
return (
|
|
<div
|
|
ref={self}
|
|
style={{
|
|
overflowY: "hidden",
|
|
}}
|
|
>
|
|
{children}
|
|
</div>
|
|
);
|
|
};
|