forked from zzzgydi/clash-verge
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add animation to ProfileNew component (zzzgydi#252)
* chore: add .vscode to .gitignore * feat: add animation to ProfileNew component
- Loading branch information
Showing
3 changed files
with
109 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ dist-ssr | |
*.local | ||
update.json | ||
scripts/_env.sh | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> | ||
); | ||
}; |