@jsenv/navi 0.29.497 → 0.29.499

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.
@@ -10276,15 +10276,16 @@ const [publishRouteRender, observeRouteRender] = createPubSub();
10276
10276
  *
10277
10277
  * A page whose height depends on something still loading is not there at the
10278
10278
  * moment it is put back, and a position beyond what has arrived is clamped.
10279
- * What navi knows a first render left out, it waits for: a `<Box
10280
- * mount="after-paint">` is built before the offset that shows it is written
10281
- * (see mount_after_paint.jsx), and a reload or a return waits for the route
10282
- * actions the page has nothing to draw for — its code among them — including
10283
- * one whose `when` lets it ask after the position is written (see
10284
- * stayForLateAsks). Anything else only the page knows, and it says so
10285
- * (useHoldScrollRestoration). A wait can be long, so the reader reaching for
10286
- * the page during it cancels the position: moved afterwards, they would lose
10287
- * whatever they had started on.
10279
+ * So it is written into what is there, as far as that goes, and written again
10280
+ * once the page is whole (see putBackMeanwhile). What navi knows a first render
10281
+ * left out, it waits for: a `<Box mount="after-paint">` is built before the
10282
+ * offset that shows it is written (see mount_after_paint.jsx), and a reload or
10283
+ * a return waits for the route actions the page has nothing to draw for — its
10284
+ * code among them — including one whose `when` lets it ask after the position
10285
+ * is written (see stayForLateAsks). Anything else only the page knows, and it
10286
+ * says so (useHoldScrollRestoration). A wait can be long, so the reader
10287
+ * reaching for the page during it cancels the position: moved afterwards, they
10288
+ * would lose whatever they had started on.
10288
10289
  *
10289
10290
  * WHEN a page is arrived at is not decided here either. A document navigation
10290
10291
  * lands where its kind says (see via_history.js), and one scrollport can be
@@ -10443,6 +10444,7 @@ const putBack = (restoration) => {
10443
10444
  restoration.due = true;
10444
10445
  if (restorationHoldCount) {
10445
10446
  // The page is not whole yet: the last release puts it back.
10447
+ putBackMeanwhile(restoration);
10446
10448
  return;
10447
10449
  }
10448
10450
  if (isDocumentHeld()) {
@@ -10489,6 +10491,22 @@ const isDocumentHeld = () => {
10489
10491
  return false;
10490
10492
  };
10491
10493
 
10494
+ // A position waiting for the page to be whole is written after the reader has
10495
+ // seen the page at its top, and seen as a jump — after the movement, when a
10496
+ // route transition photographs the page as soon as it renders, stand-ins and
10497
+ // all. So it is also written into what is there meanwhile, as far as that goes
10498
+ // (the browser clamps the rest), and again once the page is whole, when what
10499
+ // it stands on has grown or shrunk.
10500
+ const putBackMeanwhile = (restoration) => {
10501
+ // Out of whatever commit or effect is asking: see scrollTo.
10502
+ queueMicrotask(() => {
10503
+ if (pendingRestoration !== restoration || isDocumentHeld()) {
10504
+ return;
10505
+ }
10506
+ scrollTo(restoration.position);
10507
+ });
10508
+ };
10509
+
10492
10510
  // What a page holds instead: not the place, which stays the url's, but the
10493
10511
  // moment it is put back (see useHoldScrollRestoration). Counted: several parts
10494
10512
  // of one page can be waiting.
@@ -10516,11 +10534,11 @@ const holdScrollRestoration = () => {
10516
10534
  };
10517
10535
 
10518
10536
  /**
10519
- * Holds back the scroll position a reload or a back/forward gives the page,
10520
- * while the page is not whole yet: written into what the page shows meanwhile,
10521
- * it is clamped to that height and lost. Put back after the commit in which
10522
- * `held` turns false — unless the reader has reached for the page in the
10523
- * meantime (a finger, a click, a wheel, a key), or gone elsewhere.
10537
+ * Says the page is not whole yet to the scroll position a reload or a
10538
+ * back/forward gives it: written into what the page shows meanwhile, it is
10539
+ * clamped to that height. Put back again after the commit in which `held`
10540
+ * turns false — unless the reader has reached for the page in the meantime (a
10541
+ * finger, a click, a wheel, a key), or gone elsewhere.
10524
10542
  *
10525
10543
  * The page's route actions are waited for without this — its code, a read
10526
10544
  * with no answer yet, one whose `when` holds later. This is for
@@ -10632,6 +10650,7 @@ const putBackOnceAnswered = (restoration) => {
10632
10650
  });
10633
10651
  return;
10634
10652
  }
10653
+ putBackMeanwhile(restoration);
10635
10654
  // A reader drawing its own wait subscribes in an effect, after the first
10636
10655
  // paint (see afterPaint): an answer that came before is drawn only then.
10637
10656
  let waitCount = 2;
@@ -10755,11 +10774,12 @@ const restoreScrollPosition = (url) => {
10755
10774
  };
10756
10775
 
10757
10776
  // A traversal back to `url`. The offset is written once the page returned to is
10758
- // rendered and answered (see putBackOnceAnswered): written sooner, the document
10759
- // still holds the page being left, or a stand-in for the one arriving, and
10760
- // clamps it to that height. It is read at once all the same — a page left
10761
- // taller than the one arriving is clamped by the render itself, and that clamp
10762
- // is a scroll recorded under the url already returned to.
10777
+ // rendered (see whenPageRendered): written sooner, the document still holds the
10778
+ // page being left and clamps it to that height. Again once it has answered (see
10779
+ // putBackOnceAnswered), when it rendered stand-ins (see putBackMeanwhile). It
10780
+ // is read at once all the same — a page left taller than the one arriving is
10781
+ // clamped by the render itself, and that clamp is a scroll recorded under the
10782
+ // url already returned to.
10763
10783
  const restoreScrollPositionOnReturn = (url) => {
10764
10784
  pendingRestoration = null;
10765
10785
  const href = new URL(url, window.location.href).href;