
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
@douyinfe/semi-animation-react
Advanced tools
React animation library based on
@douyinfe/semi-animation
.
The transition animation effects of all components in @douyinfe/semi-ui
are implemented based on this animation library, such as: Modal, Tooltip, Collapse and other component content display and exit effects.
npm install @douyinfe/semi-animation-react
It is used to realize the animation effect of the component [show and exit]. Examples are as follows:
import { Transition } from "@douyinfe/semi-animation-react";
import { useState } from "react";
export default function App() {
const [visible, setVisible] = useState(false);
return (
<div className="App">
<Transition
state={visible ? "enter" : "leave"}
from={{ opacity: 0, scale: 0}}
enter={{ opacity: 1, scale: 1 }}
leave={{ opacity: 0, scale: 0 }}
>
{({ scale, opacity }: any) => (
<h2 style={{transform: `scale(${scale})`, opacity}}>
Toggle to see some animation happen!
</h2>
)}
</Transition>
<button onClick={() => {
setVisible((state) => !state)
}}>toggle</button>
</div>
);
}
Name | Type | Required | Default | Description |
---|---|---|---|---|
from | Object | Y | Initial state | |
enter | Object | Y | Show the end state of the animation, but also the initial state of the exit animation | |
leave | Object | Y | Exit the termination state of the animation | |
state | Enum 'enter', 'leave' | N | '' | Current state |
willEnter | Function | N | ()=> {} | The callback function before the enter animation starts |
didEnter | Function | N | ()=> {} | The callback function before the animation ends |
willLeave | Function | N | ()=> {} | The callback function before the exit animation starts |
didLeave | Function | N | ()=> {} | The callback function before the exit animation ends |
onStart | Function | N | ()=> {} | The callback function before animation starts,including enter and exit |
onRest | Function | N | ()=> {} | The callback function before animation ends,including enter and exit |
config | ConfigType | N | {} | Additional animation parameters |
Name | Type | Default | Description |
---|---|---|---|
duration | Number | 1000 | Animation duration.If this parameter is passed in, the easing function of the animation will use easing or linear function,unit: ms |
easing | Function|String | Easing function for animation. If duration is not passed, the spring easing function is used by default. If the duration parameter is passed in, the linear easing function will be used by default.For example, incoming "cubic-bezier(.17,.67,.83,.67)" will cause the animation frame update performed according to this easing function | |
tension | Number | 170 | Tension, used for spring easing function |
friction | Number | 14 | Friction, used for spring easing function |
FAQs
motion library for semi-ui-react
The npm package @douyinfe/semi-animation-react receives a total of 5,557 weekly downloads. As such, @douyinfe/semi-animation-react popularity was classified as popular.
We found that @douyinfe/semi-animation-react demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 10 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.