@jsenv/dom 0.17.67 → 0.17.69
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/dist/jsenv_dom.js +44 -17
- package/package.json +1 -1
package/dist/jsenv_dom.js
CHANGED
|
@@ -319,11 +319,14 @@ const chainEvent = (customEvent, parentEvent) => {
|
|
|
319
319
|
* which one WAS used — a tap brings the on-screen keyboard up, the trackpad
|
|
320
320
|
* next to it does not.
|
|
321
321
|
*
|
|
322
|
-
*
|
|
322
|
+
* Four readings, because no single one covers every path from a finger to an
|
|
323
323
|
* event:
|
|
324
324
|
* - a touch* event says it outright;
|
|
325
325
|
* - `pointerType` says it on a PointerEvent, which "click" also is in some
|
|
326
326
|
* engines and not in others — hence not the only reading;
|
|
327
|
+
* - the click WebKit dispatches for a tap is a PointerEvent whose `pointerType`
|
|
328
|
+
* says "mouse" while its `pointerId` is the finger's: the press last seen
|
|
329
|
+
* down with that id answers for it (see lastPress below);
|
|
327
330
|
* - `sourceCapabilities.firesTouchEvents` is what is left for the compatibility
|
|
328
331
|
* mouse events a tap synthesizes, where nothing else remembers the finger.
|
|
329
332
|
* Absent outside Chromium, where it costs nothing: the readings above have
|
|
@@ -339,10 +342,30 @@ const isTouchDrivenEvent = (event) => {
|
|
|
339
342
|
// "" on a pointer event the engine could not attribute — not an answer, so
|
|
340
343
|
// it falls through to the last reading rather than being read as "not touch".
|
|
341
344
|
if (event.pointerType) {
|
|
342
|
-
|
|
345
|
+
if (event.pointerType === "touch") {
|
|
346
|
+
return true;
|
|
347
|
+
}
|
|
348
|
+
if (lastPress && event.pointerId === lastPress.pointerId) {
|
|
349
|
+
return lastPress.pointerType === "touch";
|
|
350
|
+
}
|
|
351
|
+
return false;
|
|
343
352
|
}
|
|
344
353
|
return event.sourceCapabilities?.firesTouchEvents === true;
|
|
345
354
|
};
|
|
355
|
+
// The press behind the next click: a click follows the pointerup of its own
|
|
356
|
+
// press, and no other press comes between the two. Recorded on window in
|
|
357
|
+
// capture so that nothing lower can hide a press from it.
|
|
358
|
+
let lastPress = null;
|
|
359
|
+
window.addEventListener(
|
|
360
|
+
"pointerdown",
|
|
361
|
+
(pointerdownEvent) => {
|
|
362
|
+
lastPress = {
|
|
363
|
+
pointerId: pointerdownEvent.pointerId,
|
|
364
|
+
pointerType: pointerdownEvent.pointerType,
|
|
365
|
+
};
|
|
366
|
+
},
|
|
367
|
+
{ capture: true, passive: true },
|
|
368
|
+
);
|
|
346
369
|
|
|
347
370
|
/**
|
|
348
371
|
* Whether `event` is a click a pointer press produced, as opposed to one
|
|
@@ -12507,6 +12530,7 @@ const travelsAfter = ({
|
|
|
12507
12530
|
size,
|
|
12508
12531
|
velocity,
|
|
12509
12532
|
towardsSomething,
|
|
12533
|
+
cancelled,
|
|
12510
12534
|
commitRatio,
|
|
12511
12535
|
}) => {
|
|
12512
12536
|
if (!towardsSomething) {
|
|
@@ -12516,10 +12540,17 @@ const travelsAfter = ({
|
|
|
12516
12540
|
// carries on. Answered on the distance alone, a travel a hand merely touched
|
|
12517
12541
|
// is undone BY the touch — it was stopped where it stood, and where it stood
|
|
12518
12542
|
// is not far enough to count as an intention. Nobody asked it to stop; it was
|
|
12519
|
-
// asked to wait.
|
|
12520
|
-
|
|
12543
|
+
// asked to wait. A gesture TAKEN AWAY said nothing either (the browser
|
|
12544
|
+
// scrolling something else, a call coming in): its end was decided before
|
|
12545
|
+
// the press, and it is that end it goes on to.
|
|
12546
|
+
if (slack && (cancelled || Math.abs(pulled - slack) < DRAG_START_THRESHOLD)) {
|
|
12521
12547
|
return true;
|
|
12522
12548
|
}
|
|
12549
|
+
// Taken away from a travel this gesture began: things go back rather than
|
|
12550
|
+
// landing wherever the hand happened to be.
|
|
12551
|
+
if (cancelled) {
|
|
12552
|
+
return false;
|
|
12553
|
+
}
|
|
12523
12554
|
const sign = pulled > 0 ? 1 : -1;
|
|
12524
12555
|
// A hand that is still moving says where it is going, and it says it about
|
|
12525
12556
|
// BOTH answers. Going away from what it was bringing in fast is "put it
|
|
@@ -12907,9 +12938,6 @@ const startDragToTravel = (
|
|
|
12907
12938
|
const towardsSomething = pulled > 0 ? travel.travelBack : travel.travelOn;
|
|
12908
12939
|
const velocity =
|
|
12909
12940
|
axis === "x" ? gestureInfo.velocityX : gestureInfo.velocityY;
|
|
12910
|
-
// A gesture taken away rather than let go of (the browser scrolling
|
|
12911
|
-
// something else, a call coming in, another gesture taking the pointer)
|
|
12912
|
-
// said nothing: things go back.
|
|
12913
12941
|
const releaseEvent = gestureInfo.releaseEvent || gestureInfo.dragEvent;
|
|
12914
12942
|
const { cancelled } = gestureInfo;
|
|
12915
12943
|
onEnd({
|
|
@@ -12917,16 +12945,15 @@ const startDragToTravel = (
|
|
|
12917
12945
|
pulled,
|
|
12918
12946
|
size,
|
|
12919
12947
|
sign: pulled > 0 ? 1 : -1,
|
|
12920
|
-
travels:
|
|
12921
|
-
|
|
12922
|
-
|
|
12923
|
-
|
|
12924
|
-
|
|
12925
|
-
|
|
12926
|
-
|
|
12927
|
-
|
|
12928
|
-
|
|
12929
|
-
}),
|
|
12948
|
+
travels: travelsAfter({
|
|
12949
|
+
pulled,
|
|
12950
|
+
slack,
|
|
12951
|
+
size,
|
|
12952
|
+
velocity,
|
|
12953
|
+
towardsSomething,
|
|
12954
|
+
cancelled,
|
|
12955
|
+
commitRatio,
|
|
12956
|
+
}),
|
|
12930
12957
|
cancelled,
|
|
12931
12958
|
event: releaseEvent,
|
|
12932
12959
|
});
|