@jsenv/dom 0.17.85 → 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 +32 -21
  2. package/package.json +1 -1
package/dist/jsenv_dom.js CHANGED
@@ -4976,14 +4976,19 @@ const getFocusVisibilityInfo = (node, { excludeAriaHidden } = {}) => {
4976
4976
  }
4977
4977
  // Continue checking ancestors
4978
4978
  }
4979
- if (elementIsDialog(nodeOrAncestor) && !nodeOrAncestor.open) {
4980
- return { visible: false, reason: "inside closed dialog element" };
4981
- }
4979
+ const isPopover =
4980
+ nodeOrAncestor.popover !== null && nodeOrAncestor.popover !== undefined;
4981
+ const isOpenPopover = isPopover && nodeOrAncestor.matches(":popover-open");
4982
+ // A dialog shown as a popover (showPopover()) is open without `open`,
4983
+ // which only show() and showModal() set.
4982
4984
  if (
4983
- nodeOrAncestor.popover !== null &&
4984
- nodeOrAncestor.popover !== undefined &&
4985
- !nodeOrAncestor.matches(":popover-open")
4985
+ elementIsDialog(nodeOrAncestor) &&
4986
+ !nodeOrAncestor.open &&
4987
+ !isOpenPopover
4986
4988
  ) {
4989
+ return { visible: false, reason: "inside closed dialog element" };
4990
+ }
4991
+ if (isPopover && !isOpenPopover) {
4987
4992
  return { visible: false, reason: "inside closed popover element" };
4988
4993
  }
4989
4994
  // Open popovers and open dialogs render in the top layer: they escape
@@ -4992,11 +4997,7 @@ const getFocusVisibilityInfo = (node, { excludeAriaHidden } = {}) => {
4992
4997
  if (elementIsDialog(nodeOrAncestor) && nodeOrAncestor.open) {
4993
4998
  break;
4994
4999
  }
4995
- if (
4996
- nodeOrAncestor.popover !== null &&
4997
- nodeOrAncestor.popover !== undefined &&
4998
- nodeOrAncestor.matches(":popover-open")
4999
- ) {
5000
+ if (isOpenPopover) {
5000
5001
  break;
5001
5002
  }
5002
5003
  nodeOrAncestor = nodeOrAncestor.parentNode;
@@ -9120,7 +9121,7 @@ const createDragGestureController = (options = {}) => {
9120
9121
  // Where the pointer IS is not where it is going: throwing something is a
9121
9122
  // matter of speed, and the gesture is the only place that sees the timing of
9122
9123
  // the events it receives.
9123
- const measureVelocity = createVelocityMeter(grabX, grabY);
9124
+ const measureVelocity = createVelocityMeter(grabX, grabY, event.timeStamp);
9124
9125
 
9125
9126
  document_interactions: {
9126
9127
  if (documentInteractions === "manual") {
@@ -9412,7 +9413,11 @@ const createDragGestureController = (options = {}) => {
9412
9413
  dragEvent: event,
9413
9414
  isRelease,
9414
9415
  });
9415
- const [velocityX, velocityY] = measureVelocity(dragX, dragY);
9416
+ const [velocityX, velocityY] = measureVelocity(
9417
+ dragX,
9418
+ dragY,
9419
+ event.timeStamp,
9420
+ );
9416
9421
  const startedPrevious = gestureInfo.started;
9417
9422
  const layoutPrevious = gestureInfo.layout;
9418
9423
  // previousGestureInfo = { ...gestureInfo };
@@ -9869,13 +9874,18 @@ const isPrimaryButtonEvent = (event) =>
9869
9874
  * A pointer held still keeps producing samples at the same place, so the window
9870
9875
  * empties itself of movement and the speed falls back to zero on its own: put
9871
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.
9872
9883
  */
9873
9884
  const VELOCITY_WINDOW_MS = 100;
9874
- const createVelocityMeter = (grabX, grabY) => {
9875
- const samples = [{ time: performance.now(), x: grabX, y: grabY }];
9885
+ const createVelocityMeter = (grabX, grabY, grabTime) => {
9886
+ const samples = [{ time: grabTime, x: grabX, y: grabY }];
9876
9887
 
9877
- const measureVelocity = (x, y) => {
9878
- const time = performance.now();
9888
+ const measureVelocity = (x, y, time) => {
9879
9889
  samples.push({ time, x, y });
9880
9890
  while (samples.length > 2 && time - samples[1].time > VELOCITY_WINDOW_MS) {
9881
9891
  samples.shift();
@@ -15039,10 +15049,11 @@ const startDragTo = (
15039
15049
  * A press that WOULD be a drag, and is not.
15040
15050
  *
15041
15051
  * Recognized exactly as `startDragTo` recognizes it: the intent is established by
15042
- * the same threshold — a mouse travelling, a finger holding still, the first
15043
- * pixel inside a `[data-drag-on-contact]`. What differs is what happens once it
15044
- * is established: nothing is grabbed, nothing translates, and `onRefuse` is told
15045
- * at the instant the grab would have been acquired.
15052
+ * the same threshold — a mouse travelling a few pixels, a finger holding still,
15053
+ * or travelling those same few pixels inside a `[data-drag-on-contact]`. What
15054
+ * differs is what happens once it is established: nothing is grabbed, nothing
15055
+ * translates, and `onRefuse` is told at the instant the grab would have been
15056
+ * acquired.
15046
15057
  *
15047
15058
  * That instant is the whole point. An object that stays put under the hand and
15048
15059
  * says nothing reads as a screen that is broken, and the hand pulls harder; the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/dom",
3
- "version": "0.17.85",
3
+ "version": "0.17.87",
4
4
  "type": "module",
5
5
  "description": "DOM utilities for writing frontend code",
6
6
  "repository": {