1 | export * from './touch-manager';
|
2 |
|
3 |
|
4 |
|
5 | export var GestureEvents;
|
6 | (function (GestureEvents) {
|
7 | |
8 |
|
9 |
|
10 |
|
11 | GestureEvents["gestureAttached"] = "gestureAttached";
|
12 | |
13 |
|
14 |
|
15 | GestureEvents["touchDown"] = "touchDown";
|
16 | |
17 |
|
18 |
|
19 | GestureEvents["touchUp"] = "touchUp";
|
20 | })(GestureEvents || (GestureEvents = {}));
|
21 |
|
22 |
|
23 |
|
24 | export var GestureTypes;
|
25 | (function (GestureTypes) {
|
26 | |
27 |
|
28 |
|
29 | GestureTypes[GestureTypes["tap"] = 1] = "tap";
|
30 | |
31 |
|
32 |
|
33 | GestureTypes[GestureTypes["doubleTap"] = 2] = "doubleTap";
|
34 | |
35 |
|
36 |
|
37 | GestureTypes[GestureTypes["pinch"] = 4] = "pinch";
|
38 | |
39 |
|
40 |
|
41 | GestureTypes[GestureTypes["pan"] = 8] = "pan";
|
42 | |
43 |
|
44 |
|
45 | GestureTypes[GestureTypes["swipe"] = 16] = "swipe";
|
46 | |
47 |
|
48 |
|
49 | GestureTypes[GestureTypes["rotation"] = 32] = "rotation";
|
50 | |
51 |
|
52 |
|
53 | GestureTypes[GestureTypes["longPress"] = 64] = "longPress";
|
54 | |
55 |
|
56 |
|
57 | GestureTypes[GestureTypes["touch"] = 128] = "touch";
|
58 | })(GestureTypes || (GestureTypes = {}));
|
59 |
|
60 |
|
61 |
|
62 | export var GestureStateTypes;
|
63 | (function (GestureStateTypes) {
|
64 | |
65 |
|
66 |
|
67 | GestureStateTypes[GestureStateTypes["cancelled"] = 0] = "cancelled";
|
68 | |
69 |
|
70 |
|
71 | GestureStateTypes[GestureStateTypes["began"] = 1] = "began";
|
72 | |
73 |
|
74 |
|
75 | GestureStateTypes[GestureStateTypes["changed"] = 2] = "changed";
|
76 | |
77 |
|
78 |
|
79 | GestureStateTypes[GestureStateTypes["ended"] = 3] = "ended";
|
80 | })(GestureStateTypes || (GestureStateTypes = {}));
|
81 |
|
82 |
|
83 |
|
84 | export var SwipeDirection;
|
85 | (function (SwipeDirection) {
|
86 | |
87 |
|
88 |
|
89 | SwipeDirection[SwipeDirection["right"] = 1] = "right";
|
90 | |
91 |
|
92 |
|
93 | SwipeDirection[SwipeDirection["left"] = 2] = "left";
|
94 | |
95 |
|
96 |
|
97 | SwipeDirection[SwipeDirection["up"] = 4] = "up";
|
98 | |
99 |
|
100 |
|
101 | SwipeDirection[SwipeDirection["down"] = 8] = "down";
|
102 | })(SwipeDirection || (SwipeDirection = {}));
|
103 |
|
104 |
|
105 |
|
106 | export var TouchAction;
|
107 | (function (TouchAction) {
|
108 | |
109 |
|
110 |
|
111 | TouchAction["down"] = "down";
|
112 | |
113 |
|
114 |
|
115 | TouchAction["up"] = "up";
|
116 | |
117 |
|
118 |
|
119 | TouchAction["move"] = "move";
|
120 | |
121 |
|
122 |
|
123 | TouchAction["cancel"] = "cancel";
|
124 | })(TouchAction || (TouchAction = {}));
|
125 |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 | export function toString(type, separator) {
|
131 | const types = new Array();
|
132 | if (type & GestureTypes.tap) {
|
133 | types.push('tap');
|
134 | }
|
135 | if (type & GestureTypes.doubleTap) {
|
136 | types.push('doubleTap');
|
137 | }
|
138 | if (type & GestureTypes.pinch) {
|
139 | types.push('pinch');
|
140 | }
|
141 | if (type & GestureTypes.pan) {
|
142 | types.push('pan');
|
143 | }
|
144 | if (type & GestureTypes.swipe) {
|
145 | types.push('swipe');
|
146 | }
|
147 | if (type & GestureTypes.rotation) {
|
148 | types.push('rotation');
|
149 | }
|
150 | if (type & GestureTypes.longPress) {
|
151 | types.push('longPress');
|
152 | }
|
153 | if (type & GestureTypes.touch) {
|
154 | types.push('touch');
|
155 | }
|
156 | return types.join(separator);
|
157 | }
|
158 |
|
159 |
|
160 |
|
161 |
|
162 |
|
163 |
|
164 | export function fromString(type) {
|
165 | const t = type.trim().toLowerCase();
|
166 | if (t === 'tap') {
|
167 | return GestureTypes.tap;
|
168 | }
|
169 | else if (t === 'doubletap') {
|
170 | return GestureTypes.doubleTap;
|
171 | }
|
172 | else if (t === 'pinch') {
|
173 | return GestureTypes.pinch;
|
174 | }
|
175 | else if (t === 'pan') {
|
176 | return GestureTypes.pan;
|
177 | }
|
178 | else if (t === 'swipe') {
|
179 | return GestureTypes.swipe;
|
180 | }
|
181 | else if (t === 'rotation') {
|
182 | return GestureTypes.rotation;
|
183 | }
|
184 | else if (t === 'longpress') {
|
185 | return GestureTypes.longPress;
|
186 | }
|
187 | else if (t === 'touch') {
|
188 | return GestureTypes.touch;
|
189 | }
|
190 | return undefined;
|
191 | }
|
192 | export class GesturesObserverBase {
|
193 | get callback() {
|
194 | return this._callback;
|
195 | }
|
196 | get target() {
|
197 | return this._target;
|
198 | }
|
199 | get context() {
|
200 | return this._context;
|
201 | }
|
202 | constructor(target, callback, context) {
|
203 | this._target = target;
|
204 | this._callback = callback;
|
205 | this._context = context;
|
206 | }
|
207 | disconnect() {
|
208 |
|
209 | if (this.target) {
|
210 | const list = this.target.getGestureObservers(this.type);
|
211 | if (list && list.length > 0) {
|
212 | for (let i = 0; i < list.length; i++) {
|
213 | if (list[i].callback === this.callback) {
|
214 | break;
|
215 | }
|
216 | }
|
217 | list.length = 0;
|
218 | this.target._gestureObservers[this.type] = undefined;
|
219 | delete this.target._gestureObservers[this.type];
|
220 | }
|
221 | }
|
222 | this._target = null;
|
223 | this._callback = null;
|
224 | this._context = null;
|
225 | }
|
226 | }
|
227 |
|
\ | No newline at end of file |