Socket
Socket
Sign inDemoInstall

rc-motion

Package Overview
Dependencies
10
Maintainers
4
Versions
40
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    rc-motion

React lifecycle controlled motion library


Version published
Weekly downloads
1.6M
increased by3.62%
Maintainers
4
Install size
635 kB
Created
Weekly downloads
 

Package description

What is rc-motion?

The rc-motion npm package is a React component library designed to handle animations and transitions in a React application. It provides a simple and powerful way to implement various animations, including entering, leaving, and switching animations with customizable options for timing, easing, and more.

What are rc-motion's main functionalities?

Basic Animation

This code demonstrates how to use rc-motion to create a basic fade-in animation. The `CSSMotion` component is used with the `visible` prop set to true and a `motionName` provided to define the animation type. The children function renders the animated element with the appropriate style and className applied.

{"import React from 'react'; import CSSMotion from 'rc-motion'; function FadeInExample() { return ( <CSSMotion visible={true} motionName='fade'> {({ style, className }) => ( <div style={style} className={className}>Fade In Animation</div> )} </CSSMotion> ); } export default FadeInExample;"}

Custom Animation

This example shows how to create a custom slide animation using rc-motion. The `CSSMotion` component is configured with custom functions for `onAppearStart` and `onAppearActive` to control the animation's start and active states, respectively. This allows for more complex animations beyond predefined ones.

{"import React from 'react'; import CSSMotion from 'rc-motion'; function SlideAnimationExample() { return ( <CSSMotion visible={true} motionName='slide' motionAppear={true} onAppearStart={() => ({ height: 0 })} onAppearActive={() => ({ height: 'auto' })} > {({ style, className }) => ( <div style={style} className={className}>Slide Animation</div> )} </CSSMotion> ); } export default SlideAnimationExample;"}

Other packages similar to rc-motion

Readme

Source

rc-motion

NPM version npm download build status Codecov Dependencies DevDependencies bundle size

React lifecycle controlled motion library.

Live Demo

https://react-component.github.io/motion/

Install

rc-motion

Example

import CSSMotion from 'rc-motion';

export default ({ visible }) => (
  <CSSMotion visible={visible} motionName="my-motion">
    {({ className, style }) => <div className={className} style={style} />}
  </CSSMotion>
);

API

CSSMotion

PropertyTypeDefaultDescription
motionNamestring-Config motion name, will dynamic update when status changed
visiblebooleantrueTrigger motion events
motionAppearbooleantrueUse motion when appear
motionEnterbooleantrueUse motion when enter
motionLeavebooleantrueUse motion when leave
motionLeaveImmediatelyboolean-Will trigger leave even on mount
motionDeadlinenumber-Trigger motion status change even when motion event not fire
removeOnLeavebooleantrueRemove element when motion leave end
leavedClassNamestring-Set leaved element className
onAppearStart(HTMLElement, Event) => CSSProperties | void;-Trigger when appear start, return style will patch to element
onEnterStart(HTMLElement, Event) => CSSProperties | void;-Trigger when enter start, return style will patch to element
onLeaveStart(HTMLElement, Event) => CSSProperties | void;-Trigger when leave start, return style will patch to element
onAppearActive(HTMLElement, Event) => CSSProperties | void;-Trigger when appear active, return style will patch to element
onEnterActive(HTMLElement, Event) => CSSProperties | void;-Trigger when enter active, return style will patch to element
onLeaveActive(HTMLElement, Event) => CSSProperties | void;-Trigger when leave active, return style will patch to element
onAppearEnd(HTMLElement, Event) => boolean | void;-Trigger when appear end, will not finish when return false
onEnterEnd(HTMLElement, Event) => boolean | void;-Trigger when enter end, will not finish when return false
onLeaveEnd(HTMLElement, Event) => boolean | void;-Trigger when leave end, will not finish when return false

CSSMotionList

extends all the props from CSSMotion

PropertyTypeDefaultDescription
keysReact.Key[]-Motion list keys
componentstring | React.ComponentTypedivwrapper component

Development

npm install
npm start

License

rc-motion is released under the MIT license.

Keywords

FAQs

Last updated on 05 Sep 2023

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc