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 {
4444 text : text ,
4545 } ) ;
4646
47- Animated . timing (
47+ this . animation = Animated . timing (
4848 this . state . opacityValue ,
4949 {
5050 toValue : this . props . opacity ,
5151 duration : this . props . fadeInDuration ,
5252 }
53- ) . start ( ( ) => {
53+ )
54+ this . animation . start ( ( ) => {
5455 this . isShow = true ;
5556 if ( duration !== DURATION . FOREVER ) this . close ( ) ;
5657 } ) ;
@@ -64,13 +65,14 @@ export default class Toast extends Component {
6465 if ( ! this . isShow && ! this . state . isShow ) return ;
6566 this . timer && clearTimeout ( this . timer ) ;
6667 this . timer = setTimeout ( ( ) => {
67- Animated . timing (
68+ this . animation = Animated . timing (
6869 this . state . opacityValue ,
6970 {
7071 toValue : 0.0 ,
7172 duration : this . props . fadeOutDuration ,
7273 }
73- ) . start ( ( ) => {
74+ )
75+ this . animation . start ( ( ) => {
7476 this . setState ( {
7577 isShow : false ,
7678 } ) ;
@@ -83,6 +85,7 @@ export default class Toast extends Component {
8385 }
8486
8587 componentWillUnmount ( ) {
88+ this . animation && this . animation . stop ( )
8689 this . timer && clearTimeout ( this . timer ) ;
8790 }
8891
You can’t perform that action at this time.
0 commit comments