@jsenv/dom 0.17.86 → 0.17.87

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.
Files changed (2) hide show
  1. package/dist/jsenv_dom.js +15 -6
  2. package/package.json +1 -1
package/dist/jsenv_dom.js CHANGED
@@ -9121,7 +9121,7 @@ const createDragGestureController = (options = {}) => {
9121
9121
  // Where the pointer IS is not where it is going: throwing something is a
9122
9122
  // matter of speed, and the gesture is the only place that sees the timing of
9123
9123
  // the events it receives.
9124
- const measureVelocity = createVelocityMeter(grabX, grabY);
9124
+ const measureVelocity = createVelocityMeter(grabX, grabY, event.timeStamp);
9125
9125
 
9126
9126
  document_interactions: {
9127
9127
  if (documentInteractions === "manual") {
@@ -9413,7 +9413,11 @@ const createDragGestureController = (options = {}) => {
9413
9413
  dragEvent: event,
9414
9414
  isRelease,
9415
9415
  });
9416
- const [velocityX, velocityY] = measureVelocity(dragX, dragY);
9416
+ const [velocityX, velocityY] = measureVelocity(
9417
+ dragX,
9418
+ dragY,
9419
+ event.timeStamp,
9420
+ );
9417
9421
  const startedPrevious = gestureInfo.started;
9418
9422
  const layoutPrevious = gestureInfo.layout;
9419
9423
  // previousGestureInfo = { ...gestureInfo };
@@ -9870,13 +9874,18 @@ const isPrimaryButtonEvent = (event) =>
9870
9874
  * A pointer held still keeps producing samples at the same place, so the window
9871
9875
  * empties itself of movement and the speed falls back to zero on its own: put
9872
9876
  * down slowly is not thrown.
9877
+ * Each sample carries the time of its event (`timeStamp`, the clock of
9878
+ * `performance.now()`), not the time it is handled: behind a long frame, every
9879
+ * report the hand made meanwhile is handled in one burst with the release, and
9880
+ * stamped then, the last few pixels — often a thumb drifting back as it lifts —
9881
+ * fill the window and read as a throw the other way. A programmatic event is
9882
+ * stamped at its creation, which is when it happens.
9873
9883
  */
9874
9884
  const VELOCITY_WINDOW_MS = 100;
9875
- const createVelocityMeter = (grabX, grabY) => {
9876
- const samples = [{ time: performance.now(), x: grabX, y: grabY }];
9885
+ const createVelocityMeter = (grabX, grabY, grabTime) => {
9886
+ const samples = [{ time: grabTime, x: grabX, y: grabY }];
9877
9887
 
9878
- const measureVelocity = (x, y) => {
9879
- const time = performance.now();
9888
+ const measureVelocity = (x, y, time) => {
9880
9889
  samples.push({ time, x, y });
9881
9890
  while (samples.length > 2 && time - samples[1].time > VELOCITY_WINDOW_MS) {
9882
9891
  samples.shift();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/dom",
3
- "version": "0.17.86",
3
+ "version": "0.17.87",
4
4
  "type": "module",
5
5
  "description": "DOM utilities for writing frontend code",
6
6
  "repository": {