@jsenv/navi 0.30.38 → 0.30.39

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.
@@ -41321,6 +41321,11 @@ const css$16 = /* css */`@property --navi-route-row-pin {
41321
41321
  inherits: false
41322
41322
  }
41323
41323
 
41324
+ @property --navi-route-row-stand {
41325
+ syntax: "*";
41326
+ inherits: false
41327
+ }
41328
+
41324
41329
  .navi_route_travel {
41325
41330
  flex-direction: column;
41326
41331
  display: flex;
@@ -41862,16 +41867,14 @@ const RouteTravel = ({
41862
41867
  movement.rowTaken = true;
41863
41868
  // A travel no hand set off holds nothing: it goes where it goes.
41864
41869
  releaseHeldPage();
41865
- row.style.setProperty("--navi-route-row-stand", `${-position}px`);
41866
- row.setAttribute("data-route-row-taken", "");
41870
+ holdRowAt(row, position);
41867
41871
  afterFrames(2, () => {
41868
41872
  if (movementRef.current !== movement) {
41869
41873
  return;
41870
41874
  }
41871
41875
  // A scroller again, standing where no page does: not snapped meanwhile.
41872
41876
  row.setAttribute("data-route-row-travelling", "");
41873
- row.removeAttribute("data-route-row-taken");
41874
- row.style.removeProperty("--navi-route-row-stand");
41877
+ releaseTakenRow(row);
41875
41878
  afterFrames(1, () => {
41876
41879
  if (movementRef.current === movement) {
41877
41880
  travelRowTo(latestRef.current.currentIndex, movement);
@@ -41891,7 +41894,7 @@ const RouteTravel = ({
41891
41894
  movementRef.current = null;
41892
41895
  letRowGo(movement);
41893
41896
  putRowBack(movement);
41894
- row.removeAttribute("data-route-row-taken");
41897
+ releaseTakenRow(row);
41895
41898
  publishRouteRowMove(null);
41896
41899
  releaseHeldPage();
41897
41900
  releasePaneAtRest(row);
@@ -42369,6 +42372,22 @@ const copyScrollPositions = (from, to) => {
42369
42372
  // A tab pressed over a row a hand has left moving holds it still (takeRowFromHand):
42370
42373
  // what the row says meanwhile is not a hand moving it.
42371
42374
  const isRowTaken = row => row.hasAttribute("data-route-row-taken");
42375
+
42376
+ // What the CSS offsets while the row is taken. A picture left meanwhile is a clone
42377
+ // of the live page, and takes its offset along.
42378
+ const STANDING_IN_ROW = ":scope > [data-route-row-pane], :scope > [data-route-row-live], :scope > [data-route-row-pictures] > *";
42379
+ const holdRowAt = (row, position) => {
42380
+ for (const element of row.querySelectorAll(STANDING_IN_ROW)) {
42381
+ element.style.setProperty("--navi-route-row-stand", `${-position}px`);
42382
+ }
42383
+ row.setAttribute("data-route-row-taken", "");
42384
+ };
42385
+ const releaseTakenRow = row => {
42386
+ row.removeAttribute("data-route-row-taken");
42387
+ for (const element of row.querySelectorAll(STANDING_IN_ROW)) {
42388
+ element.style.removeProperty("--navi-route-row-stand");
42389
+ }
42390
+ };
42372
42391
  const afterFrames = (count, callback) => {
42373
42392
  if (count === 0) {
42374
42393
  callback();
@@ -86620,7 +86639,7 @@ const useListScrollSync = ({
86620
86639
  // where it lands.
86621
86640
  if (listItems.pagesSignal.peek() === 0) {
86622
86641
  if (typeof scrolledWanted.index === "number") {
86623
- placeItem(findItemElementAt(getListEl(), scrolledWanted.index), scrolledWanted.offset || 0);
86642
+ placeItem(findItemElementAt(getListEl(), scrolledWanted.index), scrolledWanted.offset || 0, scrolledWanted.align);
86624
86643
  }
86625
86644
  return;
86626
86645
  }
@@ -86684,11 +86703,13 @@ const useListScrollSync = ({
86684
86703
  const itemRect = itemEl.getBoundingClientRect();
86685
86704
  const viewportSize = (horizontal ? viewportRect.width : viewportRect.height) / scale;
86686
86705
  const itemSize = (horizontal ? itemRect.width : itemRect.height) / scale;
86687
- const scrollInset = getItemScrollInset(scrollerEl, itemEl, horizontal);
86688
- // Centred in what the room at the start leaves of the view (a fixed bar,
86689
- // a sticky header), not in the whole of it.
86690
- const alignedOffset = align === "center" ? scrollInset + (viewportSize - scrollInset - itemSize) / 2 : align === "end" ? viewportSize - itemSize : scrollInset;
86691
- const offsetWanted = resolveOpenOffset(alignedOffset + offset, viewportSize, itemSize);
86706
+ const offsetWanted = resolveHeldOffset({
86707
+ align,
86708
+ offset,
86709
+ scrollInset: getItemScrollInset(scrollerEl, itemEl, horizontal),
86710
+ viewportSize,
86711
+ itemSize
86712
+ });
86692
86713
  const offsetNow = (horizontal ? itemRect.left - viewportRect.left : itemRect.top - viewportRect.top) / scale;
86693
86714
  const scrollNow = horizontal ? scrollerEl.scrollLeft : scrollerEl.scrollTop;
86694
86715
  const delta = offsetNow - offsetWanted;
@@ -87417,6 +87438,7 @@ const useListScrollSync = ({
87417
87438
  }
87418
87439
  let index = null;
87419
87440
  let offset = 0;
87441
+ let align;
87420
87442
  if (typeof wanted === "number") {
87421
87443
  index = wanted;
87422
87444
  } else if (wanted && wanted.id !== undefined) {
@@ -87425,6 +87447,7 @@ const useListScrollSync = ({
87425
87447
  index = wanted.index;
87426
87448
  }
87427
87449
  offset = wanted.offset || 0;
87450
+ align = wanted.align;
87428
87451
  }
87429
87452
  if (index === null || index < 0 || index >= total) {
87430
87453
  return null;
@@ -87435,7 +87458,15 @@ const useListScrollSync = ({
87435
87458
  const rect = itemEl.getBoundingClientRect();
87436
87459
  itemSize = horizontal ? rect.width : rect.height;
87437
87460
  }
87438
- const above = resolveOpenOffset(getItemScrollInset(scrollerEl, itemEl, horizontal) + offset, screenSize, itemSize);
87461
+ // Not drawn yet, the item weighs nothing and has no inset: centred, it
87462
+ // stands half the screen down, which is where it will be put.
87463
+ const above = resolveHeldOffset({
87464
+ align,
87465
+ offset,
87466
+ scrollInset: getItemScrollInset(scrollerEl, itemEl, horizontal),
87467
+ viewportSize: screenSize,
87468
+ itemSize
87469
+ });
87439
87470
  return {
87440
87471
  index,
87441
87472
  above
@@ -87990,6 +88021,21 @@ const resolveOpenOffset = (offset, viewportSize, itemSize) => {
87990
88021
  }
87991
88022
  return offset;
87992
88023
  };
88024
+ // How far from the start of the view an item held at `{ offset, align }`
88025
+ // stands: read the same way where the list is placed (placeItem) and where the
88026
+ // window is sized around it (readHold), or the window frames a screen the
88027
+ // item is not on. Centred in what the room at the start leaves of the view (a
88028
+ // fixed bar, a sticky header), not in the whole of it.
88029
+ const resolveHeldOffset = ({
88030
+ align,
88031
+ offset,
88032
+ scrollInset,
88033
+ viewportSize,
88034
+ itemSize
88035
+ }) => {
88036
+ const alignedOffset = align === "center" ? scrollInset + (viewportSize - scrollInset - itemSize) / 2 : align === "end" ? viewportSize - itemSize : scrollInset;
88037
+ return resolveOpenOffset(alignedOffset + offset, viewportSize, itemSize);
88038
+ };
87993
88039
 
87994
88040
  // The room an item must be given at the top (or left) of the view: the
87995
88041
  // scroller's own scroll-padding — where a fixed bar publishes the space it