File tree Expand file tree Collapse file tree 2 files changed +54
-19
lines changed Expand file tree Collapse file tree 2 files changed +54
-19
lines changed Original file line number Diff line number Diff line change 11import React from 'react' ;
22import { node , string } from 'prop-types' ;
3+ import { Transition } from 'react-transition-group' ;
34import {
45 defaultAnimationProps ,
56 getInlineStyles ,
67 getTimeoutValue ,
78} from 'utilities' ;
89
9- import FadeInOut from '../FadeInOut' ;
10- import TweenTransform from '../TweenTransform' ;
10+ const statusStyles = {
11+ entered : {
12+ opacity : 1 ,
13+ } ,
14+ entering : {
15+ opacity : 1 ,
16+ } ,
17+ exited : {
18+ opacity : 0 ,
19+ } ,
20+ exiting : {
21+ opacity : 0 ,
22+ } ,
23+ } ;
24+
25+ const FadeTransform = ( {
26+ children,
27+ enter,
28+ exit,
29+ exiting,
30+ entering,
31+ ...props
32+ } ) => {
33+ const pos = {
34+ entering : entering || enter ,
35+ entered : enter ,
36+ exiting : exiting || exit ,
37+ exited : exit ,
38+ } ;
1139
12- const FadeTransform = ( { children, ...props } ) => {
1340 return (
14- < TweenTransform
15- timeout = { getTimeoutValue ( props ) }
16- { ...props }
17- style = { getInlineStyles ( props ) }
18- >
19- < FadeInOut
20- timeout = { getTimeoutValue ( props ) }
21- { ...props }
22- style = { getInlineStyles ( props ) }
23- >
24- { children }
25- </ FadeInOut >
26- </ TweenTransform >
41+ < Transition timeout = { getTimeoutValue ( props ) } { ...props } >
42+ { status => (
43+ < div
44+ style = { {
45+ ...getInlineStyles ( props ) ,
46+ ...statusStyles [ status ] ,
47+ transform : pos [ status ] ,
48+ transitionProperty : 'transform, opacity' ,
49+ } }
50+ >
51+ { children }
52+ </ div >
53+ ) }
54+ </ Transition >
2755 ) ;
2856} ;
2957
Original file line number Diff line number Diff line change @@ -8,11 +8,18 @@ import {
88 getTimeoutValue ,
99} from 'utilities' ;
1010
11- const TweenTransform = ( { children, enter, exit, ...props } ) => {
11+ const TweenTransform = ( {
12+ children,
13+ enter,
14+ exit,
15+ entering,
16+ exiting,
17+ ...props
18+ } ) => {
1219 const pos = {
13- entering : enter ,
20+ entering : entering || enter ,
1421 entered : enter ,
15- exiting : exit ,
22+ exiting : exiting || exit ,
1623 exited : exit ,
1724 } ;
1825
You can’t perform that action at this time.
0 commit comments