@jsenv/navi 0.29.371 → 0.29.372

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.
@@ -29141,12 +29141,17 @@ const TRANSITION_WALL_CSS = /* css */ `[data-navi-transition-wall] {
29141
29141
  left: 0;
29142
29142
 
29143
29143
  &[data-navi-transition-wall="rest"] {
29144
+ clip-path: var(--wall-holes);
29144
29145
  transition: opacity var(--navi-route-transition-duration, .3s) ease;
29145
29146
  position: fixed;
29146
29147
  inset: 0;
29147
29148
  }
29148
29149
  }
29149
29150
 
29151
+ :root:not(:active-view-transition) [data-navi-transition-wall="rest"] {
29152
+ clip-path: var(--wall-holes-arriving, var(--wall-holes));
29153
+ }
29154
+
29150
29155
  :root[data-navi-route-transition] {
29151
29156
  & .navi_dialog::backdrop, & .navi_popover_backdrop {
29152
29157
  backdrop-filter: none;
@@ -29180,6 +29185,10 @@ let wallElements = [];
29180
29185
  // the opacity they are heading to once it plays.
29181
29186
  let restWallElements = [];
29182
29187
  let restWallOpacity = "0";
29188
+ // Where each picture stood in the state being left, by element: a hole in
29189
+ // the rest walls is cut only where a picture stands at EVERY moment of the
29190
+ // movement, which takes both states' rectangles.
29191
+ let leavingRects = new Map();
29183
29192
 
29184
29193
  /**
29185
29194
  * Name what stands around the area, before the picture of the state being left
@@ -29194,8 +29203,12 @@ const nameTransitionFurniture = (owner, areaElement) => {
29194
29203
  nameFurnitureAround(areaElement);
29195
29204
  const sources = paintTransitionWalls(areaElement);
29196
29205
  // The state being left has walls: what no picture covers starts dimmed.
29206
+ // The frame the first picture is taken on shows the live document, so the
29207
+ // holes are this state's rectangles, stand-ins inside.
29197
29208
  removeRestWalls();
29198
- paintRestWalls(areaElement, sources, "1");
29209
+ leavingRects = measurePictureRects(areaElement);
29210
+ paintRestWalls(sources, "1");
29211
+ cutRestWalls([...leavingRects.values()]);
29199
29212
  };
29200
29213
 
29201
29214
  /**
@@ -29222,10 +29235,38 @@ const holdTransitionFurniture = (owner, areaElement) => {
29222
29235
  // have), from the state arriving otherwise (they come up from nothing).
29223
29236
  restWallOpacity = sources.length > 0 ? "1" : "0";
29224
29237
  if (restWallElements.length === 0) {
29225
- paintRestWalls(areaElement, sources, "0");
29226
- } else {
29227
- cutRestWalls(areaElement);
29228
- }
29238
+ paintRestWalls(sources, "0");
29239
+ }
29240
+ // For the length of the movement a picture is only ever where the two
29241
+ // states' rectangles meet: the pages' pictures slide, and a taller page
29242
+ // arriving does not make the one leaving any taller. A picture only one
29243
+ // state has travels away from where it stood, so it gets no hole at all.
29244
+ const arrivingRects = measurePictureRects(areaElement);
29245
+ const holes = [];
29246
+ for (const [target, arrivingRect] of arrivingRects) {
29247
+ const leavingRect = leavingRects.get(target);
29248
+ if (!leavingRect) {
29249
+ continue;
29250
+ }
29251
+ const left =
29252
+ leavingRect.left > arrivingRect.left
29253
+ ? leavingRect.left
29254
+ : arrivingRect.left;
29255
+ const top =
29256
+ leavingRect.top > arrivingRect.top ? leavingRect.top : arrivingRect.top;
29257
+ const right =
29258
+ leavingRect.right < arrivingRect.right
29259
+ ? leavingRect.right
29260
+ : arrivingRect.right;
29261
+ const bottom =
29262
+ leavingRect.bottom < arrivingRect.bottom
29263
+ ? leavingRect.bottom
29264
+ : arrivingRect.bottom;
29265
+ if (right > left && bottom > top) {
29266
+ holes.push({ left, top, right, bottom });
29267
+ }
29268
+ }
29269
+ cutRestWalls(holes, [...arrivingRects.values()]);
29229
29270
  const cssText = `${travelRule("old", namesLeaving, "--navi-route-transition-leave")}${travelRule("new", namesArriving, "--navi-route-transition-enter")}`;
29230
29271
  if (!cssText) {
29231
29272
  return;
@@ -29388,11 +29429,11 @@ const createWall = (source) => {
29388
29429
  };
29389
29430
 
29390
29431
  // One per open wall, over the window, at the opacity of the state they are
29391
- // painted from; a hole where each picture stands, since the picture has a
29392
- // stand-in of its own and shows the live document through nowhere — and on
29393
- // the frame the first picture is taken on, before any picture is up, a hole
29394
- // is what keeps the two from being painted on top of each other.
29395
- const paintRestWalls = (areaElement, sources, opacity) => {
29432
+ // painted from. A hole is cut where a picture stands, since the picture has
29433
+ // a stand-in of its own and shows the live document through nowhere — and on
29434
+ // the frames the live document IS shown, the first and the last, a hole is
29435
+ // what keeps the two from being painted on top of each other.
29436
+ const paintRestWalls = (sources, opacity) => {
29396
29437
  for (const source of sources) {
29397
29438
  const restWall = createWall(source);
29398
29439
  restWall.setAttribute(WALL_ATTRIBUTE, "rest");
@@ -29400,25 +29441,37 @@ const paintRestWalls = (areaElement, sources, opacity) => {
29400
29441
  document.body.appendChild(restWall);
29401
29442
  restWallElements.push(restWall);
29402
29443
  }
29403
- cutRestWalls(areaElement);
29404
29444
  };
29405
29445
 
29406
- // The holes, cut again at the hold: the state arriving may have brought a
29407
- // bar, or taken one away and let the pages grow into its band.
29408
- const cutRestWalls = (areaElement) => {
29409
- if (restWallElements.length === 0) {
29410
- return;
29411
- }
29412
- // One evenodd polygon: the window, then each hole entered from and left by
29413
- // the window's origin, so the bridges between them have no area.
29414
- let polygon = "0 0, 100% 0, 100% 100%, 0 100%, 0 0";
29446
+ const measurePictureRects = (areaElement) => {
29447
+ const rects = new Map();
29415
29448
  for (const target of pictureTargets(areaElement)) {
29416
- const { left, top, right, bottom } = target.getBoundingClientRect();
29417
- polygon += `, ${left}px ${top}px, ${right}px ${top}px, ${right}px ${bottom}px, ${left}px ${bottom}px, ${left}px ${top}px, 0 0`;
29449
+ rects.set(target, target.getBoundingClientRect());
29418
29450
  }
29451
+ return rects;
29452
+ };
29453
+
29454
+ // The holes for the movement, and the ones for its last frame (see the CSS).
29455
+ const cutRestWalls = (holes, holesArriving = null) => {
29419
29456
  for (const restWall of restWallElements) {
29420
- restWall.style.clipPath = `polygon(evenodd, ${polygon})`;
29457
+ restWall.style.setProperty("--wall-holes", holesPolygon(holes));
29458
+ if (holesArriving) {
29459
+ restWall.style.setProperty(
29460
+ "--wall-holes-arriving",
29461
+ holesPolygon(holesArriving),
29462
+ );
29463
+ }
29464
+ }
29465
+ };
29466
+
29467
+ // One evenodd polygon: the window, then each hole entered from and left by
29468
+ // the window's origin, so the bridges between them have no area.
29469
+ const holesPolygon = (holes) => {
29470
+ let polygon = "0 0, 100% 0, 100% 100%, 0 100%, 0 0";
29471
+ for (const { left, top, right, bottom } of holes) {
29472
+ polygon += `, ${left}px ${top}px, ${right}px ${top}px, ${right}px ${bottom}px, ${left}px ${bottom}px, ${left}px ${top}px, 0 0`;
29421
29473
  }
29474
+ return `polygon(evenodd, ${polygon})`;
29422
29475
  };
29423
29476
 
29424
29477
  const removeRestWalls = () => {
@@ -29427,6 +29480,7 @@ const removeRestWalls = () => {
29427
29480
  }
29428
29481
  restWallElements = [];
29429
29482
  restWallOpacity = "0";
29483
+ leavingRects = new Map();
29430
29484
  };
29431
29485
 
29432
29486
  installImportMetaCssBuild(import.meta);