@tamagui/animate-presence 1.0.1-beta.167 → 1.0.1-beta.169
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/package.json +3 -3
- package/types/AnimatePresence.d.ts +33 -0
- package/types/types.d.ts +54 -0
- package/types/usePresence.d.ts +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/animate-presence",
|
|
3
|
-
"version": "1.0.1-beta.
|
|
3
|
+
"version": "1.0.1-beta.169",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"dist"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@tamagui/core": "^1.0.1-beta.
|
|
17
|
+
"@tamagui/core": "^1.0.1-beta.169"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@tamagui/build": "^1.0.1-beta.
|
|
20
|
+
"@tamagui/build": "^1.0.1-beta.169"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"build": "tamagui-build",
|
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { AnimatePresenceProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* `AnimatePresence` enables the animation of components that have been removed from the tree.
|
|
5
|
+
*
|
|
6
|
+
* When adding/removing more than a single child, every child **must** be given a unique `key` prop.
|
|
7
|
+
*
|
|
8
|
+
* Any `motion` components that have an `exit` property defined will animate out when removed from
|
|
9
|
+
* the tree.
|
|
10
|
+
*
|
|
11
|
+
* ```tsx
|
|
12
|
+
* import { motion, AnimatePresence } from 'framer-motion'
|
|
13
|
+
*
|
|
14
|
+
* export const Items = ({ items }) => (
|
|
15
|
+
* <AnimatePresence>
|
|
16
|
+
* {items.map(item => (
|
|
17
|
+
* <motion.div
|
|
18
|
+
* key={item.id}
|
|
19
|
+
* initial={{ opacity: 0 }}
|
|
20
|
+
* animate={{ opacity: 1 }}
|
|
21
|
+
* exit={{ opacity: 0 }}
|
|
22
|
+
* />
|
|
23
|
+
* ))}
|
|
24
|
+
* </AnimatePresence>
|
|
25
|
+
* )
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* You can sequence exit animations throughout a tree using variants.
|
|
29
|
+
*
|
|
30
|
+
* If a child contains multiple `motion` components with `exit` props, it will only unmount the child
|
|
31
|
+
* once all `motion` components have finished animating out. Likewise, any components using
|
|
32
|
+
* `usePresence` all need to call `safeToRemove`.
|
|
33
|
+
*
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
3
36
|
export declare const AnimatePresence: React.FunctionComponent<React.PropsWithChildren<AnimatePresenceProps>>;
|
|
4
37
|
//# sourceMappingURL=AnimatePresence.d.ts.map
|
package/types/types.d.ts
CHANGED
|
@@ -7,11 +7,65 @@ export interface Box {
|
|
|
7
7
|
y: Axis;
|
|
8
8
|
}
|
|
9
9
|
export declare type VariantLabels = string | string[];
|
|
10
|
+
/**
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
10
13
|
export interface AnimatePresenceProps {
|
|
14
|
+
/**
|
|
15
|
+
* By passing `initial={false}`, `AnimatePresence` will disable any initial animations on children
|
|
16
|
+
* that are present when the component is first rendered.
|
|
17
|
+
*
|
|
18
|
+
* ```jsx
|
|
19
|
+
* <AnimatePresence initial={false}>
|
|
20
|
+
* {isVisible && (
|
|
21
|
+
* <motion.div
|
|
22
|
+
* key="modal"
|
|
23
|
+
* initial={{ opacity: 0 }}
|
|
24
|
+
* animate={{ opacity: 1 }}
|
|
25
|
+
* exit={{ opacity: 0 }}
|
|
26
|
+
* />
|
|
27
|
+
* )}
|
|
28
|
+
* </AnimatePresence>
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
11
33
|
initial?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* When a component is removed, there's no longer a chance to update its props. So if a component's `exit`
|
|
36
|
+
* prop is defined as a dynamic variant and you want to pass a new `custom` prop, you can do so via `AnimatePresence`.
|
|
37
|
+
* This will ensure all leaving components animate using the latest data.
|
|
38
|
+
*
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
12
41
|
custom?: any;
|
|
42
|
+
/**
|
|
43
|
+
* Fires when all exiting nodes have completed animating out.
|
|
44
|
+
*
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
13
47
|
onExitComplete?: () => void;
|
|
48
|
+
/**
|
|
49
|
+
* If set to `true`, `AnimatePresence` will only render one component at a time. The exiting component
|
|
50
|
+
* will finish its exit animation before the entering component is rendered.
|
|
51
|
+
*
|
|
52
|
+
* ```jsx
|
|
53
|
+
* const MyComponent = ({ currentItem }) => (
|
|
54
|
+
* <AnimatePresence exitBeforeEnter>
|
|
55
|
+
* <motion.div key={currentItem} exit={{ opacity: 0 }} />
|
|
56
|
+
* </AnimatePresence>
|
|
57
|
+
* )
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* @beta
|
|
61
|
+
*/
|
|
14
62
|
exitBeforeEnter?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Used in Framer to flag that sibling children *shouldn't* re-render as a result of a
|
|
65
|
+
* child being removed.
|
|
66
|
+
*
|
|
67
|
+
* @internal
|
|
68
|
+
*/
|
|
15
69
|
presenceAffectsLayout?: boolean;
|
|
16
70
|
exitVariant?: string | null;
|
|
17
71
|
enterVariant?: string | null;
|
package/types/usePresence.d.ts
CHANGED
|
@@ -4,6 +4,10 @@ declare type AlwaysPresent = [true, null];
|
|
|
4
4
|
declare type Present = [true];
|
|
5
5
|
declare type NotPresent = [false, SafeToRemove];
|
|
6
6
|
export declare function usePresence(): AlwaysPresent | Present | NotPresent;
|
|
7
|
+
/**
|
|
8
|
+
* Similar to `usePresence`, except `useIsPresent` simply returns whether or not the component is present.
|
|
9
|
+
* There is no `safeToRemove` function. ```
|
|
10
|
+
*/
|
|
7
11
|
export declare function useIsPresent(): boolean;
|
|
8
12
|
export declare function isPresent(context: PresenceContextProps | null): boolean;
|
|
9
13
|
export {};
|