1 |
|
2 | import React, { Component } from 'react';
|
3 | export declare type GestureHandler = (s: IGestureStauts) => void;
|
4 | export declare type Finger = {
|
5 | x: number;
|
6 | y: number;
|
7 | };
|
8 | export declare type MultiFingerStatus = {
|
9 | x: number;
|
10 | y: number;
|
11 | z: number;
|
12 | angle: number;
|
13 | };
|
14 | export declare type SingeFingerMoveStatus = {
|
15 | x: number;
|
16 | y: number;
|
17 | z: number;
|
18 | time: number;
|
19 | velocity: number;
|
20 | angle: number;
|
21 | };
|
22 | export interface IGesture {
|
23 | enableRotate?: boolean;
|
24 | enablePinch?: boolean;
|
25 | direction?: string;
|
26 | onPinch?: GestureHandler;
|
27 | onPinchStart?: GestureHandler;
|
28 | onPinchMove?: GestureHandler;
|
29 | onPinchEnd?: GestureHandler;
|
30 | onPinchCancel?: GestureHandler;
|
31 | onPinchIn?: GestureHandler;
|
32 | onPinchOut?: GestureHandler;
|
33 | onRotate?: GestureHandler;
|
34 | onRotateStart?: GestureHandler;
|
35 | onRotateMove?: GestureHandler;
|
36 | onRotateEnd?: GestureHandler;
|
37 | onRotateCancel?: GestureHandler;
|
38 | onPan?: GestureHandler;
|
39 | onPanStart?: GestureHandler;
|
40 | onPanMove?: GestureHandler;
|
41 | onPanEnd?: GestureHandler;
|
42 | onPanCancel?: GestureHandler;
|
43 | onPanLeft?: GestureHandler;
|
44 | onPanRight?: GestureHandler;
|
45 | onPanUp?: GestureHandler;
|
46 | onPanDown?: GestureHandler;
|
47 | onTap?: GestureHandler;
|
48 | onPress?: GestureHandler;
|
49 | onPressUp?: GestureHandler;
|
50 | onSwipe?: GestureHandler;
|
51 | onSwipeLeft?: GestureHandler;
|
52 | onSwipeRight?: GestureHandler;
|
53 | onSwipeUp?: GestureHandler;
|
54 | onSwipeDown?: GestureHandler;
|
55 | }
|
56 | export interface IGestureStauts {
|
57 | startTime: number;
|
58 | startTouches: Finger[];
|
59 | startMutliFingerStatus?: MultiFingerStatus[];
|
60 | time: number;
|
61 | touches: Finger[];
|
62 | mutliFingerStatus?: MultiFingerStatus[];
|
63 | moveStatus?: SingeFingerMoveStatus;
|
64 | press?: boolean;
|
65 | pan?: boolean;
|
66 | swipe?: boolean;
|
67 | direction?: number;
|
68 | pinch?: boolean;
|
69 | scale?: number;
|
70 | rotate?: boolean;
|
71 | rotation?: number;
|
72 | }
|
73 | export default class Gesture extends Component<IGesture, any> {
|
74 | static defaultProps: {
|
75 | enableRotate: boolean;
|
76 | enablePinch: boolean;
|
77 | direction: string;
|
78 | };
|
79 | state: {};
|
80 | protected gesture: IGestureStauts;
|
81 | protected event: any;
|
82 | private pressTimer;
|
83 | private directionSetting;
|
84 | constructor(props: any);
|
85 | triggerEvent: (name: any, ...args: any[]) => void;
|
86 | triggerCombineEvent: (mainEventName: any, eventStatus: any, ...args: any[]) => void;
|
87 | triggerSubEvent: (mainEventName: any, eventStatus: any, ...args: any[]) => void;
|
88 | triggerPinchEvent: (mainEventName: any, eventStatus: any, ...args: any[]) => void;
|
89 | initPressTimer: () => void;
|
90 | cleanPressTimer: () => void;
|
91 | setGestureState: (params: any) => void;
|
92 | getGestureState: () => {
|
93 | startTime: number;
|
94 | startTouches: Finger[];
|
95 | startMutliFingerStatus?: MultiFingerStatus[] | undefined;
|
96 | time: number;
|
97 | touches: Finger[];
|
98 | mutliFingerStatus?: MultiFingerStatus[] | undefined;
|
99 | moveStatus?: SingeFingerMoveStatus | undefined;
|
100 | press?: boolean | undefined;
|
101 | pan?: boolean | undefined;
|
102 | swipe?: boolean | undefined;
|
103 | direction?: number | undefined;
|
104 | pinch?: boolean | undefined;
|
105 | scale?: number | undefined;
|
106 | rotate?: boolean | undefined;
|
107 | rotation?: number | undefined;
|
108 | };
|
109 | cleanGestureState: () => void;
|
110 | getTouches: (e: any) => any;
|
111 | _handleTouchStart: (e: any) => void;
|
112 | initGestureStatus: (e: any) => void;
|
113 | checkIfMultiTouchStart: () => void;
|
114 | _handleTouchMove: (e: any) => void;
|
115 | checkIfMultiTouchMove: () => void;
|
116 | allowGesture: () => boolean;
|
117 | checkIfSingleTouchMove: () => void;
|
118 | checkIfMultiTouchEnd: (status: any) => void;
|
119 | updateGestureStatus: (e: any) => void;
|
120 | _handleTouchEnd: (e: any) => void;
|
121 | _handleTouchCancel: (e: any) => void;
|
122 | doSingleTouchEnd: (status: any) => void;
|
123 | componentWillUnmount(): void;
|
124 | getTouchAction: () => "auto" | "pan-x pan-y" | "pan-x" | "pan-y";
|
125 | render(): React.ReactElement<any>;
|
126 | }
|