Security News
npm Updates Search Experience with New Objective Sorting Options
npm has a revamped search experience with new, more transparent sorting options—Relevance, Downloads, Dependents, and Publish Date.
react-animated-components
Advanced tools
Because animations should be as easy as <Rotate>🥧</Rotate>
Built with Typescript. Just one dependency (styled-components
💅).
npm install --save react-animated-components
import { Rotate } from 'react-animated-components'
/** Pie is boring... let's animate it! **/
const BoringPie = () => <span>🥧</span>
/** Pie is more delicious when it's rotating **/
const RotatingPie = () => {
return (
<Rotate>
<BoringPie />
</Rotate>
)
}
Scroll down for more examples!
jtschoonhoven.github.io/react-animated-components
<Rotate>
Props:
ccw
[boolean
]: If true, rotates counter-clockwise (default false)Sub-components:
<RotateCw>
<RotateCcw>
<Fade>
Props:
out
[boolean
]: If true, fades out and exits the DOM (default false)Sub-components:
<FadeIn>
<FadeOut>
<Slide>
Props:
out
[boolean
]: If true, slides out and exits the DOM (default false)fade
[boolean
]: If true, adds a fade animationup
[boolean
]: Slide updown
[boolean
]: Slide downleft
[boolean
]: Slide leftright
[boolean
]: Slide rightdirection
["up" | "down" | "left" | "right"
]: Slide direction, an alternative to boolean direction propsSub-components:
<SlideInDown>
<SlideInUp>
<SlideInLeft>
<SlideInRight>
<SlideOutDown>
<SlideOutUp>
<SlideOutLeft>
<SlideOutRight>
Animated components all accept the following optional properties.
active
[boolean
]: Controls when the animation begins. Except for exit animations, this defaults to true and animations begin automatically on mount. Exit animations do not run until active
is set explicitly.
delayMs
[number
]: Delays the animation start by the given number of milliseconds.
durationMs
[number
]: The total duration (in milliseconds) of one iteration of the animation.
timingFunc
[string
]: Defines how animations progress through each cycle. Accepts any valid value of the animation-timing-function
CSS property.
iterations
[number | "infinite"
]: The number of times to loop the animation, or "infinite".
inline
[boolean
]: Toggle the display mode from display:block
(the default) to display:inline-block
. Inline may be more appropriate for animating icons, or for anything that appears inside a text block. NEVER override this to display:inline
as these can't be animated.
onActive
[() => void
]: Callback function, called when animation begins. Useful for chaining delayed animations.
onComplete
[() => void
]: Callback function, called when animation is complete. Useful for garbage collecting components that have exited, or for composing complex chains of effects.
childAnimation
[React.FC<BaseAnimationProps>
]: Wrap another animated component inside the current animation. Both animations will receive the same props. This can be a nice way to reduce boilerplate when combining animations with identical props.
parentAnimation
[React.FC<BaseAnimationProps>
]: Same as the childAnimation
prop, but the current component becomes the child of the new parent.
import { Rotate } from 'react-animated-components'
import { FadeIn } from 'react-animated-components'
// Create a composite effect that fades in a rotating pie
const ComposedFadeInAndRotate = () => {
return (
<FadeIn>
<Rotate>🥧</Rotate>
</FadeIn>
)
}
// ...or with `childAnimation` prop
const FadeInAndRotateChildAnimation = ({ children }) => {
return <FadeIn childAnimation={Rotate}>🥧</FadeIn>
}
import { SlideInDown } from 'react-animated-components'
import { FadeOut } from 'react-animated-components'
// Slide in a pie from above, then fade out after 3 seconds
const SlideInAndFadeout = () => {
return (
<FadeOut delayMs={3000}>
<SlideInDown durationMs={500}>🥧</SlideInDown>
</FadeOut>
)
}
import { SlideInDown } from 'react-animated-components'
import { FadeOut } from 'react-animated-components'
// Wait for the slide entrance to complete before exiting
const SlideInAndFadeout = () => {
const [didEnter, setDidEnter] = React.useState(false)
const onDidEnter = () => setDidEnter(true)
return (
<FadeOut active={didEnter}>
<SlideInDown onComplete={onDidEnter}>🥧</SlideInDown>
</FadeOut>
)
}
import { keyframes } from 'styled-components'
import { animationFactory } from 'react-animated-components'
const myKeyframes = keyframes`
from { transform: rotate(359deg); }
to { transform: rotate(0deg); }
`
// Use the animationFactory to create a reausable animated component
const CustomAnimation = animationFactory({ keyframes: myKeyframes })
// Use custom animations just like any other animated component
const UseCustomAnimation = () => {
return <CustomAnimation durationMs={500}>🥧</CustomAnimation>
}
FAQs
Easy-as-pie CSS animations for React
The npm package react-animated-components receives a total of 20 weekly downloads. As such, react-animated-components popularity was classified as not popular.
We found that react-animated-components demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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.
Security News
npm has a revamped search experience with new, more transparent sorting options—Relevance, Downloads, Dependents, and Publish Date.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.