Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@douyinfe/semi-animation-react

Package Overview
Dependencies
Maintainers
0
Versions
444
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@douyinfe/semi-animation-react

motion library for semi-ui-react

  • 2.72.0-beta.0
  • beta
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.5K
decreased by-12.7%
Maintainers
0
Weekly downloads
 
Created
Source

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.

Install

npm install @douyinfe/semi-animation-react

Usage

Transition Component

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>
  );
}

Props

NameTypeRequiredDefaultDescription
fromObjectYInitial state
enterObjectYShow the end state of the animation, but also the initial state of the exit animation
leaveObjectYExit the termination state of the animation
stateEnum 'enter', 'leave'N''Current state
willEnterFunctionN()=> {}The callback function before the enter animation starts
didEnterFunctionN()=> {}The callback function before the animation ends
willLeaveFunctionN()=> {}The callback function before the exit animation starts
didLeaveFunctionN()=> {}The callback function before the exit animation ends
onStartFunctionN()=> {}The callback function before animation starts,including enter and exit
onRestFunctionN()=> {}The callback function before animation ends,including enter and exit
configConfigTypeN{}Additional animation parameters

config

NameTypeDefaultDescription
durationNumber1000Animation duration.If this parameter is passed in, the easing function of the animation will use easing or linear function,unit: ms
easingFunction|StringEasing 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
tensionNumber170Tension, used for spring easing function
frictionNumber14Friction, used for spring easing function

Keywords

FAQs

Package last updated on 16 Dec 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc