targetj 1.0.74 → 1.0.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/babel.config.json +17 -0
- package/build/$Dom.js +424 -0
- package/build/App.js +187 -0
- package/build/Bracket.js +157 -0
- package/build/BracketGenerator.js +86 -0
- package/build/Browser.js +105 -0
- package/build/ColorUtil.js +182 -0
- package/build/Dim.js +31 -0
- package/build/Easing.js +59 -0
- package/build/EventListener.js +664 -0
- package/build/LoadingManager.js +366 -0
- package/build/LocationManager.js +211 -0
- package/build/Moves.js +71 -0
- package/build/PageManager.js +113 -0
- package/build/SearchUtil.js +196 -0
- package/build/TModel.js +1000 -0
- package/build/TModelManager.js +605 -0
- package/build/TUtil.js +188 -0
- package/build/TargetExecutor.js +117 -0
- package/build/TargetManager.js +197 -0
- package/build/TargetUtil.js +299 -0
- package/build/Viewport.js +163 -0
- package/package.json +11 -4
- package/webpack.config.js +14 -1
- package/src/$Dom.js +0 -380
- package/src/App.js +0 -224
- package/src/Bracket.js +0 -212
- package/src/Browser.js +0 -122
- package/src/ColorUtil.js +0 -166
- package/src/Dim.js +0 -21
- package/src/Easing.js +0 -41
- package/src/EventListener.js +0 -570
- package/src/LoadingManager.js +0 -368
- package/src/LocationManager.js +0 -236
- package/src/Moves.js +0 -59
- package/src/PageManager.js +0 -87
- package/src/SearchUtil.js +0 -210
- package/src/TModel.js +0 -937
- package/src/TModelManager.js +0 -575
- package/src/TUtil.js +0 -162
- package/src/TargetExecutor.js +0 -113
- package/src/TargetManager.js +0 -191
- package/src/TargetUtil.js +0 -307
- package/src/Viewport.js +0 -180
|
@@ -0,0 +1,664 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.EventListener = void 0;
|
|
7
|
+
var _$Dom = require("./$Dom.js");
|
|
8
|
+
var _Browser = require("./Browser.js");
|
|
9
|
+
var _SearchUtil = require("./SearchUtil.js");
|
|
10
|
+
var _TUtil = require("./TUtil.js");
|
|
11
|
+
var _App = require("./App.js");
|
|
12
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
13
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
14
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
15
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
16
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
17
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
18
|
+
var EventListener = exports.EventListener = /*#__PURE__*/function () {
|
|
19
|
+
function EventListener() {
|
|
20
|
+
var _this = this;
|
|
21
|
+
_classCallCheck(this, EventListener);
|
|
22
|
+
this.currentTouch = {
|
|
23
|
+
deltaY: 0,
|
|
24
|
+
deltaX: 0,
|
|
25
|
+
pinchDelta: 0,
|
|
26
|
+
key: '',
|
|
27
|
+
manualMomentumFlag: false,
|
|
28
|
+
orientation: "none",
|
|
29
|
+
dir: "",
|
|
30
|
+
source: ""
|
|
31
|
+
};
|
|
32
|
+
this.touchTimeStamp = 0;
|
|
33
|
+
this.cursor = {
|
|
34
|
+
x: 0,
|
|
35
|
+
y: 0
|
|
36
|
+
};
|
|
37
|
+
this.start0 = undefined;
|
|
38
|
+
this.start1 = undefined;
|
|
39
|
+
this.end0 = undefined;
|
|
40
|
+
this.end1 = undefined;
|
|
41
|
+
this.touchCount = 0;
|
|
42
|
+
this.currentEvent = "";
|
|
43
|
+
this.currentHandlers = {
|
|
44
|
+
touch: null,
|
|
45
|
+
scrollLeft: null,
|
|
46
|
+
scrollTop: null,
|
|
47
|
+
pinch: null
|
|
48
|
+
};
|
|
49
|
+
this.eventQueue = [];
|
|
50
|
+
this.eventMap = {
|
|
51
|
+
touchstart: {
|
|
52
|
+
to: 'touchstart',
|
|
53
|
+
inputType: 'touch',
|
|
54
|
+
eventType: 'start',
|
|
55
|
+
order: 1,
|
|
56
|
+
windowEvent: false
|
|
57
|
+
},
|
|
58
|
+
touchmove: {
|
|
59
|
+
to: 'touchmove',
|
|
60
|
+
inputType: 'touch',
|
|
61
|
+
eventType: 'move',
|
|
62
|
+
order: 1,
|
|
63
|
+
windowEvent: false
|
|
64
|
+
},
|
|
65
|
+
touchend: {
|
|
66
|
+
to: 'touchend',
|
|
67
|
+
inputType: 'touch',
|
|
68
|
+
eventType: 'end',
|
|
69
|
+
order: 1,
|
|
70
|
+
windowEvent: false
|
|
71
|
+
},
|
|
72
|
+
touchcancel: {
|
|
73
|
+
to: 'touchend',
|
|
74
|
+
inputType: 'touch',
|
|
75
|
+
eventType: 'cancel',
|
|
76
|
+
order: 1,
|
|
77
|
+
windowEvent: false
|
|
78
|
+
},
|
|
79
|
+
mousedown: {
|
|
80
|
+
to: 'mousedown',
|
|
81
|
+
inputType: 'mouse',
|
|
82
|
+
eventType: 'start',
|
|
83
|
+
order: 2,
|
|
84
|
+
windowEvent: false
|
|
85
|
+
},
|
|
86
|
+
mousemove: {
|
|
87
|
+
to: 'mousemove',
|
|
88
|
+
inputType: 'mouse',
|
|
89
|
+
eventType: 'move',
|
|
90
|
+
order: 2,
|
|
91
|
+
windowEvent: false
|
|
92
|
+
},
|
|
93
|
+
mouseup: {
|
|
94
|
+
to: 'mouseup',
|
|
95
|
+
inputType: 'mouse',
|
|
96
|
+
eventType: 'end',
|
|
97
|
+
order: 2,
|
|
98
|
+
windowEvent: false
|
|
99
|
+
},
|
|
100
|
+
mousecancel: {
|
|
101
|
+
to: 'mouseup',
|
|
102
|
+
inputType: 'mouse',
|
|
103
|
+
eventType: 'cancel',
|
|
104
|
+
order: 2,
|
|
105
|
+
windowEvent: false
|
|
106
|
+
},
|
|
107
|
+
pointerdown: {
|
|
108
|
+
to: 'mousedown',
|
|
109
|
+
inputType: 'pointer',
|
|
110
|
+
eventType: 'start',
|
|
111
|
+
order: 3,
|
|
112
|
+
windowEvent: false
|
|
113
|
+
},
|
|
114
|
+
pointermove: {
|
|
115
|
+
to: 'mousemove',
|
|
116
|
+
inputType: 'pointer',
|
|
117
|
+
eventType: 'move',
|
|
118
|
+
order: 3,
|
|
119
|
+
windowEvent: false
|
|
120
|
+
},
|
|
121
|
+
pointerup: {
|
|
122
|
+
to: 'mouseup',
|
|
123
|
+
inputType: 'pointer',
|
|
124
|
+
eventType: 'end',
|
|
125
|
+
order: 3,
|
|
126
|
+
windowEvent: false
|
|
127
|
+
},
|
|
128
|
+
pointercancel: {
|
|
129
|
+
to: 'mousecancel',
|
|
130
|
+
inputType: 'pointer',
|
|
131
|
+
eventType: 'cancel',
|
|
132
|
+
order: 3,
|
|
133
|
+
windowEvent: false
|
|
134
|
+
},
|
|
135
|
+
wheel: {
|
|
136
|
+
to: 'wheel',
|
|
137
|
+
inputType: '',
|
|
138
|
+
eventType: 'wheel',
|
|
139
|
+
order: 1,
|
|
140
|
+
windowEvent: false
|
|
141
|
+
},
|
|
142
|
+
DOMMouseScroll: {
|
|
143
|
+
to: 'wheel',
|
|
144
|
+
inputType: '',
|
|
145
|
+
eventType: 'wheel',
|
|
146
|
+
order: 1,
|
|
147
|
+
windowEvent: false
|
|
148
|
+
},
|
|
149
|
+
mousewheel: {
|
|
150
|
+
to: 'wheel',
|
|
151
|
+
inputType: '',
|
|
152
|
+
eventType: 'wheel',
|
|
153
|
+
order: 1,
|
|
154
|
+
windowEvent: false
|
|
155
|
+
},
|
|
156
|
+
keyup: {
|
|
157
|
+
to: 'key',
|
|
158
|
+
inputType: '',
|
|
159
|
+
eventType: 'key',
|
|
160
|
+
order: 1,
|
|
161
|
+
windowEvent: true
|
|
162
|
+
},
|
|
163
|
+
keydown: {
|
|
164
|
+
to: 'key',
|
|
165
|
+
inputType: '',
|
|
166
|
+
eventType: 'key',
|
|
167
|
+
order: 1,
|
|
168
|
+
windowEvent: true
|
|
169
|
+
},
|
|
170
|
+
resize: {
|
|
171
|
+
to: 'resize',
|
|
172
|
+
inputType: '',
|
|
173
|
+
eventType: 'resize',
|
|
174
|
+
order: 1,
|
|
175
|
+
windowEvent: true
|
|
176
|
+
},
|
|
177
|
+
orientationchange: {
|
|
178
|
+
to: 'resize',
|
|
179
|
+
inputType: '',
|
|
180
|
+
eventType: 'resize',
|
|
181
|
+
order: 1,
|
|
182
|
+
windowEvent: true
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
this.domEvents = Object.keys(this.eventMap).filter(function (key) {
|
|
186
|
+
return !_this.eventMap[key].windowEvent;
|
|
187
|
+
});
|
|
188
|
+
this.windowEvents = Object.keys(this.eventMap).filter(function (key) {
|
|
189
|
+
return _this.eventMap[key].windowEvent;
|
|
190
|
+
});
|
|
191
|
+
this.bindedHandleEvent = this.bindedHandleEvent || this.handleEvent.bind(this);
|
|
192
|
+
}
|
|
193
|
+
return _createClass(EventListener, [{
|
|
194
|
+
key: "removeHandlers",
|
|
195
|
+
value: function removeHandlers($dom) {
|
|
196
|
+
var _this2 = this;
|
|
197
|
+
this.domEvents.forEach(function (key) {
|
|
198
|
+
$dom.detachEvent(key, _this2.bindedHandleEvent);
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
}, {
|
|
202
|
+
key: "addHandlers",
|
|
203
|
+
value: function addHandlers($dom) {
|
|
204
|
+
var _this3 = this;
|
|
205
|
+
this.domEvents.forEach(function (key) {
|
|
206
|
+
$dom.addEvent(key, _this3.bindedHandleEvent);
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
}, {
|
|
210
|
+
key: "removeWindowHandlers",
|
|
211
|
+
value: function removeWindowHandlers() {
|
|
212
|
+
var _this4 = this;
|
|
213
|
+
this.windowEvents.forEach(function (key) {
|
|
214
|
+
_App.tApp.$window.detachEvent(key, _this4.bindedHandleEvent);
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
}, {
|
|
218
|
+
key: "addWindowHandlers",
|
|
219
|
+
value: function addWindowHandlers() {
|
|
220
|
+
var _this5 = this;
|
|
221
|
+
this.windowEvents.forEach(function (key) {
|
|
222
|
+
_App.tApp.$window.addEvent(key, _this5.bindedHandleEvent);
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
}, {
|
|
226
|
+
key: "captureEvents",
|
|
227
|
+
value: function captureEvents() {
|
|
228
|
+
if (this.eventQueue.length === 0) {
|
|
229
|
+
this.currentEvent = "";
|
|
230
|
+
this.currentKey = "";
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
var lastEvent = this.eventQueue.shift();
|
|
234
|
+
if (lastEvent.eventName === 'resize') {
|
|
235
|
+
_App.tApp.dim.measureScreen();
|
|
236
|
+
} else {
|
|
237
|
+
if (lastEvent.tmodel) {
|
|
238
|
+
this.findEventHandlers(lastEvent.tmodel);
|
|
239
|
+
}
|
|
240
|
+
this.currentEvent = lastEvent.eventName;
|
|
241
|
+
this.currentKey = this.currentTouch.key;
|
|
242
|
+
this.currentTouch.key = "";
|
|
243
|
+
}
|
|
244
|
+
_App.tApp.manager.scheduleRun(10, "captureEvents-".concat(lastEvent));
|
|
245
|
+
}
|
|
246
|
+
}, {
|
|
247
|
+
key: "handleEvent",
|
|
248
|
+
value: function handleEvent(event) {
|
|
249
|
+
if (!event) {
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
var originalName = event.type;
|
|
253
|
+
var eventItem = this.eventMap[originalName];
|
|
254
|
+
if (!eventItem) {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
var eventName = eventItem.to,
|
|
258
|
+
inputType = eventItem.inputType,
|
|
259
|
+
eventType = eventItem.eventType,
|
|
260
|
+
eventOrder = eventItem.order;
|
|
261
|
+
var now = _Browser.browser.now();
|
|
262
|
+
this.touchTimeStamp = Math.max(now, this.touchTimeStamp);
|
|
263
|
+
var tmodel = this.getTModelFromEvent(event);
|
|
264
|
+
var lastEvent = this.eventQueue.length > 0 ? this.eventQueue[this.eventQueue.length - 1] : null;
|
|
265
|
+
if (lastEvent) {
|
|
266
|
+
var lastEventItem = lastEvent.eventItem;
|
|
267
|
+
var rate = now - lastEvent.timeStamp;
|
|
268
|
+
if (inputType && lastEventItem.inputType && lastEventItem.inputType !== inputType && eventOrder > lastEventItem.order) {
|
|
269
|
+
return;
|
|
270
|
+
} else if (this.eventQueue.length > 10 && rate < 50) {
|
|
271
|
+
var capacity = 0;
|
|
272
|
+
for (var i = this.eventQueue.length - 1; i >= 0 && this.eventQueue[i].eventItem.eventType === eventType; i--) {
|
|
273
|
+
if (++capacity > 5) {
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
this.eventQueue.push({
|
|
280
|
+
eventName: eventName,
|
|
281
|
+
eventItem: eventItem,
|
|
282
|
+
originalName: originalName,
|
|
283
|
+
tmodel: tmodel,
|
|
284
|
+
timeStamp: now
|
|
285
|
+
});
|
|
286
|
+
switch (eventName) {
|
|
287
|
+
case 'mousedown':
|
|
288
|
+
case 'touchstart':
|
|
289
|
+
this.clearStart();
|
|
290
|
+
this.clearTouch();
|
|
291
|
+
this.touchCount = this.countTouches(event);
|
|
292
|
+
if (this.preventDefault(tmodel, eventName)) {
|
|
293
|
+
event.preventDefault();
|
|
294
|
+
}
|
|
295
|
+
this.start0 = this.getTouch(event);
|
|
296
|
+
this.start1 = this.getTouch(event, 1);
|
|
297
|
+
this.cursor.x = this.start0.x;
|
|
298
|
+
this.cursor.y = this.start0.y;
|
|
299
|
+
event.stopPropagation();
|
|
300
|
+
break;
|
|
301
|
+
case 'mousemove':
|
|
302
|
+
case 'touchmove':
|
|
303
|
+
{
|
|
304
|
+
var touch = this.getTouch(event);
|
|
305
|
+
this.cursor.x = touch.x;
|
|
306
|
+
this.cursor.y = touch.y;
|
|
307
|
+
if (this.preventDefault(tmodel, eventName)) {
|
|
308
|
+
event.preventDefault();
|
|
309
|
+
}
|
|
310
|
+
if (this.touchCount > 0) {
|
|
311
|
+
this.move(event);
|
|
312
|
+
event.stopPropagation();
|
|
313
|
+
}
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
case 'mouseup':
|
|
317
|
+
case 'touchend':
|
|
318
|
+
if (this.preventDefault(tmodel, eventName)) {
|
|
319
|
+
event.preventDefault();
|
|
320
|
+
}
|
|
321
|
+
this.end(event);
|
|
322
|
+
if (this.start0) {
|
|
323
|
+
var deltaX = this.end0 ? Math.abs(this.end0.originalX - this.start0.originalX) : 0;
|
|
324
|
+
var deltaY = this.end0 ? Math.abs(this.end0.originalY - this.start0.originalY) : 0;
|
|
325
|
+
var period = this.end0 ? Math.abs(this.end0.timeStamp - this.start0.timeStamp) : 300;
|
|
326
|
+
if (deltaX <= 1 && deltaY <= 1 && period <= 300) {
|
|
327
|
+
this.eventQueue.push({
|
|
328
|
+
eventName: 'click',
|
|
329
|
+
eventItem: eventItem,
|
|
330
|
+
originalName: originalName,
|
|
331
|
+
tmodel: tmodel,
|
|
332
|
+
timeStamp: now
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
this.clearStart();
|
|
337
|
+
this.touchCount = 0;
|
|
338
|
+
event.stopPropagation();
|
|
339
|
+
break;
|
|
340
|
+
case 'wheel':
|
|
341
|
+
if (this.preventDefault(tmodel, eventName)) {
|
|
342
|
+
event.preventDefault();
|
|
343
|
+
}
|
|
344
|
+
this.wheel(event);
|
|
345
|
+
break;
|
|
346
|
+
case 'key':
|
|
347
|
+
this.currentTouch.key = event.which || event.keyCode;
|
|
348
|
+
break;
|
|
349
|
+
}
|
|
350
|
+
_App.tApp.manager.scheduleRun(0, "".concat(originalName, "-").concat(eventName, "-").concat((event.target.tagName || "").toUpperCase()));
|
|
351
|
+
}
|
|
352
|
+
}, {
|
|
353
|
+
key: "findEventHandlers",
|
|
354
|
+
value: function findEventHandlers(tmodel) {
|
|
355
|
+
var touchHandler = tmodel ? _SearchUtil.SearchUtil.findFirstTouchHandler(tmodel) : null;
|
|
356
|
+
var scrollLeftHandler = this.end0 ? this.currentHandlers.scrollLeft : tmodel ? _SearchUtil.SearchUtil.findFirstScrollLeftHandler(tmodel) : null;
|
|
357
|
+
var scrollTopHandler = this.end0 ? this.currentHandlers.scrollTop : tmodel ? _SearchUtil.SearchUtil.findFirstScrollTopHandler(tmodel) : null;
|
|
358
|
+
var pinchHandler = tmodel ? _SearchUtil.SearchUtil.findFirstPinchHandler(tmodel) : null;
|
|
359
|
+
if (this.currentHandlers.scrollLeft !== scrollLeftHandler || this.currentHandlers.scrollTop !== scrollTopHandler) {
|
|
360
|
+
this.clearTouch();
|
|
361
|
+
}
|
|
362
|
+
this.currentHandlers.touch = touchHandler;
|
|
363
|
+
this.currentHandlers.scrollLeft = scrollLeftHandler;
|
|
364
|
+
this.currentHandlers.scrollTop = scrollTopHandler;
|
|
365
|
+
this.currentHandlers.pinch = pinchHandler;
|
|
366
|
+
}
|
|
367
|
+
}, {
|
|
368
|
+
key: "preventDefault",
|
|
369
|
+
value: function preventDefault(tmodel, eventName) {
|
|
370
|
+
if (tmodel && (tmodel.keepEventDefault() === true || Array.isArray(tmodel.keepEventDefault()) && tmodel.keepEventDefault().includes(eventName))) {
|
|
371
|
+
return false;
|
|
372
|
+
}
|
|
373
|
+
return true;
|
|
374
|
+
}
|
|
375
|
+
}, {
|
|
376
|
+
key: "getTModelFromEvent",
|
|
377
|
+
value: function getTModelFromEvent(event) {
|
|
378
|
+
var oid = typeof event.target.getAttribute === 'function' ? event.target.getAttribute('id') : '';
|
|
379
|
+
if (!oid || !_App.tApp.manager.visibleOidMap[oid]) {
|
|
380
|
+
oid = _$Dom.$Dom.findNearestParentWithId(event.target);
|
|
381
|
+
}
|
|
382
|
+
return _App.tApp.manager.visibleOidMap[oid];
|
|
383
|
+
}
|
|
384
|
+
}, {
|
|
385
|
+
key: "clearStart",
|
|
386
|
+
value: function clearStart() {
|
|
387
|
+
this.start0 = undefined;
|
|
388
|
+
this.start1 = undefined;
|
|
389
|
+
this.end0 = undefined;
|
|
390
|
+
this.end1 = undefined;
|
|
391
|
+
this.touchCount = 0;
|
|
392
|
+
}
|
|
393
|
+
}, {
|
|
394
|
+
key: "clearTouch",
|
|
395
|
+
value: function clearTouch() {
|
|
396
|
+
this.currentTouch = {
|
|
397
|
+
deltaY: 0,
|
|
398
|
+
deltaX: 0,
|
|
399
|
+
pinchDelta: 0,
|
|
400
|
+
key: '',
|
|
401
|
+
manualMomentumFlag: false,
|
|
402
|
+
orientation: "none",
|
|
403
|
+
dir: "",
|
|
404
|
+
source: ""
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
}, {
|
|
408
|
+
key: "clearAll",
|
|
409
|
+
value: function clearAll() {
|
|
410
|
+
this.clearStart();
|
|
411
|
+
this.clearTouch();
|
|
412
|
+
this.eventQueue.length = 0;
|
|
413
|
+
this.touchTimeStamp = 0;
|
|
414
|
+
}
|
|
415
|
+
}, {
|
|
416
|
+
key: "resetEventsOnTimeout",
|
|
417
|
+
value: function resetEventsOnTimeout() {
|
|
418
|
+
if (this.touchTimeStamp > 0) {
|
|
419
|
+
var diff = _Browser.browser.now() - this.touchTimeStamp;
|
|
420
|
+
var runDelay = 0;
|
|
421
|
+
if (Math.abs(this.currentTouch.deltaY) > 0.001 || Math.abs(this.currentTouch.deltaX) > 0.001 || Math.abs(this.currentTouch.pinchDelta) > 0.001) {
|
|
422
|
+
if (diff > 70) {
|
|
423
|
+
this.clearTouch();
|
|
424
|
+
} else if (this.currentTouch.manualMomentumFlag) {
|
|
425
|
+
this.currentTouch.deltaY *= 0.85;
|
|
426
|
+
this.currentTouch.deltaX *= 0.85;
|
|
427
|
+
runDelay = 10;
|
|
428
|
+
}
|
|
429
|
+
} else if (diff > 600) {
|
|
430
|
+
this.clearTouch();
|
|
431
|
+
this.touchTimeStamp = 0;
|
|
432
|
+
}
|
|
433
|
+
_App.tApp.manager.scheduleRun(runDelay, "scroll decay");
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}, {
|
|
437
|
+
key: "deltaX",
|
|
438
|
+
value: function deltaX() {
|
|
439
|
+
return this.currentTouch.deltaX;
|
|
440
|
+
}
|
|
441
|
+
}, {
|
|
442
|
+
key: "deltaY",
|
|
443
|
+
value: function deltaY() {
|
|
444
|
+
return this.currentTouch.deltaY;
|
|
445
|
+
}
|
|
446
|
+
}, {
|
|
447
|
+
key: "pinchDelta",
|
|
448
|
+
value: function pinchDelta() {
|
|
449
|
+
return this.currentTouch.pinchDelta;
|
|
450
|
+
}
|
|
451
|
+
}, {
|
|
452
|
+
key: "dir",
|
|
453
|
+
value: function dir() {
|
|
454
|
+
return this.currentTouch.dir;
|
|
455
|
+
}
|
|
456
|
+
}, {
|
|
457
|
+
key: "getScrollLeftHandler",
|
|
458
|
+
value: function getScrollLeftHandler() {
|
|
459
|
+
return this.currentHandlers.scrollLeft;
|
|
460
|
+
}
|
|
461
|
+
}, {
|
|
462
|
+
key: "getScrollTopHandler",
|
|
463
|
+
value: function getScrollTopHandler() {
|
|
464
|
+
return this.currentHandlers.scrollTop;
|
|
465
|
+
}
|
|
466
|
+
}, {
|
|
467
|
+
key: "getPinchHandler",
|
|
468
|
+
value: function getPinchHandler() {
|
|
469
|
+
return this.currentHandlers.pinch;
|
|
470
|
+
}
|
|
471
|
+
}, {
|
|
472
|
+
key: "getTouchHandler",
|
|
473
|
+
value: function getTouchHandler() {
|
|
474
|
+
return this.currentHandlers.touch;
|
|
475
|
+
}
|
|
476
|
+
}, {
|
|
477
|
+
key: "getTouchHandlerType",
|
|
478
|
+
value: function getTouchHandlerType() {
|
|
479
|
+
return this.currentHandlers.touch ? this.currentHandlers.touch.type : null;
|
|
480
|
+
}
|
|
481
|
+
}, {
|
|
482
|
+
key: "getTouchHandlerOid",
|
|
483
|
+
value: function getTouchHandlerOid() {
|
|
484
|
+
return this.currentHandlers.touch ? this.currentHandlers.touch.oid : null;
|
|
485
|
+
}
|
|
486
|
+
}, {
|
|
487
|
+
key: "isClickEvent",
|
|
488
|
+
value: function isClickEvent() {
|
|
489
|
+
return this.currentEvent === 'click';
|
|
490
|
+
}
|
|
491
|
+
}, {
|
|
492
|
+
key: "isResizeEvent",
|
|
493
|
+
value: function isResizeEvent() {
|
|
494
|
+
return this.currentEvent === 'resize';
|
|
495
|
+
}
|
|
496
|
+
}, {
|
|
497
|
+
key: "getCurrentEvent",
|
|
498
|
+
value: function getCurrentEvent() {
|
|
499
|
+
return this.currentEvent;
|
|
500
|
+
}
|
|
501
|
+
}, {
|
|
502
|
+
key: "isClickHandler",
|
|
503
|
+
value: function isClickHandler(target) {
|
|
504
|
+
return this.getTouchHandler() === target && this.isClickEvent();
|
|
505
|
+
}
|
|
506
|
+
}, {
|
|
507
|
+
key: "isClickHandlerType",
|
|
508
|
+
value: function isClickHandlerType(type) {
|
|
509
|
+
return this.getTouchHandlerType() === type && this.isClickEvent();
|
|
510
|
+
}
|
|
511
|
+
}, {
|
|
512
|
+
key: "isTouchHandler",
|
|
513
|
+
value: function isTouchHandler(handler) {
|
|
514
|
+
return this.getTouchHandler() === handler && handler.canHandleEvents('touch');
|
|
515
|
+
}
|
|
516
|
+
}, {
|
|
517
|
+
key: "isScrollLeftHandler",
|
|
518
|
+
value: function isScrollLeftHandler(handler) {
|
|
519
|
+
return this.currentHandlers.scrollLeft === handler;
|
|
520
|
+
}
|
|
521
|
+
}, {
|
|
522
|
+
key: "isScrollTopHandler",
|
|
523
|
+
value: function isScrollTopHandler(handler) {
|
|
524
|
+
return this.currentHandlers.scrollTop === handler;
|
|
525
|
+
}
|
|
526
|
+
}, {
|
|
527
|
+
key: "isPinchHandler",
|
|
528
|
+
value: function isPinchHandler(handler) {
|
|
529
|
+
return this.currentHandlers.pinch === handler;
|
|
530
|
+
}
|
|
531
|
+
}, {
|
|
532
|
+
key: "isCurrentSource",
|
|
533
|
+
value: function isCurrentSource(source) {
|
|
534
|
+
return this.currentTouch.source === source;
|
|
535
|
+
}
|
|
536
|
+
}, {
|
|
537
|
+
key: "isTouchHandlerType",
|
|
538
|
+
value: function isTouchHandlerType(type) {
|
|
539
|
+
return this.getTouchHandlerType() === type;
|
|
540
|
+
}
|
|
541
|
+
}, {
|
|
542
|
+
key: "isTouchHandlerOrAncestor",
|
|
543
|
+
value: function isTouchHandlerOrAncestor(target) {
|
|
544
|
+
var handler = this.getTouchHandler();
|
|
545
|
+
while (handler) {
|
|
546
|
+
if (handler === target) {
|
|
547
|
+
return true;
|
|
548
|
+
}
|
|
549
|
+
handler = handler.getParent();
|
|
550
|
+
}
|
|
551
|
+
return false;
|
|
552
|
+
}
|
|
553
|
+
}, {
|
|
554
|
+
key: "countTouches",
|
|
555
|
+
value: function countTouches(event) {
|
|
556
|
+
var _event$touches, _event$originalEvent;
|
|
557
|
+
return ((_event$touches = event.touches) === null || _event$touches === void 0 ? void 0 : _event$touches.length) || ((_event$originalEvent = event.originalEvent) === null || _event$originalEvent === void 0 || (_event$originalEvent = _event$originalEvent.touches) === null || _event$originalEvent === void 0 ? void 0 : _event$originalEvent.length) || 1;
|
|
558
|
+
}
|
|
559
|
+
}, {
|
|
560
|
+
key: "getTouch",
|
|
561
|
+
value: function getTouch(event) {
|
|
562
|
+
var _event$touches2, _event$originalEvent2;
|
|
563
|
+
var index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
564
|
+
var e = ((_event$touches2 = event.touches) === null || _event$touches2 === void 0 ? void 0 : _event$touches2[index]) || ((_event$originalEvent2 = event.originalEvent) === null || _event$originalEvent2 === void 0 || (_event$originalEvent2 = _event$originalEvent2.touches) === null || _event$originalEvent2 === void 0 ? void 0 : _event$originalEvent2[index]) || event;
|
|
565
|
+
var x = _TUtil.TUtil.isDefined(e.clientX) ? e.clientX : e.pageX || 0;
|
|
566
|
+
var y = _TUtil.TUtil.isDefined(e.clientY) ? e.clientY : e.pageY || 0;
|
|
567
|
+
return {
|
|
568
|
+
x: x,
|
|
569
|
+
y: y,
|
|
570
|
+
originalX: x,
|
|
571
|
+
originalY: y,
|
|
572
|
+
target: e.target,
|
|
573
|
+
timeStamp: _Browser.browser.now()
|
|
574
|
+
};
|
|
575
|
+
}
|
|
576
|
+
}, {
|
|
577
|
+
key: "move",
|
|
578
|
+
value: function move(event) {
|
|
579
|
+
if (this.touchCount === 1) {
|
|
580
|
+
this.start0.y = this.end0 ? this.end0.y : this.start0.y;
|
|
581
|
+
this.start0.x = this.end0 ? this.end0.x : this.start0.x;
|
|
582
|
+
this.end0 = this.getTouch(event);
|
|
583
|
+
if (_TUtil.TUtil.isDefined(this.end0)) {
|
|
584
|
+
var deltaX = this.start0.x - this.end0.x;
|
|
585
|
+
var deltaY = this.start0.y - this.end0.y;
|
|
586
|
+
this.setDeltaXDeltaY(deltaX, deltaY, 'touch');
|
|
587
|
+
}
|
|
588
|
+
} else if (this.touchCount >= 2) {
|
|
589
|
+
this.end0 = this.getTouch(event);
|
|
590
|
+
this.end1 = this.getTouch(event, 1);
|
|
591
|
+
var length1 = _TUtil.TUtil.distance(this.start0.x, this.start0.y, this.start1.x, this.start1.y);
|
|
592
|
+
var length2 = _TUtil.TUtil.distance(this.end0.x, this.end0.y, this.end1.x, this.end1.y);
|
|
593
|
+
var diff = length2 - length1;
|
|
594
|
+
this.currentTouch.pinchDelta = diff > 0 ? 0.3 : diff < 0 ? -0.3 : 0;
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
}, {
|
|
598
|
+
key: "end",
|
|
599
|
+
value: function end() {
|
|
600
|
+
if (this.touchCount <= 1 && this.start0) {
|
|
601
|
+
var deltaX = this.end0 ? this.start0.x - this.end0.x : 0;
|
|
602
|
+
var deltaY = this.end0 ? this.start0.y - this.end0.y : 0;
|
|
603
|
+
var period = this.end0 ? this.end0.timeStamp - this.start0.timeStamp : 0;
|
|
604
|
+
var momentum;
|
|
605
|
+
if (this.currentTouch.orientation === "horizontal" && Math.abs(deltaX) > 1) {
|
|
606
|
+
momentum = _TUtil.TUtil.momentum(0, deltaX, period);
|
|
607
|
+
this.currentTouch.deltaX = momentum.distance;
|
|
608
|
+
this.currentTouch.manualMomentumFlag = true;
|
|
609
|
+
this.touchTimeStamp = _Browser.browser.now() + momentum.duration;
|
|
610
|
+
} else if (this.currentTouch.orientation === "vertical" && Math.abs(deltaY) > 1) {
|
|
611
|
+
momentum = _TUtil.TUtil.momentum(0, deltaY, period);
|
|
612
|
+
this.currentTouch.deltaY = momentum.distance;
|
|
613
|
+
this.currentTouch.manualMomentumFlag = true;
|
|
614
|
+
this.touchTimeStamp = _Browser.browser.now() + momentum.duration;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
}, {
|
|
619
|
+
key: "setDeltaXDeltaY",
|
|
620
|
+
value: function setDeltaXDeltaY(deltaX, deltaY, source) {
|
|
621
|
+
var diff = Math.abs(deltaX) - Math.abs(deltaY);
|
|
622
|
+
if (diff >= 1) {
|
|
623
|
+
if (this.currentTouch.orientation === "none" || this.currentTouch.orientation === "vertical" && diff > 3 || this.currentTouch.orientation === "horizontal") {
|
|
624
|
+
this.currentTouch.orientation = "horizontal";
|
|
625
|
+
this.currentTouch.dir = deltaX <= -1 ? "left" : deltaX >= 1 ? "right" : this.currentTouch.dir;
|
|
626
|
+
this.currentTouch.source = source;
|
|
627
|
+
this.currentTouch.deltaX = deltaX;
|
|
628
|
+
this.currentTouch.deltaY = 0;
|
|
629
|
+
}
|
|
630
|
+
} else if (this.currentTouch.orientation === "none" || this.currentTouch.orientation === "horizontal" && diff < -3 || this.currentTouch.orientation === "vertical") {
|
|
631
|
+
this.currentTouch.orientation = "vertical";
|
|
632
|
+
this.currentTouch.dir = deltaY <= -1 ? "up" : deltaY >= 1 ? "down" : this.currentTouch.dir;
|
|
633
|
+
this.currentTouch.source = source;
|
|
634
|
+
this.currentTouch.deltaY = deltaY;
|
|
635
|
+
this.currentTouch.deltaX = 0;
|
|
636
|
+
} else {
|
|
637
|
+
this.currentTouch.deltaY = 0;
|
|
638
|
+
this.currentTouch.deltaX = 0;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
}, {
|
|
642
|
+
key: "wheel",
|
|
643
|
+
value: function wheel(event) {
|
|
644
|
+
var deltaX = 0;
|
|
645
|
+
var deltaY = 0;
|
|
646
|
+
this.currentTouch.pinchDelta = 0;
|
|
647
|
+
this.start0 = this.getTouch(event);
|
|
648
|
+
if (event.ctrlKey && 'deltaY' in event) {
|
|
649
|
+
this.currentTouch.pinchDelta = -event.deltaY / 10;
|
|
650
|
+
} else if ('deltaX' in event) {
|
|
651
|
+
deltaX = event.deltaX;
|
|
652
|
+
deltaY = event.deltaY;
|
|
653
|
+
} else if ('wheelDeltaX' in event) {
|
|
654
|
+
deltaX = -event.wheelDeltaX / 120;
|
|
655
|
+
deltaY = -event.wheelDeltaY / 120;
|
|
656
|
+
} else if ('wheelDelta' in event) {
|
|
657
|
+
deltaX = -event.wheelDelta / 120;
|
|
658
|
+
} else if ('detail' in event) {
|
|
659
|
+
deltaX = event.detail / 3;
|
|
660
|
+
}
|
|
661
|
+
this.setDeltaXDeltaY(deltaX, deltaY, 'wheel');
|
|
662
|
+
}
|
|
663
|
+
}]);
|
|
664
|
+
}();
|