react-awesome-reveal 4.0.0 → 4.1.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 +13 -18
- package/dist/{types.d.ts → index.d.ts} +43 -32
- package/dist/index.js +2089 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2055 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +13 -15
- package/dist/main.js +0 -2125
- package/dist/main.js.map +0 -1
- package/dist/module.js +0 -2117
- package/dist/module.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -7,12 +7,11 @@
|
|
|
7
7
|
[](https://www.npmjs.com/package/react-awesome-reveal/v/latest)
|
|
8
8
|
[](https://openbase.io/js/react-awesome-reveal?utm_source=embedded&utm_medium=badge&utm_campaign=rate-badge)
|
|
9
9
|
|
|
10
|
-
[React Awesome Reveal](https://
|
|
10
|
+
[React Awesome Reveal](https://react-awesome-reveal.morello.dev) 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](https://emotion.sh) and implemented as CSS Animations to benefit from hardware acceleration.
|
|
11
11
|
|
|
12
12
|
## Table Of Contents
|
|
13
13
|
|
|
14
14
|
- [Features](#features)
|
|
15
|
-
- [Demo](#demo)
|
|
16
15
|
- [Installation](#installation)
|
|
17
16
|
- [Quick Start](#quick-start)
|
|
18
17
|
- [Supported Effects](#supported-effects)
|
|
@@ -46,12 +45,18 @@ To add this package as a dependency to your app, simply run
|
|
|
46
45
|
npm install react-awesome-reveal @emotion/react --save
|
|
47
46
|
```
|
|
48
47
|
|
|
49
|
-
or, if you are using Yarn
|
|
48
|
+
or, if you are using Yarn:
|
|
50
49
|
|
|
51
50
|
```sh
|
|
52
51
|
yarn add react-awesome-reveal @emotion/react
|
|
53
52
|
```
|
|
54
53
|
|
|
54
|
+
or, if you are using PNPM (as I strongly suggest):
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
pnpm add react-awesome-reveal @emotion/react
|
|
58
|
+
```
|
|
59
|
+
|
|
55
60
|
## Quick Start
|
|
56
61
|
|
|
57
62
|
Import effects from [React Awesome Reveal](https://www.npmjs.com/package/react-awesome-reveal) to your React component, for example the `Fade` effect:
|
|
@@ -119,22 +124,16 @@ To chain together multiple animations, set the `cascade` prop to `true`:
|
|
|
119
124
|
</Fade>
|
|
120
125
|
```
|
|
121
126
|
|
|
122
|
-
|
|
127
|
+
Play with the `damping` prop to alter the delay by which each child will progressively appear:
|
|
123
128
|
|
|
124
|
-
```
|
|
125
|
-
<Fade>
|
|
129
|
+
```tsx
|
|
130
|
+
<Fade cascade damping={0.1}>
|
|
126
131
|
<p>I enter first...</p>
|
|
127
|
-
</Fade>
|
|
128
|
-
<Fade delay={1000}>
|
|
129
132
|
<p>...then comes my turn...</p>
|
|
130
|
-
</Fade>
|
|
131
|
-
<Fade delay={2000}>
|
|
132
133
|
<p>...and finally you see me!</p>
|
|
133
134
|
</Fade>
|
|
134
135
|
```
|
|
135
136
|
|
|
136
|
-
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).
|
|
137
|
-
|
|
138
137
|
## Custom Animations
|
|
139
138
|
|
|
140
139
|
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:
|
|
@@ -156,12 +155,8 @@ const customAnimation = keyframes`
|
|
|
156
155
|
}
|
|
157
156
|
`;
|
|
158
157
|
|
|
159
|
-
function
|
|
160
|
-
return
|
|
161
|
-
<Reveal keyframes={customAnimation}>
|
|
162
|
-
{children}
|
|
163
|
-
</Reveal>;
|
|
164
|
-
);
|
|
158
|
+
function CustomAnimation({ children }) {
|
|
159
|
+
return <Reveal keyframes={customAnimation}>{children}</Reveal>;
|
|
165
160
|
}
|
|
166
161
|
```
|
|
167
162
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Interpolation, Theme } from
|
|
2
|
-
import { Keyframes } from
|
|
3
|
-
|
|
1
|
+
import { Interpolation, Theme } from '@emotion/react';
|
|
2
|
+
import { Keyframes } from '@emotion/serialize';
|
|
3
|
+
|
|
4
|
+
interface RevealProps {
|
|
4
5
|
/**
|
|
5
6
|
* Stagger its children animations.
|
|
6
7
|
* @default false
|
|
@@ -70,18 +71,20 @@ export interface RevealProps {
|
|
|
70
71
|
*/
|
|
71
72
|
onVisibilityChange?(inView: boolean, entry: IntersectionObserverEntry): void;
|
|
72
73
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
declare const Reveal: React.FC<RevealProps>;
|
|
75
|
+
|
|
76
|
+
declare type AttentionSeekerEffect = "bounce" | "flash" | "headShake" | "heartBeat" | "jello" | "pulse" | "rubberBand" | "shake" | "shakeX" | "shakeY" | "swing" | "tada" | "wobble";
|
|
77
|
+
interface AttentionSeekerProps extends Omit<RevealProps, "keyframes" | "css"> {
|
|
76
78
|
/**
|
|
77
79
|
* The animation effect to use for this attention seeker.
|
|
78
80
|
* @default "bounce"
|
|
79
81
|
*/
|
|
80
82
|
effect?: AttentionSeekerEffect;
|
|
81
83
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
84
|
+
declare const AttentionSeeker: React.FC<AttentionSeekerProps>;
|
|
85
|
+
|
|
86
|
+
declare type BounceDirection = "down" | "left" | "right" | "up";
|
|
87
|
+
interface BounceProps extends Omit<RevealProps, "keyframes" | "css"> {
|
|
85
88
|
/**
|
|
86
89
|
* Origin of the animation.
|
|
87
90
|
* @default undefined
|
|
@@ -93,9 +96,10 @@ export interface BounceProps extends Omit<RevealProps, "keyframes" | "css"> {
|
|
|
93
96
|
*/
|
|
94
97
|
reverse?: boolean;
|
|
95
98
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
+
declare const Bounce: React.FC<BounceProps>;
|
|
100
|
+
|
|
101
|
+
declare type FadeDirection = "bottom-left" | "bottom-right" | "down" | "left" | "right" | "top-left" | "top-right" | "up";
|
|
102
|
+
interface FadeProps extends Omit<RevealProps, "keyframes" | "css"> {
|
|
99
103
|
/**
|
|
100
104
|
* Causes the animation to start farther. Only works with "down", "left", "right" and "up" directions.
|
|
101
105
|
* @default false
|
|
@@ -112,9 +116,10 @@ export interface FadeProps extends Omit<RevealProps, "keyframes" | "css"> {
|
|
|
112
116
|
*/
|
|
113
117
|
reverse?: boolean;
|
|
114
118
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
119
|
+
declare const Fade: React.FC<FadeProps>;
|
|
120
|
+
|
|
121
|
+
declare type FlipDirection = "horizontal" | "vertical";
|
|
122
|
+
interface FlipProps extends Omit<RevealProps, "keyframes" | "css"> {
|
|
118
123
|
/**
|
|
119
124
|
* Axis direction of the animation.
|
|
120
125
|
* @default undefined
|
|
@@ -126,21 +131,25 @@ export interface FlipProps extends Omit<RevealProps, "keyframes" | "css"> {
|
|
|
126
131
|
*/
|
|
127
132
|
reverse?: boolean;
|
|
128
133
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
134
|
+
declare const Flip: React.FC<FlipProps>;
|
|
135
|
+
|
|
136
|
+
declare type HingeProps = Omit<RevealProps, "keyframes" | "css">;
|
|
137
|
+
declare const Hinge: React.FC<HingeProps>;
|
|
138
|
+
|
|
139
|
+
declare type JackInTheBoxProps = Omit<RevealProps, "keyframes" | "css">;
|
|
140
|
+
declare const JackInTheBox: React.FC<JackInTheBoxProps>;
|
|
141
|
+
|
|
142
|
+
interface RollProps extends Omit<RevealProps, "keyframes" | "css"> {
|
|
135
143
|
/**
|
|
136
144
|
* Specifies if the animation should make element(s) disappear.
|
|
137
145
|
* @default false
|
|
138
146
|
*/
|
|
139
147
|
reverse?: boolean;
|
|
140
148
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
149
|
+
declare const Roll: React.FC<RollProps>;
|
|
150
|
+
|
|
151
|
+
declare type RotateDirection = "bottom-left" | "bottom-right" | "top-left" | "top-right";
|
|
152
|
+
interface RotateProps extends Omit<RevealProps, "keyframes" | "css"> {
|
|
144
153
|
/**
|
|
145
154
|
* Origin of the animation.
|
|
146
155
|
* @default undefined
|
|
@@ -152,9 +161,10 @@ export interface RotateProps extends Omit<RevealProps, "keyframes" | "css"> {
|
|
|
152
161
|
*/
|
|
153
162
|
reverse?: boolean;
|
|
154
163
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
164
|
+
declare const Rotate: React.FC<RotateProps>;
|
|
165
|
+
|
|
166
|
+
declare type SlideDirection = "down" | "left" | "right" | "up";
|
|
167
|
+
interface SlideProps extends Omit<RevealProps, "keyframes" | "css"> {
|
|
158
168
|
/**
|
|
159
169
|
* Origin of the animation.
|
|
160
170
|
* @default undefined
|
|
@@ -166,9 +176,10 @@ export interface SlideProps extends Omit<RevealProps, "keyframes" | "css"> {
|
|
|
166
176
|
*/
|
|
167
177
|
reverse?: boolean;
|
|
168
178
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
179
|
+
declare const Slide: React.FC<SlideProps>;
|
|
180
|
+
|
|
181
|
+
declare type ZoomDirection = "down" | "left" | "right" | "up";
|
|
182
|
+
interface ZoomProps extends Omit<RevealProps, "keyframes" | "css"> {
|
|
172
183
|
/**
|
|
173
184
|
* Origin of the animation.
|
|
174
185
|
* @default undefined
|
|
@@ -180,6 +191,6 @@ export interface ZoomProps extends Omit<RevealProps, "keyframes" | "css"> {
|
|
|
180
191
|
*/
|
|
181
192
|
reverse?: boolean;
|
|
182
193
|
}
|
|
183
|
-
|
|
194
|
+
declare const Zoom: React.FC<ZoomProps>;
|
|
184
195
|
|
|
185
|
-
|
|
196
|
+
export { AttentionSeeker, AttentionSeekerProps, Bounce, BounceProps, Fade, FadeProps, Flip, FlipProps, Hinge, HingeProps, JackInTheBox, JackInTheBoxProps, Reveal, RevealProps, Roll, RollProps, Rotate, RotateProps, Slide, SlideProps, Zoom, ZoomProps, Reveal as default };
|