File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -37,9 +37,9 @@ export default class Toast extends Component {
3737 }
3838 }
3939
40- show ( text , duration ) {
41- this . duration = typeof duration === 'number' ? duration : DURATION . LENGTH_SHORT ;
42-
40+ show ( text , duration = DURATION . LENGTH_SHORT , callback ) {
41+
42+ let delay = duration ;
4343 this . setState ( {
4444 isShow : true ,
4545 text : text ,
@@ -53,13 +53,13 @@ export default class Toast extends Component {
5353 }
5454 ) . start ( ( ) => {
5555 this . isShow = true ;
56- if ( duration !== DURATION . FOREVER ) this . close ( ) ;
56+ if ( duration !== DURATION . FOREVER ) this . close ( callback ) ;
5757 } ) ;
5858 }
5959
60- close ( duration ) {
61- let delay = typeof duration === 'undefined' ? this . duration : duration ;
60+ close ( duration = DURATION . LENGTH_SHORT , callback ) {
6261
62+ let delay = duration ;
6363 if ( delay === DURATION . FOREVER ) delay = this . props . defaultCloseDelay || 250 ;
6464
6565 if ( ! this . isShow && ! this . state . isShow ) return ;
@@ -72,10 +72,14 @@ export default class Toast extends Component {
7272 duration : this . props . fadeOutDuration ,
7373 }
7474 ) . start ( ( ) => {
75+
7576 this . setState ( {
7677 isShow : false ,
7778 } ) ;
7879 this . isShow = false ;
80+ if ( typeof callback === 'function' ) {
81+ callback ( ) ;
82+ }
7983 } ) ;
8084 } , delay ) ;
8185 }
You can’t perform that action at this time.
0 commit comments