File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -44,13 +44,14 @@ export default class Toast extends Component {
44
44
text : text ,
45
45
} ) ;
46
46
47
- Animated . timing (
47
+ this . animation = Animated . timing (
48
48
this . state . opacityValue ,
49
49
{
50
50
toValue : this . props . opacity ,
51
51
duration : this . props . fadeInDuration ,
52
52
}
53
- ) . start ( ( ) => {
53
+ )
54
+ this . animation . start ( ( ) => {
54
55
this . isShow = true ;
55
56
if ( duration !== DURATION . FOREVER ) this . close ( ) ;
56
57
} ) ;
@@ -64,13 +65,14 @@ export default class Toast extends Component {
64
65
if ( ! this . isShow && ! this . state . isShow ) return ;
65
66
this . timer && clearTimeout ( this . timer ) ;
66
67
this . timer = setTimeout ( ( ) => {
67
- Animated . timing (
68
+ this . animation = Animated . timing (
68
69
this . state . opacityValue ,
69
70
{
70
71
toValue : 0.0 ,
71
72
duration : this . props . fadeOutDuration ,
72
73
}
73
- ) . start ( ( ) => {
74
+ )
75
+ this . animation . start ( ( ) => {
74
76
this . setState ( {
75
77
isShow : false ,
76
78
} ) ;
@@ -83,6 +85,7 @@ export default class Toast extends Component {
83
85
}
84
86
85
87
componentWillUnmount ( ) {
88
+ this . animation && this . animation . stop ( )
86
89
this . timer && clearTimeout ( this . timer ) ;
87
90
}
88
91
You can’t perform that action at this time.
0 commit comments