targetj 1.0.253 → 1.0.254
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/build/EventListener.js +41 -36
- package/package.json +1 -1
package/build/EventListener.js
CHANGED
|
@@ -94,6 +94,7 @@ var EventListener = /*#__PURE__*/function () {
|
|
|
94
94
|
this.bindedHandleWindowEvent = this.handleWindowEvent.bind(this);
|
|
95
95
|
this.bindedHandleEvent = this.handleEvent.bind(this);
|
|
96
96
|
this.bindedParentHandleEvent = this.handleDocEvent.bind(this);
|
|
97
|
+
this.maxPointerMoveDistance = 0;
|
|
97
98
|
}
|
|
98
99
|
return _createClass(EventListener, [{
|
|
99
100
|
key: "detachWindowEvents",
|
|
@@ -223,38 +224,43 @@ var EventListener = /*#__PURE__*/function () {
|
|
|
223
224
|
}, {
|
|
224
225
|
key: "resetEventsOnTimeout",
|
|
225
226
|
value: function resetEventsOnTimeout() {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
this.currentTouch.pinchDelta = 0;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
if (diff <= 0) {
|
|
227
|
+
var hasPendingScroll = this.scrollEndTimeStamp.x > 0 || this.scrollEndTimeStamp.y > 0 || this.currentTouch.pinchDelta !== 0;
|
|
228
|
+
if (!hasPendingScroll) {
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
if (this.touchCount > 0) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
var now = TUtil.now();
|
|
235
|
+
var diff = Math.max(this.scrollEndTimeStamp.x - now, this.scrollEndTimeStamp.y - now);
|
|
236
|
+
if (diff > 100) {
|
|
237
|
+
this.currentTouch.deltaY *= 0.95;
|
|
238
|
+
this.currentTouch.deltaX *= 0.95;
|
|
239
|
+
this.currentTouch.pinchDelta *= 0.95;
|
|
240
|
+
if (Math.abs(this.currentTouch.deltaY) < 0.1) {
|
|
244
241
|
this.currentTouch.deltaY = 0;
|
|
245
|
-
this.currentTouch.deltaX = 0;
|
|
246
|
-
this.currentTouch.pinchDelta = 0;
|
|
247
242
|
}
|
|
248
|
-
if (
|
|
249
|
-
this.
|
|
250
|
-
this.queueScrollEndEvent('x', this.currentHandlers.scrollLeft);
|
|
243
|
+
if (Math.abs(this.currentTouch.deltaX) < 0.1) {
|
|
244
|
+
this.currentTouch.deltaX = 0;
|
|
251
245
|
}
|
|
252
|
-
if (
|
|
253
|
-
this.
|
|
254
|
-
this.scrollEndTimeStamp.y = 0;
|
|
246
|
+
if (Math.abs(this.currentTouch.pinchDelta) < 0.1) {
|
|
247
|
+
this.currentTouch.pinchDelta = 0;
|
|
255
248
|
}
|
|
256
|
-
getRunScheduler().schedule(10, 'scroll decay');
|
|
257
249
|
}
|
|
250
|
+
if (diff <= 0) {
|
|
251
|
+
this.currentTouch.deltaY = 0;
|
|
252
|
+
this.currentTouch.deltaX = 0;
|
|
253
|
+
this.currentTouch.pinchDelta = 0;
|
|
254
|
+
}
|
|
255
|
+
if (!this.currentTouch.deltaX && this.scrollEndTimeStamp.x && now >= this.scrollEndTimeStamp.x) {
|
|
256
|
+
this.scrollEndTimeStamp.x = 0;
|
|
257
|
+
this.queueScrollEndEvent('x', this.currentHandlers.scrollLeft);
|
|
258
|
+
}
|
|
259
|
+
if (!this.currentTouch.deltaY && this.scrollEndTimeStamp.y && now >= this.scrollEndTimeStamp.y) {
|
|
260
|
+
this.queueScrollEndEvent('y', this.currentHandlers.scrollTop);
|
|
261
|
+
this.scrollEndTimeStamp.y = 0;
|
|
262
|
+
}
|
|
263
|
+
getRunScheduler().schedule(10, 'scroll decay');
|
|
258
264
|
}
|
|
259
265
|
}, {
|
|
260
266
|
key: "findEventHandlers",
|
|
@@ -448,6 +454,7 @@ var EventListener = /*#__PURE__*/function () {
|
|
|
448
454
|
switch (eventName) {
|
|
449
455
|
case 'mousedown':
|
|
450
456
|
case 'touchstart':
|
|
457
|
+
this.maxPointerMoveDistance = 0;
|
|
451
458
|
this.clearStart();
|
|
452
459
|
this.clearEnd();
|
|
453
460
|
this.clearTouch();
|
|
@@ -509,7 +516,7 @@ var EventListener = /*#__PURE__*/function () {
|
|
|
509
516
|
}
|
|
510
517
|
this.end0 = this.getTouch(event);
|
|
511
518
|
var clickHandler = SearchUtil.findFirstClickHandler(tmodel);
|
|
512
|
-
var canAcceptClick = !this.start0 || clickHandler === this.currentHandlers.click &&
|
|
519
|
+
var canAcceptClick = !this.start0 || clickHandler === this.currentHandlers.click && this.maxPointerMoveDistance < EventListener.CLICK_MOVE_THRESHOLD;
|
|
513
520
|
if (clickHandler && canAcceptClick) {
|
|
514
521
|
this.eventQueue.length = 0;
|
|
515
522
|
this.eventQueue.push({
|
|
@@ -524,6 +531,7 @@ var EventListener = /*#__PURE__*/function () {
|
|
|
524
531
|
}
|
|
525
532
|
this.clearEnd();
|
|
526
533
|
this.clearStart();
|
|
534
|
+
this.maxPointerMoveDistance = 0;
|
|
527
535
|
this.touchCount = 0;
|
|
528
536
|
event.stopPropagation();
|
|
529
537
|
break;
|
|
@@ -555,6 +563,7 @@ var EventListener = /*#__PURE__*/function () {
|
|
|
555
563
|
this.clearStart();
|
|
556
564
|
this.clearEnd();
|
|
557
565
|
this.clearTouch();
|
|
566
|
+
this.maxPointerMoveDistance = 0;
|
|
558
567
|
this.touchCount = 0;
|
|
559
568
|
event.stopPropagation();
|
|
560
569
|
break;
|
|
@@ -726,6 +735,7 @@ var EventListener = /*#__PURE__*/function () {
|
|
|
726
735
|
this.windowScrollEndTimer = 0;
|
|
727
736
|
this.scrollEndTimeStamp.x = 0;
|
|
728
737
|
this.scrollEndTimeStamp.y = 0;
|
|
738
|
+
this.maxPointerMoveDistance = 0;
|
|
729
739
|
this.currentHandlers = {
|
|
730
740
|
touch: null,
|
|
731
741
|
click: null,
|
|
@@ -773,14 +783,6 @@ var EventListener = /*#__PURE__*/function () {
|
|
|
773
783
|
value: function swipeY() {
|
|
774
784
|
return this.cursor.y - this.swipeStartY;
|
|
775
785
|
}
|
|
776
|
-
}, {
|
|
777
|
-
key: "getSwipeDistance",
|
|
778
|
-
value: function getSwipeDistance() {
|
|
779
|
-
if (this.start0 && this.end0) {
|
|
780
|
-
return TUtil.distance(this.start0.originalX, this.start0.originalY, this.end0.x, this.end0.y);
|
|
781
|
-
}
|
|
782
|
-
return 0;
|
|
783
|
-
}
|
|
784
786
|
}, {
|
|
785
787
|
key: "pinchDelta",
|
|
786
788
|
value: function pinchDelta() {
|
|
@@ -1040,6 +1042,8 @@ var EventListener = /*#__PURE__*/function () {
|
|
|
1040
1042
|
this.start0.x = this.end0 ? this.end0.x : this.start0.x;
|
|
1041
1043
|
this.end0 = this.getTouch(event);
|
|
1042
1044
|
if (TUtil.isDefined(this.end0)) {
|
|
1045
|
+
var distance = TUtil.distance(this.start0.originalX, this.start0.originalY, this.end0.x, this.end0.y);
|
|
1046
|
+
this.maxPointerMoveDistance = Math.max(this.maxPointerMoveDistance, distance);
|
|
1043
1047
|
var deltaX = this.start0.x - this.end0.x;
|
|
1044
1048
|
var deltaY = this.start0.y - this.end0.y;
|
|
1045
1049
|
this.setDeltaXDeltaY(deltaX, deltaY, 'touch');
|
|
@@ -1144,4 +1148,5 @@ var EventListener = /*#__PURE__*/function () {
|
|
|
1144
1148
|
}();
|
|
1145
1149
|
_defineProperty(EventListener, "MAX_EVENT_QUEUE_SIZE", 10);
|
|
1146
1150
|
_defineProperty(EventListener, "MAX_EVENT_TYPE_CAPACITY", 2);
|
|
1151
|
+
_defineProperty(EventListener, "CLICK_MOVE_THRESHOLD", 10);
|
|
1147
1152
|
export { EventListener };
|