react-awesome-reveal 4.3.1 → 5.0.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -207
- package/dist/index.d.ts +1 -3
- package/dist/index.js +1 -1831
- package/dist/keyframes.d.ts +1 -0
- package/dist/keyframes.js +1 -0
- package/package.json +51 -58
- package/skills/migrating-from-v4/SKILL.md +95 -0
- package/dist/Reveal.d.ts +0 -69
- package/dist/animations/attention_seekers/bounce.d.ts +0 -5
- package/dist/animations/attention_seekers/flash.d.ts +0 -5
- package/dist/animations/attention_seekers/headShake.d.ts +0 -5
- package/dist/animations/attention_seekers/heartBeat.d.ts +0 -5
- package/dist/animations/attention_seekers/index.d.ts +0 -13
- package/dist/animations/attention_seekers/jello.d.ts +0 -5
- package/dist/animations/attention_seekers/pulse.d.ts +0 -5
- package/dist/animations/attention_seekers/rubberBand.d.ts +0 -5
- package/dist/animations/attention_seekers/shake.d.ts +0 -5
- package/dist/animations/attention_seekers/shakeX.d.ts +0 -5
- package/dist/animations/attention_seekers/shakeY.d.ts +0 -5
- package/dist/animations/attention_seekers/swing.d.ts +0 -5
- package/dist/animations/attention_seekers/tada.d.ts +0 -5
- package/dist/animations/attention_seekers/wobble.d.ts +0 -5
- package/dist/animations/bouncing_entrances/bounceIn.d.ts +0 -5
- package/dist/animations/bouncing_entrances/bounceInDown.d.ts +0 -5
- package/dist/animations/bouncing_entrances/bounceInLeft.d.ts +0 -5
- package/dist/animations/bouncing_entrances/bounceInRight.d.ts +0 -5
- package/dist/animations/bouncing_entrances/bounceInUp.d.ts +0 -5
- package/dist/animations/bouncing_entrances/index.d.ts +0 -5
- package/dist/animations/bouncing_exits/bounceOut.d.ts +0 -5
- package/dist/animations/bouncing_exits/bounceOutDown.d.ts +0 -5
- package/dist/animations/bouncing_exits/bounceOutLeft.d.ts +0 -5
- package/dist/animations/bouncing_exits/bounceOutRight.d.ts +0 -5
- package/dist/animations/bouncing_exits/bounceOutUp.d.ts +0 -5
- package/dist/animations/bouncing_exits/index.d.ts +0 -5
- package/dist/animations/fading_entrances/fadeIn.d.ts +0 -5
- package/dist/animations/fading_entrances/fadeInBottomLeft.d.ts +0 -5
- package/dist/animations/fading_entrances/fadeInBottomRight.d.ts +0 -5
- package/dist/animations/fading_entrances/fadeInDown.d.ts +0 -5
- package/dist/animations/fading_entrances/fadeInDownBig.d.ts +0 -5
- package/dist/animations/fading_entrances/fadeInLeft.d.ts +0 -5
- package/dist/animations/fading_entrances/fadeInLeftBig.d.ts +0 -5
- package/dist/animations/fading_entrances/fadeInRight.d.ts +0 -5
- package/dist/animations/fading_entrances/fadeInRightBig.d.ts +0 -5
- package/dist/animations/fading_entrances/fadeInTopLeft.d.ts +0 -5
- package/dist/animations/fading_entrances/fadeInTopRight.d.ts +0 -5
- package/dist/animations/fading_entrances/fadeInUp.d.ts +0 -5
- package/dist/animations/fading_entrances/fadeInUpBig.d.ts +0 -5
- package/dist/animations/fading_entrances/index.d.ts +0 -13
- package/dist/animations/fading_exits/fadeOut.d.ts +0 -5
- package/dist/animations/fading_exits/fadeOutBottomLeft.d.ts +0 -5
- package/dist/animations/fading_exits/fadeOutBottomRight.d.ts +0 -5
- package/dist/animations/fading_exits/fadeOutDown.d.ts +0 -5
- package/dist/animations/fading_exits/fadeOutDownBig.d.ts +0 -5
- package/dist/animations/fading_exits/fadeOutLeft.d.ts +0 -5
- package/dist/animations/fading_exits/fadeOutLeftBig.d.ts +0 -5
- package/dist/animations/fading_exits/fadeOutRight.d.ts +0 -5
- package/dist/animations/fading_exits/fadeOutRightBig.d.ts +0 -5
- package/dist/animations/fading_exits/fadeOutTopLeft.d.ts +0 -5
- package/dist/animations/fading_exits/fadeOutTopRight.d.ts +0 -5
- package/dist/animations/fading_exits/fadeOutUp.d.ts +0 -5
- package/dist/animations/fading_exits/fadeOutUpBig.d.ts +0 -5
- package/dist/animations/fading_exits/index.d.ts +0 -13
- package/dist/animations/flippers/flip.d.ts +0 -5
- package/dist/animations/flippers/flipInX.d.ts +0 -5
- package/dist/animations/flippers/flipInY.d.ts +0 -5
- package/dist/animations/flippers/flipOutX.d.ts +0 -5
- package/dist/animations/flippers/flipOutY.d.ts +0 -5
- package/dist/animations/flippers/index.d.ts +0 -5
- package/dist/animations/rotating_entrances/index.d.ts +0 -5
- package/dist/animations/rotating_entrances/rotateIn.d.ts +0 -5
- package/dist/animations/rotating_entrances/rotateInDownLeft.d.ts +0 -5
- package/dist/animations/rotating_entrances/rotateInDownRight.d.ts +0 -5
- package/dist/animations/rotating_entrances/rotateInUpLeft.d.ts +0 -5
- package/dist/animations/rotating_entrances/rotateInUpRight.d.ts +0 -5
- package/dist/animations/rotating_exits/index.d.ts +0 -5
- package/dist/animations/rotating_exits/rotateOut.d.ts +0 -5
- package/dist/animations/rotating_exits/rotateOutDownLeft.d.ts +0 -5
- package/dist/animations/rotating_exits/rotateOutDownRight.d.ts +0 -5
- package/dist/animations/rotating_exits/rotateOutUpLeft.d.ts +0 -5
- package/dist/animations/rotating_exits/rotateOutUpRight.d.ts +0 -5
- package/dist/animations/sliding_entrances/index.d.ts +0 -4
- package/dist/animations/sliding_entrances/slideInDown.d.ts +0 -5
- package/dist/animations/sliding_entrances/slideInLeft.d.ts +0 -5
- package/dist/animations/sliding_entrances/slideInRight.d.ts +0 -5
- package/dist/animations/sliding_entrances/slideInUp.d.ts +0 -5
- package/dist/animations/sliding_exits/index.d.ts +0 -4
- package/dist/animations/sliding_exits/slideOutDown.d.ts +0 -5
- package/dist/animations/sliding_exits/slideOutLeft.d.ts +0 -5
- package/dist/animations/sliding_exits/slideOutRight.d.ts +0 -5
- package/dist/animations/sliding_exits/slideOutUp.d.ts +0 -5
- package/dist/animations/specials/hinge.d.ts +0 -5
- package/dist/animations/specials/index.d.ts +0 -4
- package/dist/animations/specials/jackInTheBox.d.ts +0 -5
- package/dist/animations/specials/rollIn.d.ts +0 -5
- package/dist/animations/specials/rollOut.d.ts +0 -5
- package/dist/animations/zooming_entrances/index.d.ts +0 -5
- package/dist/animations/zooming_entrances/zoomIn.d.ts +0 -5
- package/dist/animations/zooming_entrances/zoomInDown.d.ts +0 -5
- package/dist/animations/zooming_entrances/zoomInLeft.d.ts +0 -5
- package/dist/animations/zooming_entrances/zoomInRight.d.ts +0 -5
- package/dist/animations/zooming_entrances/zoomInUp.d.ts +0 -5
- package/dist/animations/zooming_exits/index.d.ts +0 -5
- package/dist/animations/zooming_exits/zoomOut.d.ts +0 -5
- package/dist/animations/zooming_exits/zoomOutDown.d.ts +0 -5
- package/dist/animations/zooming_exits/zoomOutLeft.d.ts +0 -5
- package/dist/animations/zooming_exits/zoomOutRight.d.ts +0 -5
- package/dist/animations/zooming_exits/zoomOutUp.d.ts +0 -5
- package/dist/components/AttentionSeeker.d.ts +0 -12
- package/dist/components/Bounce.d.ts +0 -17
- package/dist/components/Fade.d.ts +0 -22
- package/dist/components/Flip.d.ts +0 -17
- package/dist/components/Hinge.d.ts +0 -4
- package/dist/components/JackInTheBox.d.ts +0 -4
- package/dist/components/Roll.d.ts +0 -10
- package/dist/components/Rotate.d.ts +0 -17
- package/dist/components/Slide.d.ts +0 -17
- package/dist/components/Zoom.d.ts +0 -17
- package/dist/components/index.d.ts +0 -10
- package/dist/index.cjs +0 -1846
- package/dist/utils/animations.d.ts +0 -8
- package/dist/utils/guards.d.ts +0 -2
- package/dist/utils/patterns.d.ts +0 -2
package/README.md
CHANGED
|
@@ -1,221 +1,30 @@
|
|
|
1
|
-
#
|
|
1
|
+
# react-awesome-reveal
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/react-awesome-reveal
|
|
4
|
-
[](https://bundlephobia.com/result?p=react-awesome-reveal@latest)
|
|
7
|
-
[](https://www.npmjs.com/package/react-awesome-reveal/v/latest)
|
|
8
|
-
[](https://openbase.io/js/react-awesome-reveal?utm_source=embedded&utm_medium=badge&utm_campaign=rate-badge)
|
|
3
|
+
[](https://www.npmjs.com/package/react-awesome-reveal)
|
|
4
|
+
[](https://www.npmjs.com/package/react-awesome-reveal)
|
|
5
|
+
[](https://www.npmjs.com/package/react-awesome-reveal)
|
|
9
6
|
|
|
10
|
-
|
|
11
|
-
> If you like this library, please [consider supporting its creator](https://github.com/sponsors/morellodev).
|
|
7
|
+
React Awesome Reveal is now [`@awesome-reveal/react`](https://www.npmjs.com/package/@awesome-reveal/react). Version 5 of this package re-exports it, with the same entry points:
|
|
12
8
|
|
|
13
|
-
|
|
9
|
+
| Import path | Same as |
|
|
10
|
+
| -------------------------------- | --------------------------------- |
|
|
11
|
+
| `react-awesome-reveal` | `@awesome-reveal/react` |
|
|
12
|
+
| `react-awesome-reveal/keyframes` | `@awesome-reveal/react/keyframes` |
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
- [Features](#features)
|
|
18
|
-
- [Installation](#installation)
|
|
19
|
-
- [Quick Start](#quick-start)
|
|
20
|
-
- [Supported Effects](#supported-effects)
|
|
21
|
-
- [Attention Seekers](#attention-seekers)
|
|
22
|
-
- [Props](#props)
|
|
23
|
-
- [Example](#example)
|
|
24
|
-
- [Chaining Multiple Animations](#chaining-multiple-animations)
|
|
25
|
-
- [Custom Animations](#custom-animations)
|
|
26
|
-
- [Other Props](#other-props)
|
|
27
|
-
- [Intersection Observer](#intersection-observer)
|
|
28
|
-
- [Polyfill](#polyfill)
|
|
29
|
-
- [Past Releases](#past-releases)
|
|
30
|
-
- [License](#license)
|
|
31
|
-
|
|
32
|
-
## Features
|
|
33
|
-
|
|
34
|
-
- 🎁 **Modern stack** – It is built for modern React and supports React 18
|
|
35
|
-
- 🏷 **TypeScript support** – It is written in TypeScript to improve the DX
|
|
36
|
-
- 🍃 **Lightweight** – Very little footprint on your project
|
|
37
|
-
- ⚙️ **Uses native APIs** – Intersection Observer and CSS Animations are now supported by all browsers
|
|
38
|
-
- 🚀 **Fast** – Buttery smooth experience thanks to the use of native asynchronous APIs and hardware acceleration
|
|
39
|
-
- 💅 **Fully customizable** – Define custom animations and let the library render them
|
|
40
|
-
- 💻 **SSR support** – Server Side Rendering works out-of-the-box
|
|
41
|
-
- 🌳 **Tree-shakeable** – Only the parts you use will be included in your final bundle
|
|
42
|
-
|
|
43
|
-
## Installation
|
|
44
|
-
|
|
45
|
-
To add this package as a dependency to your app, simply run
|
|
46
|
-
|
|
47
|
-
```sh
|
|
48
|
-
npm install react-awesome-reveal @emotion/react --save
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
or, if you are using Yarn:
|
|
52
|
-
|
|
53
|
-
```sh
|
|
54
|
-
yarn add react-awesome-reveal @emotion/react
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
or, if you are using PNPM (as I strongly suggest):
|
|
58
|
-
|
|
59
|
-
```sh
|
|
60
|
-
pnpm add react-awesome-reveal @emotion/react
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
## Quick Start
|
|
64
|
-
|
|
65
|
-
Import effects from [React Awesome Reveal](https://www.npmjs.com/package/react-awesome-reveal) to your React component, for example the `Fade` effect:
|
|
66
|
-
|
|
67
|
-
```js
|
|
68
|
-
import { Fade } from "react-awesome-reveal";
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
Then simply wrap the components you want to animate:
|
|
72
|
-
|
|
73
|
-
```jsx
|
|
74
|
-
<Fade>
|
|
75
|
-
<p>I will gently appear as I enter the viewport</p>
|
|
76
|
-
</Fade>
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
## Supported Effects
|
|
80
|
-
|
|
81
|
-
The effects currently supported are `Bounce`, `Fade`, `Flip`, `Hinge`, `JackInTheBox`, `Roll`, `Rotate`, `Slide` and `Zoom`. Refer to the [Animate.css](https://animate.style) documentation for the details.
|
|
82
|
-
|
|
83
|
-
### Attention Seekers
|
|
84
|
-
|
|
85
|
-
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”`.
|
|
86
|
-
|
|
87
|
-
Again, refer to the [Animate.css](https://animate.style) documentation for the details.
|
|
88
|
-
|
|
89
|
-
### Props
|
|
90
|
-
|
|
91
|
-
You can pass the following props to the animation components to customize the behavior:
|
|
92
|
-
|
|
93
|
-
| Prop | Description | Values | Default |
|
|
94
|
-
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
|
|
95
|
-
| `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` |
|
|
96
|
-
| `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) |
|
|
97
|
-
| `direction` | Origin of the animation (where applicable). | Usually `"down"`, `"left"`, `"right"` or `"up"`, with some exceptions documented in the code | `undefined` |
|
|
98
|
-
| `delay` | Time to wait before the animation starts (in milliseconds). | `number` | `0` |
|
|
99
|
-
| `duration` | The animation duration (milliseconds). | `number` | `1000` |
|
|
100
|
-
| `fraction` | How much an element should be in viewport before the animation is triggered. | `number` between `0` and `1` | `0` |
|
|
101
|
-
| `triggerOnce` | Specifies if the animation should run only once or everytime an element enters/exits/re-enters the viewport. | `true` or `false` | `false` |
|
|
102
|
-
| `className` | The class names to add to the container element. | `string` | `undefined` |
|
|
103
|
-
| `style` | The inline styles to add to the container element. | `React.CSSProperties` | `undefined` |
|
|
104
|
-
| `childClassName` | The class names to add to the child element. | `string` | `undefined` |
|
|
105
|
-
| `childStyle` | The inline styles to add to the child element. | `React.CSSProperties` | `undefined` |
|
|
106
|
-
| `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` |
|
|
107
|
-
|
|
108
|
-
### Example
|
|
109
|
-
|
|
110
|
-
To trigger the animation only the first time an element enters the viewport:
|
|
111
|
-
|
|
112
|
-
```jsx
|
|
113
|
-
<Slide triggerOnce>
|
|
114
|
-
<p>I will animate only the first time you see me</p>
|
|
115
|
-
</Slide>
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
### Chaining Multiple Animations
|
|
119
|
-
|
|
120
|
-
To chain together multiple animations, set the `cascade` prop to `true`:
|
|
121
|
-
|
|
122
|
-
```jsx
|
|
123
|
-
<Fade cascade>
|
|
124
|
-
<p>I enter first...</p>
|
|
125
|
-
<p>...then comes my turn...</p>
|
|
126
|
-
<p>...and finally you see me!</p>
|
|
127
|
-
</Fade>
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
Play with the `damping` prop to alter the delay by which each child will progressively appear:
|
|
131
|
-
|
|
132
|
-
```tsx
|
|
133
|
-
<Fade cascade damping={0.1}>
|
|
134
|
-
<p>I enter first...</p>
|
|
135
|
-
<p>...then comes my turn...</p>
|
|
136
|
-
<p>...and finally you see me!</p>
|
|
137
|
-
</Fade>
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
## Custom Animations
|
|
141
|
-
|
|
142
|
-
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:
|
|
143
|
-
|
|
144
|
-
```jsx
|
|
145
|
-
import React from "react";
|
|
146
|
-
import Reveal from "react-awesome-reveal";
|
|
147
|
-
import { keyframes } from "@emotion/react";
|
|
148
|
-
|
|
149
|
-
const customAnimation = keyframes`
|
|
150
|
-
from {
|
|
151
|
-
opacity: 0;
|
|
152
|
-
transform: translate3d(-200px, -100px, 0);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
to {
|
|
156
|
-
opacity: 1;
|
|
157
|
-
transform: translate3d(0, 0, 0);
|
|
158
|
-
}
|
|
159
|
-
`;
|
|
160
|
-
|
|
161
|
-
function CustomAnimation({ children }) {
|
|
162
|
-
return <Reveal keyframes={customAnimation}>{children}</Reveal>;
|
|
163
|
-
}
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
If no `keyframes` prop is passed, the default rendered animation is a fading entrance from the left (equivalent to `<Fade direction="left">...</Fade>`).
|
|
167
|
-
|
|
168
|
-
### Other Props
|
|
169
|
-
|
|
170
|
-
You can also pass these props to `Reveal`:
|
|
171
|
-
|
|
172
|
-
- `cascade`
|
|
173
|
-
- `damping`
|
|
174
|
-
- `delay`
|
|
175
|
-
- `duration`
|
|
176
|
-
- `fraction`
|
|
177
|
-
- `triggerOnce`
|
|
178
|
-
- `className` and `childClassName`
|
|
179
|
-
- `style` and `childStyle`
|
|
180
|
-
- `onVisibilityChange`
|
|
181
|
-
|
|
182
|
-
## Intersection Observer
|
|
183
|
-
|
|
184
|
-
[Intersection Observer](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API) is the API used to determine if an element is inside the viewport or not. [Browser support](http://caniuse.com/#feat=intersectionobserver) is really good – with [Safari adding support in 12.1](https://webkit.org/blog/8718/new-webkit-features-in-safari-12-1), all major browsers now support Intersection Observers natively.
|
|
185
|
-
|
|
186
|
-
If you need to support old browsers, add the polyfill for the Intersection Observer API.
|
|
187
|
-
|
|
188
|
-
### Polyfill
|
|
189
|
-
|
|
190
|
-
You can add the [polyfill](https://www.npmjs.com/package/intersection-observer) directly or use a service like [polyfill.io](https://polyfill.io/v2/docs) to add it when needed.
|
|
14
|
+
Install `@awesome-reveal/react` in new projects:
|
|
191
15
|
|
|
192
16
|
```sh
|
|
193
|
-
|
|
17
|
+
pnpm add @awesome-reveal/react
|
|
194
18
|
```
|
|
195
19
|
|
|
196
|
-
|
|
20
|
+
## Migrating from v4
|
|
197
21
|
|
|
198
|
-
|
|
199
|
-
import "intersection-observer";
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
If you are using Webpack (or similar) you could use [dynamic imports](https://webpack.js.org/guides/code-splitting/#dynamic-imports) to load the polyfill only if needed. A basic implementation could look something like this:
|
|
203
|
-
|
|
204
|
-
```javascript
|
|
205
|
-
/**
|
|
206
|
-
* Do feature detection, to figure out which polyfills needs to be imported.
|
|
207
|
-
**/
|
|
208
|
-
async function loadPolyfills() {
|
|
209
|
-
if (typeof window.IntersectionObserver === "undefined") {
|
|
210
|
-
await import("intersection-observer");
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
```
|
|
22
|
+
Version 5 is not compatible with v4. It has no effect components, such as `Fade` or `Slide`, and it does not use Emotion. Read [Migrating from v4](https://github.com/awesome-reveal/awesome-reveal/tree/next/packages/react#migrating-from-v4).
|
|
214
23
|
|
|
215
|
-
|
|
24
|
+
This package includes the `migrating-from-v4` agent skill, which helps a coding agent do the migration.
|
|
216
25
|
|
|
217
|
-
|
|
26
|
+
The v4 documentation is in the [README of `react-awesome-reveal@4.3.1`](https://github.com/awesome-reveal/awesome-reveal/blob/react-awesome-reveal%404.3.1/README.md).
|
|
218
27
|
|
|
219
28
|
## License
|
|
220
29
|
|
|
221
|
-
|
|
30
|
+
MIT
|
package/dist/index.d.ts
CHANGED