@jsenv/navi 0.29.373 → 0.29.374

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.
@@ -29399,12 +29399,12 @@ const paintTransitionWalls = (areaElement) => {
29399
29399
  // positioned against an ancestor of it: the wall is placed from
29400
29400
  // wherever its containing block turns out to be, by the offset between
29401
29401
  // that box and the target's.
29402
- const targetRect = target.getBoundingClientRect();
29402
+ const targetRect = pictureRect(target);
29403
29403
  const wallRect = wall.getBoundingClientRect();
29404
29404
  wall.style.left = `${targetRect.left - wallRect.left}px`;
29405
29405
  wall.style.top = `${targetRect.top - wallRect.top}px`;
29406
- wall.style.width = `${targetRect.width}px`;
29407
- wall.style.height = `${targetRect.height}px`;
29406
+ wall.style.width = `${targetRect.right - targetRect.left}px`;
29407
+ wall.style.height = `${targetRect.bottom - targetRect.top}px`;
29408
29408
  wallElements.push(wall);
29409
29409
  }
29410
29410
  }
@@ -29458,11 +29458,45 @@ const paintRestWalls = (sources, opacity) => {
29458
29458
  const measurePictureRects = (areaElement) => {
29459
29459
  const rects = new Map();
29460
29460
  for (const target of pictureTargets(areaElement)) {
29461
- rects.set(target, target.getBoundingClientRect());
29461
+ rects.set(target, pictureRect(target));
29462
29462
  }
29463
29463
  return rects;
29464
29464
  };
29465
29465
 
29466
+ // What the picture holds, which is what the wall covers at rest: a bar's
29467
+ // picture carries what its content paints outside its box (a button standing
29468
+ // up out of a tab bar), so its rectangle is taken with its descendants'. The
29469
+ // pages' is their own box — the movement cuts them at it anyway.
29470
+ const pictureRect = (target) => {
29471
+ const rect = target.getBoundingClientRect();
29472
+ let { left, top, right, bottom } = rect;
29473
+ if (!target.matches(FIXED_BAR_SELECTOR$1)) {
29474
+ return { left, top, right, bottom };
29475
+ }
29476
+ for (const descendant of target.querySelectorAll("*")) {
29477
+ if (descendant.hasAttribute(WALL_ATTRIBUTE)) {
29478
+ continue;
29479
+ }
29480
+ const descendantRect = descendant.getBoundingClientRect();
29481
+ if (descendantRect.width === 0 || descendantRect.height === 0) {
29482
+ continue;
29483
+ }
29484
+ if (descendantRect.left < left) {
29485
+ left = descendantRect.left;
29486
+ }
29487
+ if (descendantRect.top < top) {
29488
+ top = descendantRect.top;
29489
+ }
29490
+ if (descendantRect.right > right) {
29491
+ right = descendantRect.right;
29492
+ }
29493
+ if (descendantRect.bottom > bottom) {
29494
+ bottom = descendantRect.bottom;
29495
+ }
29496
+ }
29497
+ return { left, top, right, bottom };
29498
+ };
29499
+
29466
29500
  // The holes for the movement, and the ones for its last frame (see the CSS).
29467
29501
  const cutRestWalls = (holes, holesArriving = null) => {
29468
29502
  for (const restWall of restWallElements) {
@@ -29477,15 +29511,83 @@ const cutRestWalls = (holes, holesArriving = null) => {
29477
29511
  };
29478
29512
 
29479
29513
  // One evenodd polygon: the window, then each hole entered from and left by
29480
- // the window's origin, so the bridges between them have no area.
29514
+ // the window's origin, so the bridges between them have no area. The holes
29515
+ // must not overlap — evenodd fills where two of them do — and they do
29516
+ // overlap as measured: the pages run under the bars by design, so a bar's
29517
+ // rectangle lies inside the area's. Each is cut down to what the ones before
29518
+ // it left.
29481
29519
  const holesPolygon = (holes) => {
29482
29520
  let polygon = "0 0, 100% 0, 100% 100%, 0 100%, 0 0";
29483
- for (const { left, top, right, bottom } of holes) {
29521
+ for (const { left, top, right, bottom } of disjointRects(holes)) {
29484
29522
  polygon += `, ${left}px ${top}px, ${right}px ${top}px, ${right}px ${bottom}px, ${left}px ${bottom}px, ${left}px ${top}px, 0 0`;
29485
29523
  }
29486
29524
  return `polygon(evenodd, ${polygon})`;
29487
29525
  };
29488
29526
 
29527
+ const disjointRects = (rects) => {
29528
+ const result = [];
29529
+ for (const rect of rects) {
29530
+ let pieces = [rect];
29531
+ for (const placed of result) {
29532
+ const remaining = [];
29533
+ for (const piece of pieces) {
29534
+ remaining.push(...subtractRect(piece, placed));
29535
+ }
29536
+ pieces = remaining;
29537
+ }
29538
+ result.push(...pieces);
29539
+ }
29540
+ return result;
29541
+ };
29542
+
29543
+ // What is left of `rect` outside `hole`: up to four rectangles around it.
29544
+ const subtractRect = (rect, hole) => {
29545
+ if (
29546
+ hole.left >= rect.right ||
29547
+ hole.right <= rect.left ||
29548
+ hole.top >= rect.bottom ||
29549
+ hole.bottom <= rect.top
29550
+ ) {
29551
+ return [rect];
29552
+ }
29553
+ const pieces = [];
29554
+ const innerTop = hole.top > rect.top ? hole.top : rect.top;
29555
+ const innerBottom = hole.bottom < rect.bottom ? hole.bottom : rect.bottom;
29556
+ if (hole.top > rect.top) {
29557
+ pieces.push({
29558
+ left: rect.left,
29559
+ top: rect.top,
29560
+ right: rect.right,
29561
+ bottom: hole.top,
29562
+ });
29563
+ }
29564
+ if (hole.bottom < rect.bottom) {
29565
+ pieces.push({
29566
+ left: rect.left,
29567
+ top: hole.bottom,
29568
+ right: rect.right,
29569
+ bottom: rect.bottom,
29570
+ });
29571
+ }
29572
+ if (hole.left > rect.left) {
29573
+ pieces.push({
29574
+ left: rect.left,
29575
+ top: innerTop,
29576
+ right: hole.left,
29577
+ bottom: innerBottom,
29578
+ });
29579
+ }
29580
+ if (hole.right < rect.right) {
29581
+ pieces.push({
29582
+ left: hole.right,
29583
+ top: innerTop,
29584
+ right: rect.right,
29585
+ bottom: innerBottom,
29586
+ });
29587
+ }
29588
+ return pieces;
29589
+ };
29590
+
29489
29591
  const removeRestWalls = () => {
29490
29592
  for (const restWall of restWallElements) {
29491
29593
  restWall.remove();