@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/jsenv_navi.js
CHANGED
|
@@ -9871,15 +9871,16 @@ const [publishRouteRender, observeRouteRender] = createPubSub();
|
|
|
9871
9871
|
*
|
|
9872
9872
|
* A page whose height depends on something still loading is not there at the
|
|
9873
9873
|
* moment it is put back, and a position beyond what has arrived is clamped.
|
|
9874
|
-
*
|
|
9875
|
-
*
|
|
9876
|
-
*
|
|
9877
|
-
*
|
|
9878
|
-
*
|
|
9879
|
-
*
|
|
9880
|
-
* (
|
|
9881
|
-
*
|
|
9882
|
-
*
|
|
9874
|
+
* So it is written into what is there, as far as that goes, and written again
|
|
9875
|
+
* once the page is whole (see putBackMeanwhile). What navi knows a first render
|
|
9876
|
+
* left out, it waits for: a `<Box mount="after-paint">` is built before the
|
|
9877
|
+
* offset that shows it is written (see mount_after_paint.jsx), and a reload or
|
|
9878
|
+
* a return waits for the route actions the page has nothing to draw for — its
|
|
9879
|
+
* code among them — including one whose `when` lets it ask after the position
|
|
9880
|
+
* is written (see stayForLateAsks). Anything else only the page knows, and it
|
|
9881
|
+
* says so (useHoldScrollRestoration). A wait can be long, so the reader
|
|
9882
|
+
* reaching for the page during it cancels the position: moved afterwards, they
|
|
9883
|
+
* would lose whatever they had started on.
|
|
9883
9884
|
*
|
|
9884
9885
|
* WHEN a page is arrived at is not decided here either. A document navigation
|
|
9885
9886
|
* lands where its kind says (see via_history.js), and one scrollport can be
|
|
@@ -10038,6 +10039,7 @@ const putBack = (restoration) => {
|
|
|
10038
10039
|
restoration.due = true;
|
|
10039
10040
|
if (restorationHoldCount) {
|
|
10040
10041
|
// The page is not whole yet: the last release puts it back.
|
|
10042
|
+
putBackMeanwhile(restoration);
|
|
10041
10043
|
return;
|
|
10042
10044
|
}
|
|
10043
10045
|
if (isDocumentHeld()) {
|
|
@@ -10084,6 +10086,22 @@ const isDocumentHeld = () => {
|
|
|
10084
10086
|
return false;
|
|
10085
10087
|
};
|
|
10086
10088
|
|
|
10089
|
+
// A position waiting for the page to be whole is written after the reader has
|
|
10090
|
+
// seen the page at its top, and seen as a jump — after the movement, when a
|
|
10091
|
+
// route transition photographs the page as soon as it renders, stand-ins and
|
|
10092
|
+
// all. So it is also written into what is there meanwhile, as far as that goes
|
|
10093
|
+
// (the browser clamps the rest), and again once the page is whole, when what
|
|
10094
|
+
// it stands on has grown or shrunk.
|
|
10095
|
+
const putBackMeanwhile = (restoration) => {
|
|
10096
|
+
// Out of whatever commit or effect is asking: see scrollTo.
|
|
10097
|
+
queueMicrotask(() => {
|
|
10098
|
+
if (pendingRestoration !== restoration || isDocumentHeld()) {
|
|
10099
|
+
return;
|
|
10100
|
+
}
|
|
10101
|
+
scrollTo(restoration.position);
|
|
10102
|
+
});
|
|
10103
|
+
};
|
|
10104
|
+
|
|
10087
10105
|
// What a page holds instead: not the place, which stays the url's, but the
|
|
10088
10106
|
// moment it is put back (see useHoldScrollRestoration). Counted: several parts
|
|
10089
10107
|
// of one page can be waiting.
|
|
@@ -10111,11 +10129,11 @@ const holdScrollRestoration = () => {
|
|
|
10111
10129
|
};
|
|
10112
10130
|
|
|
10113
10131
|
/**
|
|
10114
|
-
*
|
|
10115
|
-
*
|
|
10116
|
-
*
|
|
10117
|
-
*
|
|
10118
|
-
*
|
|
10132
|
+
* Says the page is not whole yet to the scroll position a reload or a
|
|
10133
|
+
* back/forward gives it: written into what the page shows meanwhile, it is
|
|
10134
|
+
* clamped to that height. Put back again after the commit in which `held`
|
|
10135
|
+
* turns false — unless the reader has reached for the page in the meantime (a
|
|
10136
|
+
* finger, a click, a wheel, a key), or gone elsewhere.
|
|
10119
10137
|
*
|
|
10120
10138
|
* The page's route actions are waited for without this — its code, a read
|
|
10121
10139
|
* with no answer yet, one whose `when` holds later. This is for
|
|
@@ -10227,6 +10245,7 @@ const putBackOnceAnswered = (restoration) => {
|
|
|
10227
10245
|
});
|
|
10228
10246
|
return;
|
|
10229
10247
|
}
|
|
10248
|
+
putBackMeanwhile(restoration);
|
|
10230
10249
|
// A reader drawing its own wait subscribes in an effect, after the first
|
|
10231
10250
|
// paint (see afterPaint): an answer that came before is drawn only then.
|
|
10232
10251
|
let waitCount = 2;
|
|
@@ -10350,11 +10369,12 @@ const restoreScrollPosition = (url) => {
|
|
|
10350
10369
|
};
|
|
10351
10370
|
|
|
10352
10371
|
// A traversal back to `url`. The offset is written once the page returned to is
|
|
10353
|
-
// rendered
|
|
10354
|
-
//
|
|
10355
|
-
//
|
|
10356
|
-
//
|
|
10357
|
-
// is a scroll recorded under the
|
|
10372
|
+
// rendered (see whenPageRendered): written sooner, the document still holds the
|
|
10373
|
+
// page being left and clamps it to that height. Again once it has answered (see
|
|
10374
|
+
// putBackOnceAnswered), when it rendered stand-ins (see putBackMeanwhile). It
|
|
10375
|
+
// is read at once all the same — a page left taller than the one arriving is
|
|
10376
|
+
// clamped by the render itself, and that clamp is a scroll recorded under the
|
|
10377
|
+
// url already returned to.
|
|
10358
10378
|
const restoreScrollPositionOnReturn = (url) => {
|
|
10359
10379
|
pendingRestoration = null;
|
|
10360
10380
|
const href = new URL(url, window.location.href).href;
|