![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
react-awesome-reveal
Advanced tools
React components to add reveal animations using Intersection Observer API and CSS Animations.
React Awesome Reveal is a library for React apps written in TypeScript that adds reveal animations using the Intersection Observer API to detect when the elements appear in the viewport. Animations are internally provided by Emotion and implemented as CSS Animations to benefit from hardware acceleration.
You can find a demo website here.
To add this package as a dependency to your app, simply run
npm install react-awesome-reveal --save
or, if you are using Yarn (as I strongly suggest):
yarn add react-awesome-reveal
Import effects from React Awesome Reveal to your React component, for example the Fade
effect:
import { Fade } from "react-awesome-reveal";
Then simply wrap the components you want to animate:
<Fade>
<p>I will gently appear as I enter the viewport</p>
</Fade>
The effects currently supported are Bounce
, Fade
, Flip
, Hinge
, JackInTheBox
, Roll
, Rotate
, Slide
and Zoom
. Refer to the Animate.css documentation for the details.
Since version 3, attention seeker animations are wrapped by the AttentionSeeker
component, which accepts a prop called effect
that specifies the animation to render (defaults to "bounce”
). The supported effects are: ”bounce"
, "flash"
, "headShake”
, "heartBeat"
, "jello”
, "pulse"
, "rubberBand"
, “shake”
, “shakeX"
, "shakeY”
, "swing”
, "tada"
and “wobble”
.
Again, refer to the Animate.css documentation for the details.
You can pass the following props to the animation components to customize the behavior:
Prop | Description | Values | Default |
---|---|---|---|
cascade | If set, each child of a reveal animation automatically get assigned a delay that takes into account their predecessor (child i enters the viewport after i * delay * damping milliseconds) – useful for animating list items. | true or false | false |
damping | Factor that affects the delay that each animated component in a cascade animation will be assigned. If damping = 1 then the delay will be equal to the animation duration; if damping < 1 then the delay will be lower than the animation duration; if damping > 1 then the delay will be greater than the animation duration. | number | 0.5 (meaning that the delay will be half of the animation duration) |
direction | Origin of the animation (where applicable). | Usually "down" , "left" , "right" or "up" , with some exceptions documented in the code | undefined |
delay | Time to wait before the animation starts (in milliseconds). | number | 0 |
duration | The animation duration (milliseconds). | number | 1000 |
fraction | How much an element should be in viewport before the animation is triggered. | number between 0 and 1 | 0 |
triggerOnce | Specifies if the animation should run only once or everytime an element enters/exits/re-enters the viewport. | true or false | false |
className | The class names to add to the container element. | string | undefined |
style | The inline styles to add to the container element. | React.CSSProperties | undefined |
childCassName | The class names to add to the child element. | string | undefined |
childStyle | The inline styles to add to the child element. | React.CSSProperties | undefined |
To trigger the animation only the first time an element enters the viewport:
<Slide triggerOnce>
<p>I will animate only the first time you see me</p>
</Slide>
To chain together multiple animations, set the cascade
prop to true
:
<Fade cascade>
<p>I enter first...</p>
<p>...then comes my turn...</p>
<p>...and finally you see me!</p>
</Fade>
This is almost equivalent to
<Fade>
<p>I enter first...</p>
</Fade>
<Fade delay={1000}>
<p>...then comes my turn...</p>
</Fade>
<Fade delay={2000}>
<p>...and finally you see me!</p>
</Fade>
with the exception that, since each Fade
component creates an isolated visibility context, in the second snippet every p
will be shown only if they are inside the viewport (after the specified delay).
Starting from version 3.2.0, you can define custom animations! Simply import the Reveal
component (which is the default export of the library) and pass it a keyframes
prop:
import React from "react";
import Reveal from "react-awesome-reveal";
import { keyframes } from "@emotion/core";
const customAnimation = keyframes`
from {
opacity: 0;
transform: translate3d(-200px, -100px, 0);
}
to {
opacity: 1;
transform: translate3d(0, 0, 0);
}
`;
function MyAnimatedComponent({children}) {
return (
<Reveal keyframes={customAnimation}>
{children}
</Reveal>;
);
}
If no keyframes
prop is passed, the default rendered animation is a fading entrance from the left (equivalent to <Fade direction="left">...</Fade>
).
You can also pass these props to Reveal
:
cascade
damping
delay
duration
fraction
triggerOnce
className
and childClassName
style
and childStyle
To see the documentation for previous versions, navigate through past tags in the GitHub's project repository and read the README for that specific version.
Project source code is licensed under the MIT license. You are free to fork this repository, edit the code, share and use it both for non-commercial and commercial purposes.
FAQs
React components to add reveal animations using the Intersection Observer API and CSS Animations.
The npm package react-awesome-reveal receives a total of 29,014 weekly downloads. As such, react-awesome-reveal popularity was classified as popular.
We found that react-awesome-reveal demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.