Security News
Highlights from the 2024 Rails Community Survey
A record 2,709 developers participated in the 2024 Ruby on Rails Community Survey, revealing key tools, practices, and trends shaping the Rails ecosystem.
react-smooth
Advanced tools
The react-smooth package provides a set of tools to implement smooth animations in React applications. It allows developers to animate the appearance, disappearance, and property changes of components with ease. The package offers a high-level API for common animations, making it straightforward to add smooth transitions without delving into the complexities of animation libraries.
Fade In Animation
This feature allows elements to fade in smoothly. The `fadeIn` component wraps any content that should appear with a fading effect.
import { fadeIn } from 'react-smooth';
function FadeInExample() {
return (
<fadeIn>
<div>Content to fade in</div>
</fadeIn>
);
}
Animate on Property Change
This feature enables animation between different states based on property changes. The `Animate` component is used to transition between a start and end state, such as changing the opacity.
import { Animate } from 'react-smooth';
function AnimateOnChangeExample() {
return (
<Animate start={{ opacity: 0 }} end={{ opacity: 1 }}>
<div>Content that changes opacity</div>
</Animate>
);
}
React-motion is a popular library for animations in React. It offers a powerful spring configuration to create fluid animations. Compared to react-smooth, react-motion provides more control over the physics of the animations, making it suitable for complex animations but potentially overkill for simple fades or transitions.
React-spring is another animation library for React that focuses on spring physics to create natural motion. It supports a wide range of animations, including transitions, parallax effects, and more. React-spring is similar to react-smooth in ease of use but offers more extensive customization options and supports more complex animations.
react-smooth is a animation library work on React.
npm install --save react-smooth
ordinary animation
<Animate to="0" attributeName="opacity">
<div />
</Animate>
steps animation
const steps = [{
style: {
opacity: 0,
},
moment: 400,
}, {
style: {
opacity: 1,
transform: 'translate(0, 0)',
},
moment: 1000,
}, {
style: {
transform: 'translate(100px, 100px)',
},
moment: 1200,
}];
<Animate steps={steps}>
<div />
</Animate>
children can be a function
<Animate from={{ opacity: 0 }}
to={{ opacity: 1 }}
easing="ease-in"
>
{
({ opacity }) => <div style={{ opacity }}></div>
}
</Animate>
you can configure js timing function
const easing = configureBezier(0.1, 0.1, 0.5, 0.8);
const easing = configureSpring({ stiff: 170, damping: 20 });
group animation
const appear = {
from: 0,
to: 1,
attributeName: 'opacity',
};
const leave = {
steps: [{
moment: 0,
style: {
transform: 'translateX(0)',
},
}, {
moment: 1000,
style: {
transform: 'translateX(300)',
height: 50,
},
}, {
moment: 2000,
style: {
height: 0,
},
}]
}
<AnimateGroup appear={appear} leave={leave}>
{ list }
</AnimateGroup>
name | type | default | description |
---|---|---|---|
from | string or object | '' | set the initial style of the children |
to | string or object | '' | set the final style of the children |
canBegin | boolean | true | whether the animation is start |
begin | number | 0 | animation delay time |
duration | number | 1000 | animation duration |
steps | array | [] | animation keyframes |
onAnimationEnd | function | () => {} | called when animation finished |
attributeName | string | '' | style property |
easing | string | 'ease' | the animation timing function, support css timing function temporary |
isActive | boolean | true | whether the animation is active |
children | element | support only child temporary |
name | type | default | description |
---|---|---|---|
appear | object | undefined | configure element appear animation |
enter | object | undefined | configure element appear animation |
leave | object | undefined | configure element appear animation |
Copyright (c) 2015-2016 Recharts Group
0.0.7 / 2016-02-04
FAQs
react animation library
The npm package react-smooth receives a total of 1,929,341 weekly downloads. As such, react-smooth popularity was classified as popular.
We found that react-smooth demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 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
A record 2,709 developers participated in the 2024 Ruby on Rails Community Survey, revealing key tools, practices, and trends shaping the Rails ecosystem.
Security News
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.