@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.
@@ -30305,12 +30305,12 @@ const paintTransitionWalls = (areaElement) => {
30305
30305
  // positioned against an ancestor of it: the wall is placed from
30306
30306
  // wherever its containing block turns out to be, by the offset between
30307
30307
  // that box and the target's.
30308
- const targetRect = target.getBoundingClientRect();
30308
+ const targetRect = pictureRect(target);
30309
30309
  const wallRect = wall.getBoundingClientRect();
30310
30310
  wall.style.left = `${targetRect.left - wallRect.left}px`;
30311
30311
  wall.style.top = `${targetRect.top - wallRect.top}px`;
30312
- wall.style.width = `${targetRect.width}px`;
30313
- wall.style.height = `${targetRect.height}px`;
30312
+ wall.style.width = `${targetRect.right - targetRect.left}px`;
30313
+ wall.style.height = `${targetRect.bottom - targetRect.top}px`;
30314
30314
  wallElements.push(wall);
30315
30315
  }
30316
30316
  }
@@ -30364,11 +30364,45 @@ const paintRestWalls = (sources, opacity) => {
30364
30364
  const measurePictureRects = (areaElement) => {
30365
30365
  const rects = new Map();
30366
30366
  for (const target of pictureTargets(areaElement)) {
30367
- rects.set(target, target.getBoundingClientRect());
30367
+ rects.set(target, pictureRect(target));
30368
30368
  }
30369
30369
  return rects;
30370
30370
  };
30371
30371
 
30372
+ // What the picture holds, which is what the wall covers at rest: a bar's
30373
+ // picture carries what its content paints outside its box (a button standing
30374
+ // up out of a tab bar), so its rectangle is taken with its descendants'. The
30375
+ // pages' is their own box — the movement cuts them at it anyway.
30376
+ const pictureRect = (target) => {
30377
+ const rect = target.getBoundingClientRect();
30378
+ let { left, top, right, bottom } = rect;
30379
+ if (!target.matches(FIXED_BAR_SELECTOR$1)) {
30380
+ return { left, top, right, bottom };
30381
+ }
30382
+ for (const descendant of target.querySelectorAll("*")) {
30383
+ if (descendant.hasAttribute(WALL_ATTRIBUTE)) {
30384
+ continue;
30385
+ }
30386
+ const descendantRect = descendant.getBoundingClientRect();
30387
+ if (descendantRect.width === 0 || descendantRect.height === 0) {
30388
+ continue;
30389
+ }
30390
+ if (descendantRect.left < left) {
30391
+ left = descendantRect.left;
30392
+ }
30393
+ if (descendantRect.top < top) {
30394
+ top = descendantRect.top;
30395
+ }
30396
+ if (descendantRect.right > right) {
30397
+ right = descendantRect.right;
30398
+ }
30399
+ if (descendantRect.bottom > bottom) {
30400
+ bottom = descendantRect.bottom;
30401
+ }
30402
+ }
30403
+ return { left, top, right, bottom };
30404
+ };
30405
+
30372
30406
  // The holes for the movement, and the ones for its last frame (see the CSS).
30373
30407
  const cutRestWalls = (holes, holesArriving = null) => {
30374
30408
  for (const restWall of restWallElements) {
@@ -30383,15 +30417,83 @@ const cutRestWalls = (holes, holesArriving = null) => {
30383
30417
  };
30384
30418
 
30385
30419
  // One evenodd polygon: the window, then each hole entered from and left by
30386
- // the window's origin, so the bridges between them have no area.
30420
+ // the window's origin, so the bridges between them have no area. The holes
30421
+ // must not overlap — evenodd fills where two of them do — and they do
30422
+ // overlap as measured: the pages run under the bars by design, so a bar's
30423
+ // rectangle lies inside the area's. Each is cut down to what the ones before
30424
+ // it left.
30387
30425
  const holesPolygon = (holes) => {
30388
30426
  let polygon = "0 0, 100% 0, 100% 100%, 0 100%, 0 0";
30389
- for (const { left, top, right, bottom } of holes) {
30427
+ for (const { left, top, right, bottom } of disjointRects(holes)) {
30390
30428
  polygon += `, ${left}px ${top}px, ${right}px ${top}px, ${right}px ${bottom}px, ${left}px ${bottom}px, ${left}px ${top}px, 0 0`;
30391
30429
  }
30392
30430
  return `polygon(evenodd, ${polygon})`;
30393
30431
  };
30394
30432
 
30433
+ const disjointRects = (rects) => {
30434
+ const result = [];
30435
+ for (const rect of rects) {
30436
+ let pieces = [rect];
30437
+ for (const placed of result) {
30438
+ const remaining = [];
30439
+ for (const piece of pieces) {
30440
+ remaining.push(...subtractRect(piece, placed));
30441
+ }
30442
+ pieces = remaining;
30443
+ }
30444
+ result.push(...pieces);
30445
+ }
30446
+ return result;
30447
+ };
30448
+
30449
+ // What is left of `rect` outside `hole`: up to four rectangles around it.
30450
+ const subtractRect = (rect, hole) => {
30451
+ if (
30452
+ hole.left >= rect.right ||
30453
+ hole.right <= rect.left ||
30454
+ hole.top >= rect.bottom ||
30455
+ hole.bottom <= rect.top
30456
+ ) {
30457
+ return [rect];
30458
+ }
30459
+ const pieces = [];
30460
+ const innerTop = hole.top > rect.top ? hole.top : rect.top;
30461
+ const innerBottom = hole.bottom < rect.bottom ? hole.bottom : rect.bottom;
30462
+ if (hole.top > rect.top) {
30463
+ pieces.push({
30464
+ left: rect.left,
30465
+ top: rect.top,
30466
+ right: rect.right,
30467
+ bottom: hole.top,
30468
+ });
30469
+ }
30470
+ if (hole.bottom < rect.bottom) {
30471
+ pieces.push({
30472
+ left: rect.left,
30473
+ top: hole.bottom,
30474
+ right: rect.right,
30475
+ bottom: rect.bottom,
30476
+ });
30477
+ }
30478
+ if (hole.left > rect.left) {
30479
+ pieces.push({
30480
+ left: rect.left,
30481
+ top: innerTop,
30482
+ right: hole.left,
30483
+ bottom: innerBottom,
30484
+ });
30485
+ }
30486
+ if (hole.right < rect.right) {
30487
+ pieces.push({
30488
+ left: hole.right,
30489
+ top: innerTop,
30490
+ right: rect.right,
30491
+ bottom: innerBottom,
30492
+ });
30493
+ }
30494
+ return pieces;
30495
+ };
30496
+
30395
30497
  const removeRestWalls = () => {
30396
30498
  for (const restWall of restWallElements) {
30397
30499
  restWall.remove();