1 | import { VariantsType } from '../types';
|
---|
2 | //
|
---|
3 | import { varTranEnter, varTranExit } from './transition';
|
---|
4 |
|
---|
5 | // ----------------------------------------------------------------------
|
---|
6 |
|
---|
7 | export const varFade = (props?: VariantsType) => {
|
---|
8 | const distance = props?.distance || 120;
|
---|
9 | const durationIn = props?.durationIn;
|
---|
10 | const durationOut = props?.durationOut;
|
---|
11 | const easeIn = props?.easeIn;
|
---|
12 | const easeOut = props?.easeOut;
|
---|
13 |
|
---|
14 | return {
|
---|
15 | // IN
|
---|
16 | in: {
|
---|
17 | initial: { opacity: 0 },
|
---|
18 | animate: { opacity: 1, transition: varTranEnter },
|
---|
19 | exit: { opacity: 0, transition: varTranExit },
|
---|
20 | },
|
---|
21 | inUp: {
|
---|
22 | initial: { y: distance, opacity: 0 },
|
---|
23 | animate: {
|
---|
24 | y: 0,
|
---|
25 | opacity: 1,
|
---|
26 | transition: varTranEnter({ durationIn, easeIn }),
|
---|
27 | },
|
---|
28 | exit: {
|
---|
29 | y: distance,
|
---|
30 | opacity: 0,
|
---|
31 | transition: varTranExit({ durationOut, easeOut }),
|
---|
32 | },
|
---|
33 | },
|
---|
34 | inDown: {
|
---|
35 | initial: { y: -distance, opacity: 0 },
|
---|
36 | animate: {
|
---|
37 | y: 0,
|
---|
38 | opacity: 1,
|
---|
39 | transition: varTranEnter({ durationIn, easeIn }),
|
---|
40 | },
|
---|
41 | exit: {
|
---|
42 | y: -distance,
|
---|
43 | opacity: 0,
|
---|
44 | transition: varTranExit({ durationOut, easeOut }),
|
---|
45 | },
|
---|
46 | },
|
---|
47 | inLeft: {
|
---|
48 | initial: { x: -distance, opacity: 0 },
|
---|
49 | animate: {
|
---|
50 | x: 0,
|
---|
51 | opacity: 1,
|
---|
52 | transition: varTranEnter({ durationIn, easeIn }),
|
---|
53 | },
|
---|
54 | exit: {
|
---|
55 | x: -distance,
|
---|
56 | opacity: 0,
|
---|
57 | transition: varTranExit({ durationOut, easeOut }),
|
---|
58 | },
|
---|
59 | },
|
---|
60 | inRight: {
|
---|
61 | initial: { x: distance, opacity: 0 },
|
---|
62 | animate: {
|
---|
63 | x: 0,
|
---|
64 | opacity: 1,
|
---|
65 | transition: varTranEnter({ durationIn, easeIn }),
|
---|
66 | },
|
---|
67 | exit: {
|
---|
68 | x: distance,
|
---|
69 | opacity: 0,
|
---|
70 | transition: varTranExit({ durationOut, easeOut }),
|
---|
71 | },
|
---|
72 | },
|
---|
73 |
|
---|
74 | // OUT
|
---|
75 | out: {
|
---|
76 | initial: { opacity: 1 },
|
---|
77 | animate: { opacity: 0, transition: varTranEnter({ durationIn, easeIn }) },
|
---|
78 | exit: { opacity: 1, transition: varTranExit({ durationOut, easeOut }) },
|
---|
79 | },
|
---|
80 | outUp: {
|
---|
81 | initial: { y: 0, opacity: 1 },
|
---|
82 | animate: {
|
---|
83 | y: -distance,
|
---|
84 | opacity: 0,
|
---|
85 | transition: varTranEnter({ durationIn, easeIn }),
|
---|
86 | },
|
---|
87 | exit: {
|
---|
88 | y: 0,
|
---|
89 | opacity: 1,
|
---|
90 | transition: varTranExit({ durationOut, easeOut }),
|
---|
91 | },
|
---|
92 | },
|
---|
93 | outDown: {
|
---|
94 | initial: { y: 0, opacity: 1 },
|
---|
95 | animate: {
|
---|
96 | y: distance,
|
---|
97 | opacity: 0,
|
---|
98 | transition: varTranEnter({ durationIn, easeIn }),
|
---|
99 | },
|
---|
100 | exit: {
|
---|
101 | y: 0,
|
---|
102 | opacity: 1,
|
---|
103 | transition: varTranExit({ durationOut, easeOut }),
|
---|
104 | },
|
---|
105 | },
|
---|
106 | outLeft: {
|
---|
107 | initial: { x: 0, opacity: 1 },
|
---|
108 | animate: {
|
---|
109 | x: -distance,
|
---|
110 | opacity: 0,
|
---|
111 | transition: varTranEnter({ durationIn, easeIn }),
|
---|
112 | },
|
---|
113 | exit: {
|
---|
114 | x: 0,
|
---|
115 | opacity: 1,
|
---|
116 | transition: varTranExit({ durationOut, easeOut }),
|
---|
117 | },
|
---|
118 | },
|
---|
119 | outRight: {
|
---|
120 | initial: { x: 0, opacity: 1 },
|
---|
121 | animate: {
|
---|
122 | x: distance,
|
---|
123 | opacity: 0,
|
---|
124 | transition: varTranEnter({ durationIn, easeIn }),
|
---|
125 | },
|
---|
126 | exit: {
|
---|
127 | x: 0,
|
---|
128 | opacity: 1,
|
---|
129 | transition: varTranExit({ durationOut, easeOut }),
|
---|
130 | },
|
---|
131 | },
|
---|
132 | };
|
---|
133 | };
|
---|