feat: add animation to ProfileNew component (#252)

* chore: add .vscode to .gitignore

* feat: add animation to ProfileNew component
This commit is contained in:
angrylid
2022-10-29 20:02:51 +08:00
committed by GitHub
parent f238da416b
commit b88a736735
3 changed files with 109 additions and 79 deletions

View File

@@ -0,0 +1,30 @@
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>
);
};