@jsenv/dom 0.17.8 → 0.17.9

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 +33 -1
  2. package/package.json +1 -1
package/dist/jsenv_dom.js CHANGED
@@ -11993,7 +11993,9 @@ import.meta.css = [/* css */`
11993
11993
  /* A drag over text selects it on the way, and the blue trail says the
11994
11994
  gesture was understood as something else. Not from the press: a press on
11995
11995
  text IS how one selects it, and only a press that has become a travel has
11996
- said it was about something else. */
11996
+ said it was about something else — which is also why this cannot be the
11997
+ whole answer, and why the selection made meanwhile is dropped by hand
11998
+ (see dropSelection). */
11997
11999
  user-select: none;
11998
12000
  }
11999
12001
  `, "@jsenv/dom/src/interaction/drag/drag_to_travel.js"];
@@ -12071,6 +12073,29 @@ const axesLeftBy = (axes, fromElement, stopElement, attribute) => {
12071
12073
  return left;
12072
12074
  };
12073
12075
 
12076
+ /**
12077
+ * What the browser painted blue while it was still allowed to think this press
12078
+ * was about text.
12079
+ *
12080
+ * A mouse dragged across a page selects what it crosses, and it starts doing so
12081
+ * from the first pixel — while this is still spending ten of them deciding
12082
+ * whether the press is a travel at all. By the time it is one, a trail is
12083
+ * already there. `user-select: none` (see the CSS) stops it GROWING, it does not
12084
+ * take back what was made, and a selection already under way goes on being
12085
+ * extended by some browsers whatever the property says.
12086
+ *
12087
+ * So it is dropped, and dropped again as it comes back. The cause is outside —
12088
+ * one gesture, two things answering it, and the browser answers first — and
12089
+ * cannot be removed from here; what can be removed is its trace, on every frame
12090
+ * of a travel that is walking.
12091
+ */
12092
+ const dropSelection = () => {
12093
+ const selection = window.getSelection();
12094
+ if (selection && !selection.isCollapsed) {
12095
+ selection.removeAllRanges();
12096
+ }
12097
+ };
12098
+
12074
12099
  /**
12075
12100
  * A scroller between the pointer and the box it is in, with room left the way
12076
12101
  * the gesture goes: it gets the gesture, and nothing travels — dragging a row
@@ -12382,6 +12407,9 @@ const startDragToTravel = (pointerDownEvent, {
12382
12407
  };
12383
12408
  document.documentElement.setAttribute(WALKING_ATTRIBUTE, axis);
12384
12409
  }
12410
+ // Whatever the press was taken for until now, it was taken for something
12411
+ // else (see dropSelection).
12412
+ dropSelection();
12385
12413
  const {
12386
12414
  axis
12387
12415
  } = travel;
@@ -12443,6 +12471,10 @@ const startDragToTravel = (pointerDownEvent, {
12443
12471
  return;
12444
12472
  }
12445
12473
  finish();
12474
+ // Last chance: the pointer moves once more as it goes up, and by then the
12475
+ // attribute above is off — so a trail made on that last move would be the
12476
+ // one that stays (see dropSelection).
12477
+ dropSelection();
12446
12478
  const {
12447
12479
  axis,
12448
12480
  size,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/dom",
3
- "version": "0.17.8",
3
+ "version": "0.17.9",
4
4
  "type": "module",
5
5
  "description": "DOM utilities for writing frontend code",
6
6
  "repository": {