@@ -26,13 +26,13 @@ interface IState {
26
26
export class ToastRender extends React . Component < IProps , IState > {
27
27
private _heightContainer : number ;
28
28
private _positionToast : Animated . Value ;
29
- private _pressStartY : null | number ;
29
+ private _pressStart : null | { startY : number ; startAt : number } ;
30
30
private _countdown : null | Function ;
31
31
32
32
constructor ( props : IProps ) {
33
33
super ( props ) ;
34
34
this . _heightContainer = 0 ;
35
- this . _pressStartY = null ;
35
+ this . _pressStart = null ;
36
36
this . _positionToast = new Animated . Value ( 0 ) ;
37
37
this . _countdown = null ;
38
38
this . state = {
@@ -94,15 +94,15 @@ export class ToastRender extends React.Component<IProps, IState> {
94
94
}
95
95
} ,
96
96
onPanResponderTerminationRequest : ( ) => true ,
97
- onPanResponderStart : ( _ , { dy } ) => {
98
- this . _pressStartY = dy ;
97
+ onPanResponderStart : ( _ , { dy : startY } ) => {
98
+ this . _pressStart = { startY , startAt : Date . now ( ) } ;
99
99
this . _countdown ?.( ) ;
100
100
} ,
101
101
onPanResponderEnd : async ( _ , { dy } ) => {
102
102
let heightContainer = this . _heightContainer ;
103
- const startY = this . _pressStartY ! ;
104
- this . _pressStartY = null ;
105
- if ( Math . abs ( dy - startY ) < 7 ) {
103
+ const { startY, startAt } = this . _pressStart ! ;
104
+ this . _pressStart = null ;
105
+ if ( startAt + 500 >= Date . now ( ) && Math . abs ( dy - startY ) < 7 ) {
106
106
this . props ?. onPress ?.( ) ;
107
107
this . _autoCloseHandler ( ) ;
108
108
} else if ( dy < - ( heightContainer / 3 ) ) {
0 commit comments