Gathering detailed insights and metrics for react-awesome-reveal-triggerfix
Gathering detailed insights and metrics for react-awesome-reveal-triggerfix
Gathering detailed insights and metrics for react-awesome-reveal-triggerfix
Gathering detailed insights and metrics for react-awesome-reveal-triggerfix
React components to add reveal animations using the Intersection Observer API and CSS Animations.
npm install react-awesome-reveal-triggerfix
Typescript
Module System
Node Version
NPM Version
react-awesome-reveal@4.3.1
Published on 21 Dec 2024
react-awesome-reveal@4.3.0
Published on 21 Dec 2024
react-awesome-reveal@4.2.14
Published on 01 Aug 2024
react-awesome-reveal@4.2.13
Published on 23 Jul 2024
react-awesome-reveal@4.2.12
Published on 16 Jun 2024
react-awesome-reveal@4.2.11
Published on 19 May 2024
TypeScript (98.79%)
HTML (0.72%)
JavaScript (0.49%)
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
1,160 Stars
477 Commits
43 Forks
5 Watching
2 Branches
6 Contributors
Latest Version
4.2.5
Package Id
react-awesome-reveal-triggerfix@4.2.5
Unpacked Size
286.93 kB
Size
38.16 kB
File Count
121
NPM Version
9.6.4
Node Version
18.16.0
Publised On
22 Sept 2023
Cumulative downloads
Total Downloads
Last day
0%
0
Compared to previous day
Last week
0%
0
Compared to previous week
Last month
0%
0
Compared to previous month
Last year
0%
0
Compared to previous year
2
2
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.
To add this package as a dependency to your app, simply run
1npm install react-awesome-reveal @emotion/react --save
or, if you are using Yarn:
1yarn add react-awesome-reveal @emotion/react
or, if you are using PNPM (as I strongly suggest):
1pnpm add react-awesome-reveal @emotion/react
Import effects from React Awesome Reveal to your React component, for example the Fade
effect:
1import { Fade } from "react-awesome-reveal";
Then simply wrap the components you want to animate:
1<Fade> 2 <p>I will gently appear as I enter the viewport</p> 3</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 |
childClassName | The class names to add to the child element. | string | undefined |
childStyle | The inline styles to add to the child element. | React.CSSProperties | undefined |
onVisibilityChange | Callback executed when the element enters or leaves the viewport. If more than one element is being animated, this function is called on each element. | (inView: boolean, entry: IntersectionObserverEntry) => void | undefined |
To trigger the animation only the first time an element enters the viewport:
1<Slide triggerOnce> 2 <p>I will animate only the first time you see me</p> 3</Slide>
To chain together multiple animations, set the cascade
prop to true
:
1<Fade cascade> 2 <p>I enter first...</p> 3 <p>...then comes my turn...</p> 4 <p>...and finally you see me!</p> 5</Fade>
Play with the damping
prop to alter the delay by which each child will progressively appear:
1<Fade cascade damping={0.1}> 2 <p>I enter first...</p> 3 <p>...then comes my turn...</p> 4 <p>...and finally you see me!</p> 5</Fade>
Starting from version 3.2.0, you can define custom animations! Simply import the Reveal
component (which is the default export of the library – give it the name you want) and pass it a keyframes
prop:
1import React from "react"; 2import Reveal from "react-awesome-reveal"; 3import { keyframes } from "@emotion/react"; 4 5const customAnimation = keyframes` 6 from { 7 opacity: 0; 8 transform: translate3d(-200px, -100px, 0); 9 } 10 11 to { 12 opacity: 1; 13 transform: translate3d(0, 0, 0); 14 } 15`; 16 17function CustomAnimation({ children }) { 18 return <Reveal keyframes={customAnimation}>{children}</Reveal>; 19}
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
onVisibilityChange
Intersection Observer is the API used to determine if an element is inside the viewport or not. Browser support is really good – with Safari adding support in 12.1, all major browsers now support Intersection Observers natively.
If you need to support old browsers, add the polyfill for the Intersection Observer API.
You can add the polyfill directly or use a service like polyfill.io to add it when needed.
1yarn add intersection-observer
Then import it in your app:
1import "intersection-observer";
If you are using Webpack (or similar) you could use dynamic imports to load the polyfill only if needed. A basic implementation could look something like this:
1/** 2 * Do feature detection, to figure out which polyfills needs to be imported. 3 **/ 4async function loadPolyfills() { 5 if (typeof window.IntersectionObserver === "undefined") { 6 await import("intersection-observer"); 7 } 8}
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.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
4 commit(s) and 3 issue activity found in the last 90 days -- score normalized to 5
Reason
8 existing vulnerabilities detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 1
Details
Reason
Found 0/23 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Score
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More