@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.
@@ -42637,6 +42637,11 @@ const css$16 = /* css */`@property --navi-route-row-pin {
42637
42637
  inherits: false
42638
42638
  }
42639
42639
 
42640
+ @property --navi-route-row-stand {
42641
+ syntax: "*";
42642
+ inherits: false
42643
+ }
42644
+
42640
42645
  .navi_route_travel {
42641
42646
  flex-direction: column;
42642
42647
  display: flex;
@@ -43178,16 +43183,14 @@ const RouteTravel = ({
43178
43183
  movement.rowTaken = true;
43179
43184
  // A travel no hand set off holds nothing: it goes where it goes.
43180
43185
  releaseHeldPage();
43181
- row.style.setProperty("--navi-route-row-stand", `${-position}px`);
43182
- row.setAttribute("data-route-row-taken", "");
43186
+ holdRowAt(row, position);
43183
43187
  afterFrames(2, () => {
43184
43188
  if (movementRef.current !== movement) {
43185
43189
  return;
43186
43190
  }
43187
43191
  // A scroller again, standing where no page does: not snapped meanwhile.
43188
43192
  row.setAttribute("data-route-row-travelling", "");
43189
- row.removeAttribute("data-route-row-taken");
43190
- row.style.removeProperty("--navi-route-row-stand");
43193
+ releaseTakenRow(row);
43191
43194
  afterFrames(1, () => {
43192
43195
  if (movementRef.current === movement) {
43193
43196
  travelRowTo(latestRef.current.currentIndex, movement);
@@ -43207,7 +43210,7 @@ const RouteTravel = ({
43207
43210
  movementRef.current = null;
43208
43211
  letRowGo(movement);
43209
43212
  putRowBack(movement);
43210
- row.removeAttribute("data-route-row-taken");
43213
+ releaseTakenRow(row);
43211
43214
  publishRouteRowMove(null);
43212
43215
  releaseHeldPage();
43213
43216
  releasePaneAtRest(row);
@@ -43685,6 +43688,22 @@ const copyScrollPositions = (from, to) => {
43685
43688
  // A tab pressed over a row a hand has left moving holds it still (takeRowFromHand):
43686
43689
  // what the row says meanwhile is not a hand moving it.
43687
43690
  const isRowTaken = row => row.hasAttribute("data-route-row-taken");
43691
+
43692
+ // What the CSS offsets while the row is taken. A picture left meanwhile is a clone
43693
+ // of the live page, and takes its offset along.
43694
+ const STANDING_IN_ROW = ":scope > [data-route-row-pane], :scope > [data-route-row-live], :scope > [data-route-row-pictures] > *";
43695
+ const holdRowAt = (row, position) => {
43696
+ for (const element of row.querySelectorAll(STANDING_IN_ROW)) {
43697
+ element.style.setProperty("--navi-route-row-stand", `${-position}px`);
43698
+ }
43699
+ row.setAttribute("data-route-row-taken", "");
43700
+ };
43701
+ const releaseTakenRow = row => {
43702
+ row.removeAttribute("data-route-row-taken");
43703
+ for (const element of row.querySelectorAll(STANDING_IN_ROW)) {
43704
+ element.style.removeProperty("--navi-route-row-stand");
43705
+ }
43706
+ };
43688
43707
  const afterFrames = (count, callback) => {
43689
43708
  if (count === 0) {
43690
43709
  callback();
@@ -88503,7 +88522,7 @@ const useListScrollSync = ({
88503
88522
  // where it lands.
88504
88523
  if (listItems.pagesSignal.peek() === 0) {
88505
88524
  if (typeof scrolledWanted.index === "number") {
88506
- placeItem(findItemElementAt(getListEl(), scrolledWanted.index), scrolledWanted.offset || 0);
88525
+ placeItem(findItemElementAt(getListEl(), scrolledWanted.index), scrolledWanted.offset || 0, scrolledWanted.align);
88507
88526
  }
88508
88527
  return;
88509
88528
  }
@@ -88567,11 +88586,13 @@ const useListScrollSync = ({
88567
88586
  const itemRect = itemEl.getBoundingClientRect();
88568
88587
  const viewportSize = (horizontal ? viewportRect.width : viewportRect.height) / scale;
88569
88588
  const itemSize = (horizontal ? itemRect.width : itemRect.height) / scale;
88570
- const scrollInset = getItemScrollInset(scrollerEl, itemEl, horizontal);
88571
- // Centred in what the room at the start leaves of the view (a fixed bar,
88572
- // a sticky header), not in the whole of it.
88573
- const alignedOffset = align === "center" ? scrollInset + (viewportSize - scrollInset - itemSize) / 2 : align === "end" ? viewportSize - itemSize : scrollInset;
88574
- const offsetWanted = resolveOpenOffset(alignedOffset + offset, viewportSize, itemSize);
88589
+ const offsetWanted = resolveHeldOffset({
88590
+ align,
88591
+ offset,
88592
+ scrollInset: getItemScrollInset(scrollerEl, itemEl, horizontal),
88593
+ viewportSize,
88594
+ itemSize
88595
+ });
88575
88596
  const offsetNow = (horizontal ? itemRect.left - viewportRect.left : itemRect.top - viewportRect.top) / scale;
88576
88597
  const scrollNow = horizontal ? scrollerEl.scrollLeft : scrollerEl.scrollTop;
88577
88598
  const delta = offsetNow - offsetWanted;
@@ -89310,6 +89331,7 @@ const useListScrollSync = ({
89310
89331
  }
89311
89332
  let index = null;
89312
89333
  let offset = 0;
89334
+ let align;
89313
89335
  if (typeof wanted === "number") {
89314
89336
  index = wanted;
89315
89337
  } else if (wanted && wanted.id !== undefined) {
@@ -89318,6 +89340,7 @@ const useListScrollSync = ({
89318
89340
  index = wanted.index;
89319
89341
  }
89320
89342
  offset = wanted.offset || 0;
89343
+ align = wanted.align;
89321
89344
  }
89322
89345
  if (index === null || index < 0 || index >= total) {
89323
89346
  return null;
@@ -89328,7 +89351,15 @@ const useListScrollSync = ({
89328
89351
  const rect = itemEl.getBoundingClientRect();
89329
89352
  itemSize = horizontal ? rect.width : rect.height;
89330
89353
  }
89331
- const above = resolveOpenOffset(getItemScrollInset(scrollerEl, itemEl, horizontal) + offset, screenSize, itemSize);
89354
+ // Not drawn yet, the item weighs nothing and has no inset: centred, it
89355
+ // stands half the screen down, which is where it will be put.
89356
+ const above = resolveHeldOffset({
89357
+ align,
89358
+ offset,
89359
+ scrollInset: getItemScrollInset(scrollerEl, itemEl, horizontal),
89360
+ viewportSize: screenSize,
89361
+ itemSize
89362
+ });
89332
89363
  return {
89333
89364
  index,
89334
89365
  above
@@ -90000,6 +90031,21 @@ const resolveOpenOffset = (offset, viewportSize, itemSize) => {
90000
90031
  }
90001
90032
  return offset;
90002
90033
  };
90034
+ // How far from the start of the view an item held at `{ offset, align }`
90035
+ // stands: read the same way where the list is placed (placeItem) and where the
90036
+ // window is sized around it (readHold), or the window frames a screen the
90037
+ // item is not on. Centred in what the room at the start leaves of the view (a
90038
+ // fixed bar, a sticky header), not in the whole of it.
90039
+ const resolveHeldOffset = ({
90040
+ align,
90041
+ offset,
90042
+ scrollInset,
90043
+ viewportSize,
90044
+ itemSize
90045
+ }) => {
90046
+ const alignedOffset = align === "center" ? scrollInset + (viewportSize - scrollInset - itemSize) / 2 : align === "end" ? viewportSize - itemSize : scrollInset;
90047
+ return resolveOpenOffset(alignedOffset + offset, viewportSize, itemSize);
90048
+ };
90003
90049
 
90004
90050
  // The room an item must be given at the top (or left) of the view: the
90005
90051
  // scroller's own scroll-padding — where a fixed bar publishes the space it