File tree 1 file changed +6
-6
lines changed
components/tabs/src/hooks
1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -33,26 +33,26 @@ export default function useTouchMove(
33
33
34
34
e . preventDefault ( ) ;
35
35
const { screenX, screenY } = e . touches [ 0 ] ;
36
- setTouchPosition ( { x : screenX , y : screenY } ) ;
37
36
const offsetX = screenX - touchPosition . value . x ;
38
37
const offsetY = screenY - touchPosition . value . y ;
39
38
onOffset ( offsetX , offsetY ) ;
39
+ setTouchPosition ( { x : screenX , y : screenY } ) ;
40
40
const now = Date . now ( ) ;
41
- setLastTimestamp ( now ) ;
42
41
setLastTimeDiff ( now - lastTimestamp . value ) ;
42
+ setLastTimestamp ( now ) ;
43
43
setLastOffset ( { x : offsetX , y : offsetY } ) ;
44
44
}
45
45
46
46
function onTouchEnd ( ) {
47
47
if ( ! touchPosition . value ) return ;
48
-
48
+ const lastOffsetValue = lastOffset . value ;
49
49
setTouchPosition ( null ) ;
50
50
setLastOffset ( null ) ;
51
51
52
52
// Swipe if needed
53
- if ( lastOffset . value ) {
54
- const distanceX = lastOffset . value . x / lastTimeDiff . value ;
55
- const distanceY = lastOffset . value . y / lastTimeDiff . value ;
53
+ if ( lastOffsetValue ) {
54
+ const distanceX = lastOffsetValue . x / lastTimeDiff . value ;
55
+ const distanceY = lastOffsetValue . y / lastTimeDiff . value ;
56
56
const absX = Math . abs ( distanceX ) ;
57
57
const absY = Math . abs ( distanceY ) ;
58
58
You can’t perform that action at this time.
0 commit comments