@jsenv/dom 0.17.86 → 0.17.88
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 +30 -23
- package/package.json +1 -1
package/dist/jsenv_dom.js
CHANGED
|
@@ -575,21 +575,28 @@ const getEventLabel = (e) => {
|
|
|
575
575
|
|
|
576
576
|
const createIterableWeakSet = () => {
|
|
577
577
|
const objectWeakRefSet = new Set();
|
|
578
|
+
// The one WeakRef of each member, so that adding a member twice keeps one
|
|
579
|
+
// entry and deleting it once removes it. Weak on the object, and a WeakRef
|
|
580
|
+
// holds nothing: this keeps nothing alive.
|
|
581
|
+
let weakRefMap = new WeakMap();
|
|
578
582
|
|
|
579
583
|
return {
|
|
580
584
|
add: (object) => {
|
|
585
|
+
if (weakRefMap.has(object)) {
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
581
588
|
const objectWeakRef = new WeakRef(object);
|
|
582
589
|
objectWeakRefSet.add(objectWeakRef);
|
|
590
|
+
weakRefMap.set(object, objectWeakRef);
|
|
583
591
|
},
|
|
584
592
|
|
|
585
593
|
delete: (object) => {
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
return true;
|
|
590
|
-
}
|
|
594
|
+
const objectWeakRef = weakRefMap.get(object);
|
|
595
|
+
if (!objectWeakRef) {
|
|
596
|
+
return false;
|
|
591
597
|
}
|
|
592
|
-
|
|
598
|
+
weakRefMap.delete(object);
|
|
599
|
+
return objectWeakRefSet.delete(objectWeakRef);
|
|
593
600
|
},
|
|
594
601
|
|
|
595
602
|
*[Symbol.iterator]() {
|
|
@@ -604,21 +611,12 @@ const createIterableWeakSet = () => {
|
|
|
604
611
|
},
|
|
605
612
|
|
|
606
613
|
has: (object) => {
|
|
607
|
-
|
|
608
|
-
const objectCandidate = weakRef.deref();
|
|
609
|
-
if (objectCandidate === undefined) {
|
|
610
|
-
objectWeakRefSet.delete(weakRef);
|
|
611
|
-
continue;
|
|
612
|
-
}
|
|
613
|
-
if (objectCandidate === object) {
|
|
614
|
-
return true;
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
return false;
|
|
614
|
+
return weakRefMap.has(object);
|
|
618
615
|
},
|
|
619
616
|
|
|
620
617
|
clear: () => {
|
|
621
618
|
objectWeakRefSet.clear();
|
|
619
|
+
weakRefMap = new WeakMap();
|
|
622
620
|
},
|
|
623
621
|
|
|
624
622
|
get size() {
|
|
@@ -9121,7 +9119,7 @@ const createDragGestureController = (options = {}) => {
|
|
|
9121
9119
|
// Where the pointer IS is not where it is going: throwing something is a
|
|
9122
9120
|
// matter of speed, and the gesture is the only place that sees the timing of
|
|
9123
9121
|
// the events it receives.
|
|
9124
|
-
const measureVelocity = createVelocityMeter(grabX, grabY);
|
|
9122
|
+
const measureVelocity = createVelocityMeter(grabX, grabY, event.timeStamp);
|
|
9125
9123
|
|
|
9126
9124
|
document_interactions: {
|
|
9127
9125
|
if (documentInteractions === "manual") {
|
|
@@ -9413,7 +9411,11 @@ const createDragGestureController = (options = {}) => {
|
|
|
9413
9411
|
dragEvent: event,
|
|
9414
9412
|
isRelease,
|
|
9415
9413
|
});
|
|
9416
|
-
const [velocityX, velocityY] = measureVelocity(
|
|
9414
|
+
const [velocityX, velocityY] = measureVelocity(
|
|
9415
|
+
dragX,
|
|
9416
|
+
dragY,
|
|
9417
|
+
event.timeStamp,
|
|
9418
|
+
);
|
|
9417
9419
|
const startedPrevious = gestureInfo.started;
|
|
9418
9420
|
const layoutPrevious = gestureInfo.layout;
|
|
9419
9421
|
// previousGestureInfo = { ...gestureInfo };
|
|
@@ -9870,13 +9872,18 @@ const isPrimaryButtonEvent = (event) =>
|
|
|
9870
9872
|
* A pointer held still keeps producing samples at the same place, so the window
|
|
9871
9873
|
* empties itself of movement and the speed falls back to zero on its own: put
|
|
9872
9874
|
* down slowly is not thrown.
|
|
9875
|
+
* Each sample carries the time of its event (`timeStamp`, the clock of
|
|
9876
|
+
* `performance.now()`), not the time it is handled: behind a long frame, every
|
|
9877
|
+
* report the hand made meanwhile is handled in one burst with the release, and
|
|
9878
|
+
* stamped then, the last few pixels — often a thumb drifting back as it lifts —
|
|
9879
|
+
* fill the window and read as a throw the other way. A programmatic event is
|
|
9880
|
+
* stamped at its creation, which is when it happens.
|
|
9873
9881
|
*/
|
|
9874
9882
|
const VELOCITY_WINDOW_MS = 100;
|
|
9875
|
-
const createVelocityMeter = (grabX, grabY) => {
|
|
9876
|
-
const samples = [{ time:
|
|
9883
|
+
const createVelocityMeter = (grabX, grabY, grabTime) => {
|
|
9884
|
+
const samples = [{ time: grabTime, x: grabX, y: grabY }];
|
|
9877
9885
|
|
|
9878
|
-
const measureVelocity = (x, y) => {
|
|
9879
|
-
const time = performance.now();
|
|
9886
|
+
const measureVelocity = (x, y, time) => {
|
|
9880
9887
|
samples.push({ time, x, y });
|
|
9881
9888
|
while (samples.length > 2 && time - samples[1].time > VELOCITY_WINDOW_MS) {
|
|
9882
9889
|
samples.shift();
|