@vaadin/component-base 23.1.0-alpha3 → 23.1.0-beta2
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/custom_typings/vaadin.d.ts +3 -3
- package/package.json +2 -2
- package/src/active-mixin.d.ts +1 -1
- package/src/async.d.ts +114 -0
- package/src/async.js +11 -7
- package/src/browser-utils.js +1 -1
- package/src/controller-mixin.d.ts +1 -1
- package/src/controller-mixin.js +7 -3
- package/src/debounce.d.ts +101 -0
- package/src/dir-helper.d.ts +1 -1
- package/src/dir-mixin.js +15 -5
- package/src/disabled-mixin.js +3 -3
- package/src/element-mixin.d.ts +1 -1
- package/src/element-mixin.js +2 -2
- package/src/focus-mixin.js +5 -5
- package/src/gestures.d.ts +8 -8
- package/src/gestures.js +80 -81
- package/src/iron-list-core.js +96 -94
- package/src/keyboard-mixin.js +1 -1
- package/src/polylit-mixin.js +11 -11
- package/src/resize-mixin.d.ts +6 -0
- package/src/resize-mixin.js +47 -3
- package/src/slot-controller.d.ts +1 -1
- package/src/slot-mixin.js +1 -1
- package/src/tabindex-mixin.d.ts +1 -1
- package/src/tabindex-mixin.js +3 -3
- package/src/templates.js +1 -1
- package/src/virtualizer-iron-list-adapter.js +29 -14
package/src/gestures.js
CHANGED
|
@@ -26,19 +26,19 @@ import { microTask } from './async.js';
|
|
|
26
26
|
const passiveTouchGestures = false;
|
|
27
27
|
const wrap = (node) => node;
|
|
28
28
|
|
|
29
|
-
//
|
|
29
|
+
// Detect native touch action support
|
|
30
30
|
const HAS_NATIVE_TA = typeof document.head.style.touchAction === 'string';
|
|
31
31
|
const GESTURE_KEY = '__polymerGestures';
|
|
32
32
|
const HANDLED_OBJ = '__polymerGesturesHandled';
|
|
33
33
|
const TOUCH_ACTION = '__polymerGesturesTouchAction';
|
|
34
|
-
//
|
|
34
|
+
// Radius for tap and track
|
|
35
35
|
const TAP_DISTANCE = 25;
|
|
36
36
|
const TRACK_DISTANCE = 5;
|
|
37
|
-
//
|
|
37
|
+
// Number of last N track positions to keep
|
|
38
38
|
const TRACK_LENGTH = 2;
|
|
39
39
|
|
|
40
40
|
const MOUSE_EVENTS = ['mousedown', 'mousemove', 'mouseup', 'click'];
|
|
41
|
-
//
|
|
41
|
+
// An array of bitmask values for mapping MouseEvent.which to MouseEvent.buttons
|
|
42
42
|
const MOUSE_WHICH_TO_BUTTONS = [0, 1, 4, 2];
|
|
43
43
|
const MOUSE_HAS_BUTTONS = (function () {
|
|
44
44
|
try {
|
|
@@ -65,7 +65,7 @@ let supportsPassive = false;
|
|
|
65
65
|
// eslint-disable-next-line getter-return
|
|
66
66
|
get() {
|
|
67
67
|
supportsPassive = true;
|
|
68
|
-
}
|
|
68
|
+
},
|
|
69
69
|
});
|
|
70
70
|
window.addEventListener('test', null, opts);
|
|
71
71
|
window.removeEventListener('test', null, opts);
|
|
@@ -103,7 +103,7 @@ const canBeDisabled = {
|
|
|
103
103
|
optgroup: true,
|
|
104
104
|
option: true,
|
|
105
105
|
select: true,
|
|
106
|
-
textarea: true
|
|
106
|
+
textarea: true,
|
|
107
107
|
};
|
|
108
108
|
|
|
109
109
|
/**
|
|
@@ -112,47 +112,47 @@ const canBeDisabled = {
|
|
|
112
112
|
*/
|
|
113
113
|
function hasLeftMouseButton(ev) {
|
|
114
114
|
const type = ev.type;
|
|
115
|
-
//
|
|
115
|
+
// Exit early if the event is not a mouse event
|
|
116
116
|
if (!isMouseEvent(type)) {
|
|
117
117
|
return false;
|
|
118
118
|
}
|
|
119
|
-
//
|
|
119
|
+
// Ev.button is not reliable for mousemove (0 is overloaded as both left button and no buttons)
|
|
120
120
|
// instead we use ev.buttons (bitmask of buttons) or fall back to ev.which (deprecated, 0 for no buttons, 1 for left button)
|
|
121
121
|
if (type === 'mousemove') {
|
|
122
|
-
//
|
|
122
|
+
// Allow undefined for testing events
|
|
123
123
|
let buttons = ev.buttons === undefined ? 1 : ev.buttons;
|
|
124
124
|
if (ev instanceof window.MouseEvent && !MOUSE_HAS_BUTTONS) {
|
|
125
125
|
buttons = MOUSE_WHICH_TO_BUTTONS[ev.which] || 0;
|
|
126
126
|
}
|
|
127
|
-
//
|
|
127
|
+
// Buttons is a bitmask, check that the left button bit is set (1)
|
|
128
128
|
return Boolean(buttons & 1);
|
|
129
129
|
}
|
|
130
|
-
//
|
|
130
|
+
// Allow undefined for testing events
|
|
131
131
|
const button = ev.button === undefined ? 0 : ev.button;
|
|
132
|
-
//
|
|
132
|
+
// Ev.button is 0 in mousedown/mouseup/click for left button activation
|
|
133
133
|
return button === 0;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
function isSyntheticClick(ev) {
|
|
137
137
|
if (ev.type === 'click') {
|
|
138
|
-
//
|
|
138
|
+
// Ev.detail is 0 for HTMLElement.click in most browsers
|
|
139
139
|
if (ev.detail === 0) {
|
|
140
140
|
return true;
|
|
141
141
|
}
|
|
142
|
-
//
|
|
142
|
+
// In the worst case, check that the x/y position of the click is within
|
|
143
143
|
// the bounding box of the target of the event
|
|
144
144
|
// Thanks IE 10 >:(
|
|
145
145
|
const t = _findOriginalTarget(ev);
|
|
146
|
-
//
|
|
146
|
+
// Make sure the target of the event is an element so we can use getBoundingClientRect,
|
|
147
147
|
// if not, just assume it is a synthetic click
|
|
148
148
|
if (!t.nodeType || /** @type {Element} */ (t).nodeType !== Node.ELEMENT_NODE) {
|
|
149
149
|
return true;
|
|
150
150
|
}
|
|
151
151
|
const bcr = /** @type {Element} */ (t).getBoundingClientRect();
|
|
152
|
-
//
|
|
152
|
+
// Use page x/y to account for scrolling
|
|
153
153
|
const x = ev.pageX,
|
|
154
154
|
y = ev.pageY;
|
|
155
|
-
//
|
|
155
|
+
// Ev is a synthetic click if the position is outside the bounding box of the target
|
|
156
156
|
return !(x >= bcr.left && x <= bcr.right && y >= bcr.top && y <= bcr.bottom);
|
|
157
157
|
}
|
|
158
158
|
return false;
|
|
@@ -161,14 +161,14 @@ function isSyntheticClick(ev) {
|
|
|
161
161
|
const POINTERSTATE = {
|
|
162
162
|
mouse: {
|
|
163
163
|
target: null,
|
|
164
|
-
mouseIgnoreJob: null
|
|
164
|
+
mouseIgnoreJob: null,
|
|
165
165
|
},
|
|
166
166
|
touch: {
|
|
167
167
|
x: 0,
|
|
168
168
|
y: 0,
|
|
169
169
|
id: -1,
|
|
170
|
-
scrollDecided: false
|
|
171
|
-
}
|
|
170
|
+
scrollDecided: false,
|
|
171
|
+
},
|
|
172
172
|
};
|
|
173
173
|
|
|
174
174
|
function firstTouchAction(ev) {
|
|
@@ -228,14 +228,14 @@ export const recognizers = [];
|
|
|
228
228
|
export function deepTargetFind(x, y) {
|
|
229
229
|
let node = document.elementFromPoint(x, y);
|
|
230
230
|
let next = node;
|
|
231
|
-
//
|
|
231
|
+
// This code path is only taken when native ShadowDOM is used
|
|
232
232
|
// if there is a shadowroot, it may have a node at x/y
|
|
233
233
|
// if there is not a shadowroot, exit the loop
|
|
234
234
|
while (next && next.shadowRoot && !window.ShadyDOM) {
|
|
235
|
-
//
|
|
235
|
+
// If there is a node at x/y in the shadowroot, look deeper
|
|
236
236
|
const oldNext = next;
|
|
237
237
|
next = next.shadowRoot.elementFromPoint(x, y);
|
|
238
|
-
//
|
|
238
|
+
// On Safari, elementFromPoint may return the shadowRoot host
|
|
239
239
|
if (oldNext === next) {
|
|
240
240
|
break;
|
|
241
241
|
}
|
|
@@ -247,7 +247,7 @@ export function deepTargetFind(x, y) {
|
|
|
247
247
|
}
|
|
248
248
|
|
|
249
249
|
/**
|
|
250
|
-
*
|
|
250
|
+
* A cheaper check than ev.composedPath()[0];
|
|
251
251
|
*
|
|
252
252
|
* @private
|
|
253
253
|
* @param {Event|Touch} ev Event.
|
|
@@ -278,10 +278,9 @@ function _handleNative(ev) {
|
|
|
278
278
|
if (!ev[HANDLED_OBJ]) {
|
|
279
279
|
ev[HANDLED_OBJ] = {};
|
|
280
280
|
if (type.slice(0, 5) === 'touch') {
|
|
281
|
-
// ev = /** @type {TouchEvent} */ (ev); // eslint-disable-line no-self-assign
|
|
282
281
|
const t = ev.changedTouches[0];
|
|
283
282
|
if (type === 'touchstart') {
|
|
284
|
-
//
|
|
283
|
+
// Only handle the first finger
|
|
285
284
|
if (ev.touches.length === 1) {
|
|
286
285
|
POINTERSTATE.touch.id = t.identifier;
|
|
287
286
|
}
|
|
@@ -297,11 +296,11 @@ function _handleNative(ev) {
|
|
|
297
296
|
}
|
|
298
297
|
}
|
|
299
298
|
const handled = ev[HANDLED_OBJ];
|
|
300
|
-
//
|
|
299
|
+
// Used to ignore synthetic mouse events
|
|
301
300
|
if (handled.skip) {
|
|
302
301
|
return;
|
|
303
302
|
}
|
|
304
|
-
//
|
|
303
|
+
// Reset recognizer state
|
|
305
304
|
for (let i = 0, r; i < recognizers.length; i++) {
|
|
306
305
|
r = recognizers[i];
|
|
307
306
|
if (gs[r.name] && !handled[r.name]) {
|
|
@@ -310,7 +309,7 @@ function _handleNative(ev) {
|
|
|
310
309
|
}
|
|
311
310
|
}
|
|
312
311
|
}
|
|
313
|
-
//
|
|
312
|
+
// Enforce gesture recognizer order
|
|
314
313
|
for (let i = 0, r; i < recognizers.length; i++) {
|
|
315
314
|
r = recognizers[i];
|
|
316
315
|
if (gs[r.name] && !handled[r.name]) {
|
|
@@ -342,7 +341,7 @@ function _handleTouchAction(ev) {
|
|
|
342
341
|
const dx = Math.abs(POINTERSTATE.touch.x - t.clientX);
|
|
343
342
|
const dy = Math.abs(POINTERSTATE.touch.y - t.clientY);
|
|
344
343
|
if (!ev.cancelable) {
|
|
345
|
-
//
|
|
344
|
+
// Scrolling is happening
|
|
346
345
|
} else if (ta === 'none') {
|
|
347
346
|
shouldPrevent = true;
|
|
348
347
|
} else if (ta === 'pan-x') {
|
|
@@ -392,7 +391,7 @@ export function removeListener(node, evType, handler) {
|
|
|
392
391
|
}
|
|
393
392
|
|
|
394
393
|
/**
|
|
395
|
-
*
|
|
394
|
+
* Automate the event listeners for the native events
|
|
396
395
|
*
|
|
397
396
|
* @private
|
|
398
397
|
* @param {!EventTarget} node Node on which to add the event.
|
|
@@ -410,7 +409,7 @@ function _add(node, evType, handler) {
|
|
|
410
409
|
}
|
|
411
410
|
for (let i = 0, dep, gd; i < deps.length; i++) {
|
|
412
411
|
dep = deps[i];
|
|
413
|
-
//
|
|
412
|
+
// Don't add mouse handlers on iOS because they cause gray selection overlays
|
|
414
413
|
if (IS_TOUCH_ONLY && isMouseEvent(dep) && dep !== 'click') {
|
|
415
414
|
continue;
|
|
416
415
|
}
|
|
@@ -431,7 +430,7 @@ function _add(node, evType, handler) {
|
|
|
431
430
|
}
|
|
432
431
|
|
|
433
432
|
/**
|
|
434
|
-
*
|
|
433
|
+
* Automate event listener removal for native events
|
|
435
434
|
*
|
|
436
435
|
* @private
|
|
437
436
|
* @param {!EventTarget} node Node on which to remove the event.
|
|
@@ -528,7 +527,7 @@ function _fire(target, type, detail) {
|
|
|
528
527
|
const ev = new Event(type, { bubbles: true, cancelable: true, composed: true });
|
|
529
528
|
ev.detail = detail;
|
|
530
529
|
wrap(/** @type {!Node} */ (target)).dispatchEvent(ev);
|
|
531
|
-
//
|
|
530
|
+
// Forward `preventDefault` in a clean way
|
|
532
531
|
if (ev.defaultPrevented) {
|
|
533
532
|
const preventer = detail.preventer || detail.sourceEvent;
|
|
534
533
|
if (preventer && preventer.preventDefault) {
|
|
@@ -555,20 +554,20 @@ register({
|
|
|
555
554
|
deps: ['mousedown', 'touchstart', 'touchend'],
|
|
556
555
|
flow: {
|
|
557
556
|
start: ['mousedown', 'touchstart'],
|
|
558
|
-
end: ['mouseup', 'touchend']
|
|
557
|
+
end: ['mouseup', 'touchend'],
|
|
559
558
|
},
|
|
560
559
|
emits: ['down', 'up'],
|
|
561
560
|
|
|
562
561
|
info: {
|
|
563
562
|
movefn: null,
|
|
564
|
-
upfn: null
|
|
563
|
+
upfn: null,
|
|
565
564
|
},
|
|
566
565
|
|
|
567
566
|
/**
|
|
568
567
|
* @this {GestureRecognizer}
|
|
569
568
|
* @return {void}
|
|
570
569
|
*/
|
|
571
|
-
reset
|
|
570
|
+
reset() {
|
|
572
571
|
untrackDocument(this.info);
|
|
573
572
|
},
|
|
574
573
|
|
|
@@ -577,7 +576,7 @@ register({
|
|
|
577
576
|
* @param {MouseEvent} e
|
|
578
577
|
* @return {void}
|
|
579
578
|
*/
|
|
580
|
-
mousedown
|
|
579
|
+
mousedown(e) {
|
|
581
580
|
if (!hasLeftMouseButton(e)) {
|
|
582
581
|
return;
|
|
583
582
|
}
|
|
@@ -605,7 +604,7 @@ register({
|
|
|
605
604
|
* @param {TouchEvent} e
|
|
606
605
|
* @return {void}
|
|
607
606
|
*/
|
|
608
|
-
touchstart
|
|
607
|
+
touchstart(e) {
|
|
609
608
|
downupFire('down', _findOriginalTarget(e), e.changedTouches[0], e);
|
|
610
609
|
},
|
|
611
610
|
|
|
@@ -614,9 +613,9 @@ register({
|
|
|
614
613
|
* @param {TouchEvent} e
|
|
615
614
|
* @return {void}
|
|
616
615
|
*/
|
|
617
|
-
touchend
|
|
616
|
+
touchend(e) {
|
|
618
617
|
downupFire('up', _findOriginalTarget(e), e.changedTouches[0], e);
|
|
619
|
-
}
|
|
618
|
+
},
|
|
620
619
|
});
|
|
621
620
|
|
|
622
621
|
/**
|
|
@@ -634,10 +633,10 @@ function downupFire(type, target, event, preventer) {
|
|
|
634
633
|
x: event.clientX,
|
|
635
634
|
y: event.clientY,
|
|
636
635
|
sourceEvent: event,
|
|
637
|
-
preventer
|
|
638
|
-
prevent
|
|
636
|
+
preventer,
|
|
637
|
+
prevent(e) {
|
|
639
638
|
return prevent(e);
|
|
640
|
-
}
|
|
639
|
+
},
|
|
641
640
|
});
|
|
642
641
|
}
|
|
643
642
|
|
|
@@ -647,7 +646,7 @@ register({
|
|
|
647
646
|
deps: ['mousedown', 'touchstart', 'touchmove', 'touchend'],
|
|
648
647
|
flow: {
|
|
649
648
|
start: ['mousedown', 'touchstart'],
|
|
650
|
-
end: ['mouseup', 'touchend']
|
|
649
|
+
end: ['mouseup', 'touchend'],
|
|
651
650
|
},
|
|
652
651
|
emits: ['track'],
|
|
653
652
|
|
|
@@ -658,7 +657,7 @@ register({
|
|
|
658
657
|
started: false,
|
|
659
658
|
moves: [],
|
|
660
659
|
/** @this {GestureInfo} */
|
|
661
|
-
addMove
|
|
660
|
+
addMove(move) {
|
|
662
661
|
if (this.moves.length > TRACK_LENGTH) {
|
|
663
662
|
this.moves.shift();
|
|
664
663
|
}
|
|
@@ -666,14 +665,14 @@ register({
|
|
|
666
665
|
},
|
|
667
666
|
movefn: null,
|
|
668
667
|
upfn: null,
|
|
669
|
-
prevent: false
|
|
668
|
+
prevent: false,
|
|
670
669
|
},
|
|
671
670
|
|
|
672
671
|
/**
|
|
673
672
|
* @this {GestureRecognizer}
|
|
674
673
|
* @return {void}
|
|
675
674
|
*/
|
|
676
|
-
reset
|
|
675
|
+
reset() {
|
|
677
676
|
this.info.state = 'start';
|
|
678
677
|
this.info.started = false;
|
|
679
678
|
this.info.moves = [];
|
|
@@ -688,7 +687,7 @@ register({
|
|
|
688
687
|
* @param {MouseEvent} e
|
|
689
688
|
* @return {void}
|
|
690
689
|
*/
|
|
691
|
-
mousedown
|
|
690
|
+
mousedown(e) {
|
|
692
691
|
if (!hasLeftMouseButton(e)) {
|
|
693
692
|
return;
|
|
694
693
|
}
|
|
@@ -699,15 +698,15 @@ register({
|
|
|
699
698
|
const x = e.clientX,
|
|
700
699
|
y = e.clientY;
|
|
701
700
|
if (trackHasMovedEnough(self.info, x, y)) {
|
|
702
|
-
//
|
|
701
|
+
// First move is 'start', subsequent moves are 'move', mouseup is 'end'
|
|
703
702
|
self.info.state = self.info.started ? (e.type === 'mouseup' ? 'end' : 'track') : 'start';
|
|
704
703
|
if (self.info.state === 'start') {
|
|
705
|
-
//
|
|
704
|
+
// If and only if tracking, always prevent tap
|
|
706
705
|
prevent('tap');
|
|
707
706
|
}
|
|
708
|
-
self.info.addMove({ x
|
|
707
|
+
self.info.addMove({ x, y });
|
|
709
708
|
if (!hasLeftMouseButton(e)) {
|
|
710
|
-
//
|
|
709
|
+
// Always fire "end"
|
|
711
710
|
self.info.state = 'end';
|
|
712
711
|
untrackDocument(self.info);
|
|
713
712
|
}
|
|
@@ -722,10 +721,10 @@ register({
|
|
|
722
721
|
movefn(e);
|
|
723
722
|
}
|
|
724
723
|
|
|
725
|
-
//
|
|
724
|
+
// Remove the temporary listeners
|
|
726
725
|
untrackDocument(self.info);
|
|
727
726
|
};
|
|
728
|
-
//
|
|
727
|
+
// Add temporary document listeners as mouse retargets
|
|
729
728
|
trackDocument(this.info, movefn, upfn);
|
|
730
729
|
this.info.x = e.clientX;
|
|
731
730
|
this.info.y = e.clientY;
|
|
@@ -736,7 +735,7 @@ register({
|
|
|
736
735
|
* @param {TouchEvent} e
|
|
737
736
|
* @return {void}
|
|
738
737
|
*/
|
|
739
|
-
touchstart
|
|
738
|
+
touchstart(e) {
|
|
740
739
|
const ct = e.changedTouches[0];
|
|
741
740
|
this.info.x = ct.clientX;
|
|
742
741
|
this.info.y = ct.clientY;
|
|
@@ -747,17 +746,17 @@ register({
|
|
|
747
746
|
* @param {TouchEvent} e
|
|
748
747
|
* @return {void}
|
|
749
748
|
*/
|
|
750
|
-
touchmove
|
|
749
|
+
touchmove(e) {
|
|
751
750
|
const t = _findOriginalTarget(e);
|
|
752
751
|
const ct = e.changedTouches[0];
|
|
753
752
|
const x = ct.clientX,
|
|
754
753
|
y = ct.clientY;
|
|
755
754
|
if (trackHasMovedEnough(this.info, x, y)) {
|
|
756
755
|
if (this.info.state === 'start') {
|
|
757
|
-
//
|
|
756
|
+
// If and only if tracking, always prevent tap
|
|
758
757
|
prevent('tap');
|
|
759
758
|
}
|
|
760
|
-
this.info.addMove({ x
|
|
759
|
+
this.info.addMove({ x, y });
|
|
761
760
|
trackFire(this.info, t, ct);
|
|
762
761
|
this.info.state = 'track';
|
|
763
762
|
this.info.started = true;
|
|
@@ -769,17 +768,17 @@ register({
|
|
|
769
768
|
* @param {TouchEvent} e
|
|
770
769
|
* @return {void}
|
|
771
770
|
*/
|
|
772
|
-
touchend
|
|
771
|
+
touchend(e) {
|
|
773
772
|
const t = _findOriginalTarget(e);
|
|
774
773
|
const ct = e.changedTouches[0];
|
|
775
|
-
//
|
|
774
|
+
// Only trackend if track was started and not aborted
|
|
776
775
|
if (this.info.started) {
|
|
777
|
-
//
|
|
776
|
+
// Reset started state on up
|
|
778
777
|
this.info.state = 'end';
|
|
779
778
|
this.info.addMove({ x: ct.clientX, y: ct.clientY });
|
|
780
779
|
trackFire(this.info, t, ct);
|
|
781
780
|
}
|
|
782
|
-
}
|
|
781
|
+
},
|
|
783
782
|
});
|
|
784
783
|
|
|
785
784
|
/**
|
|
@@ -824,14 +823,14 @@ function trackFire(info, target, touch) {
|
|
|
824
823
|
state: info.state,
|
|
825
824
|
x: touch.clientX,
|
|
826
825
|
y: touch.clientY,
|
|
827
|
-
dx
|
|
828
|
-
dy
|
|
829
|
-
ddx
|
|
830
|
-
ddy
|
|
826
|
+
dx,
|
|
827
|
+
dy,
|
|
828
|
+
ddx,
|
|
829
|
+
ddy,
|
|
831
830
|
sourceEvent: touch,
|
|
832
|
-
hover
|
|
831
|
+
hover() {
|
|
833
832
|
return deepTargetFind(touch.clientX, touch.clientY);
|
|
834
|
-
}
|
|
833
|
+
},
|
|
835
834
|
});
|
|
836
835
|
}
|
|
837
836
|
|
|
@@ -840,20 +839,20 @@ register({
|
|
|
840
839
|
deps: ['mousedown', 'click', 'touchstart', 'touchend'],
|
|
841
840
|
flow: {
|
|
842
841
|
start: ['mousedown', 'touchstart'],
|
|
843
|
-
end: ['click', 'touchend']
|
|
842
|
+
end: ['click', 'touchend'],
|
|
844
843
|
},
|
|
845
844
|
emits: ['tap'],
|
|
846
845
|
info: {
|
|
847
846
|
x: NaN,
|
|
848
847
|
y: NaN,
|
|
849
|
-
prevent: false
|
|
848
|
+
prevent: false,
|
|
850
849
|
},
|
|
851
850
|
|
|
852
851
|
/**
|
|
853
852
|
* @this {GestureRecognizer}
|
|
854
853
|
* @return {void}
|
|
855
854
|
*/
|
|
856
|
-
reset
|
|
855
|
+
reset() {
|
|
857
856
|
this.info.x = NaN;
|
|
858
857
|
this.info.y = NaN;
|
|
859
858
|
this.info.prevent = false;
|
|
@@ -864,7 +863,7 @@ register({
|
|
|
864
863
|
* @param {MouseEvent} e
|
|
865
864
|
* @return {void}
|
|
866
865
|
*/
|
|
867
|
-
mousedown
|
|
866
|
+
mousedown(e) {
|
|
868
867
|
if (hasLeftMouseButton(e)) {
|
|
869
868
|
this.info.x = e.clientX;
|
|
870
869
|
this.info.y = e.clientY;
|
|
@@ -876,7 +875,7 @@ register({
|
|
|
876
875
|
* @param {MouseEvent} e
|
|
877
876
|
* @return {void}
|
|
878
877
|
*/
|
|
879
|
-
click
|
|
878
|
+
click(e) {
|
|
880
879
|
if (hasLeftMouseButton(e)) {
|
|
881
880
|
trackForward(this.info, e);
|
|
882
881
|
}
|
|
@@ -887,7 +886,7 @@ register({
|
|
|
887
886
|
* @param {TouchEvent} e
|
|
888
887
|
* @return {void}
|
|
889
888
|
*/
|
|
890
|
-
touchstart
|
|
889
|
+
touchstart(e) {
|
|
891
890
|
const touch = e.changedTouches[0];
|
|
892
891
|
this.info.x = touch.clientX;
|
|
893
892
|
this.info.y = touch.clientY;
|
|
@@ -898,9 +897,9 @@ register({
|
|
|
898
897
|
* @param {TouchEvent} e
|
|
899
898
|
* @return {void}
|
|
900
899
|
*/
|
|
901
|
-
touchend
|
|
900
|
+
touchend(e) {
|
|
902
901
|
trackForward(this.info, e.changedTouches[0], e);
|
|
903
|
-
}
|
|
902
|
+
},
|
|
904
903
|
});
|
|
905
904
|
|
|
906
905
|
/**
|
|
@@ -912,20 +911,20 @@ register({
|
|
|
912
911
|
function trackForward(info, e, preventer) {
|
|
913
912
|
const dx = Math.abs(e.clientX - info.x);
|
|
914
913
|
const dy = Math.abs(e.clientY - info.y);
|
|
915
|
-
//
|
|
914
|
+
// Find original target from `preventer` for TouchEvents, or `e` for MouseEvents
|
|
916
915
|
const t = _findOriginalTarget(preventer || e);
|
|
917
916
|
if (!t || (canBeDisabled[/** @type {!HTMLElement} */ (t).localName] && t.hasAttribute('disabled'))) {
|
|
918
917
|
return;
|
|
919
918
|
}
|
|
920
|
-
//
|
|
919
|
+
// Dx,dy can be NaN if `click` has been simulated and there was no `down` for `start`
|
|
921
920
|
if (isNaN(dx) || isNaN(dy) || (dx <= TAP_DISTANCE && dy <= TAP_DISTANCE) || isSyntheticClick(e)) {
|
|
922
|
-
//
|
|
921
|
+
// Prevent taps from being generated if an event has canceled them
|
|
923
922
|
if (!info.prevent) {
|
|
924
923
|
_fire(t, 'tap', {
|
|
925
924
|
x: e.clientX,
|
|
926
925
|
y: e.clientY,
|
|
927
926
|
sourceEvent: e,
|
|
928
|
-
preventer
|
|
927
|
+
preventer,
|
|
929
928
|
});
|
|
930
929
|
}
|
|
931
930
|
}
|