@jsenv/dom 0.17.41 → 0.17.43

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 +52 -7
  2. package/package.json +1 -1
package/dist/jsenv_dom.js CHANGED
@@ -14163,6 +14163,13 @@ const WHEEL_NEXT_STEP_DELTA = 600;
14163
14163
  // slides. Two events in a row are asked for rather than one, because a hand
14164
14164
  // wavers and momentum does not.
14165
14165
  const WHEEL_FADE_RUN = 2;
14166
+ // …and the same fact read the other way: momentum only ever weakens, so a
14167
+ // stream already recognized as momentum that GROWS twice in a row is a hand
14168
+ // pushing again — a second swipe thrown while the tail of the first is still
14169
+ // streaming. The browser sees one unbroken burst (the tail never went silent),
14170
+ // but to the hand these are two gestures, and the second is answered like a
14171
+ // first event: with a screen, now, not with credit towards one.
14172
+ const WHEEL_REGROW_RUN = 2;
14166
14173
 
14167
14174
  /**
14168
14175
  * A travel asked for with a wheel, and it asks for a WHOLE ONE.
@@ -14307,6 +14314,8 @@ const watchWheelTravel = (element, {
14307
14314
  pushed: 0,
14308
14315
  lastMagnitude: 0,
14309
14316
  fadeRun: 0,
14317
+ growRun: 0,
14318
+ faded: false,
14310
14319
  stepped: false
14311
14320
  };
14312
14321
  document.documentElement.setAttribute(GESTURE_ATTRIBUTE, "");
@@ -14314,24 +14323,39 @@ const watchWheelTravel = (element, {
14314
14323
  }
14315
14324
  // Ours from here, on both axes: what the browser would do with the leftover
14316
14325
  // — scroll the page behind the box, bounce it, go back in history — is one
14317
- // gesture answered twice.
14326
+ // gesture answered twice. On the other axis that swallowing is absolute —
14327
+ // there is no per-event reading that tells a scroll's onset from the
14328
+ // tail's own wobble (end-of-fade crumbs land on either axis, and a
14329
+ // diagonal swipe's tail carries hand-sized deltas on both), and a crumb
14330
+ // let through scrolls the slide's own content under the travel, a header
14331
+ // creeping off the edge of the box.
14318
14332
  wheelEvent.preventDefault();
14319
- // …and said on every event of it, because a claim nobody renews is a
14320
- // gesture that is over: silence is the only end a wheel has.
14321
- claimWheelGesture(element, {
14322
- onEnd: forgetGesture
14323
- });
14324
14333
  if (axis !== gesture.axis) {
14325
14334
  // The other axis mid-gesture: a hand is never perfectly straight, and the
14326
- // axis was decided when the gesture set off.
14335
+ // axis was decided when the gesture set off. Swallowed, but NOT renewing
14336
+ // the claim below: silence is the only end a wheel gesture has, and it
14337
+ // is silence ON ITS AXIS. Renewed by what it eats, the gesture would
14338
+ // outlive its own stream — a hand starting a scroll over the tail would
14339
+ // extend, event by event, the very deadness it is waiting out. Left to
14340
+ // lapse, the claim dies shortly after our axis goes quiet (and on a
14341
+ // system where touching the surface kills the old momentum, that is
14342
+ // moments after the new scroll begins) — the browser then answers the
14343
+ // rest of the scroll itself.
14327
14344
  return;
14328
14345
  }
14346
+ // …and said on every event on our axis, because a claim nobody renews is a
14347
+ // gesture that is over.
14348
+ claimWheelGesture(element, {
14349
+ onEnd: forgetGesture
14350
+ });
14329
14351
  if (sign !== gesture.sign) {
14330
14352
  // Turned around: what was adding up was going the other way.
14331
14353
  gesture.sign = sign;
14332
14354
  gesture.pushed = 0;
14333
14355
  gesture.lastMagnitude = 0;
14334
14356
  gesture.fadeRun = 0;
14357
+ gesture.growRun = 0;
14358
+ gesture.faded = false;
14335
14359
  gesture.stepped = false;
14336
14360
  }
14337
14361
  if (!gesture.stepped) {
@@ -14350,11 +14374,32 @@ const watchWheelTravel = (element, {
14350
14374
  const magnitude = Math.abs(delta);
14351
14375
  if (magnitude < gesture.lastMagnitude) {
14352
14376
  gesture.fadeRun += 1;
14377
+ gesture.growRun = 0;
14378
+ if (gesture.fadeRun >= WHEEL_FADE_RUN) {
14379
+ // Momentum, recognized — and remembered past the next growth: fadeRun
14380
+ // is transient (one louder event resets it), while what the regrow
14381
+ // rule below needs to know is that a tail WAS established at all.
14382
+ gesture.faded = true;
14383
+ }
14353
14384
  } else if (magnitude > gesture.lastMagnitude) {
14354
14385
  // Back up again — a hand asking for more. Momentum never does this.
14355
14386
  gesture.fadeRun = 0;
14387
+ gesture.growRun += 1;
14356
14388
  }
14357
14389
  gesture.lastMagnitude = magnitude;
14390
+ // A second push, thrown while the tail of the first still streams (see
14391
+ // WHEEL_REGROW_RUN): a new gesture to the hand, whatever the stream says.
14392
+ if (gesture.faded && gesture.growRun >= WHEEL_REGROW_RUN) {
14393
+ gesture.faded = false;
14394
+ gesture.growRun = 0;
14395
+ gesture.pushed = 0;
14396
+ onStep({
14397
+ axis: gesture.axis,
14398
+ sign: gesture.sign,
14399
+ event: wheelEvent
14400
+ });
14401
+ return;
14402
+ }
14358
14403
  if (gesture.fadeRun >= WHEEL_FADE_RUN) {
14359
14404
  return;
14360
14405
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/dom",
3
- "version": "0.17.41",
3
+ "version": "0.17.43",
4
4
  "type": "module",
5
5
  "description": "DOM utilities for writing frontend code",
6
6
  "repository": {