@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.
- package/dist/dev/jsenv_navi.js +39 -19
- package/dist/dev/jsenv_navi.js.map +2 -2
- package/dist/jsenv_navi.js +39 -19
- package/dist/jsenv_navi.js.map +2 -2
- package/docs/navigation.md +8 -4
- package/package.json +1 -1
package/dist/dev/jsenv_navi.js
CHANGED
|
@@ -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
|
-
*
|
|
10280
|
-
*
|
|
10281
|
-
*
|
|
10282
|
-
*
|
|
10283
|
-
*
|
|
10284
|
-
*
|
|
10285
|
-
* (
|
|
10286
|
-
*
|
|
10287
|
-
*
|
|
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
|
-
*
|
|
10520
|
-
*
|
|
10521
|
-
*
|
|
10522
|
-
*
|
|
10523
|
-
*
|
|
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
|
|
10759
|
-
//
|
|
10760
|
-
//
|
|
10761
|
-
//
|
|
10762
|
-
// is a scroll recorded under the
|
|
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;
|