@n-uf/placement 26.11.50 → 26.11.51
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.
- package/CHANGELOG.md +36 -0
- package/dist/{chunk-NM4ADJC2.js → chunk-UPZXNTIR.js} +113 -49
- package/dist/{chunk-NM4ADJC2.js.map → chunk-UPZXNTIR.js.map} +1 -1
- package/dist/{lanes-CkFz9E5l.d.ts → lanes-Dl39s0r7.d.ts} +5 -0
- package/dist/scene-cases.d.ts +7 -2
- package/dist/scene-cases.js +36 -1
- package/dist/scene-cases.js.map +1 -1
- package/dist/scene.d.ts +2 -2
- package/dist/scene.js +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,42 @@
|
|
|
3
3
|
Versions are calendar versions, `YY.M.R` (year, month of the release, counter within the month), shared with
|
|
4
4
|
`@n-uf/motion`: both packages carry the same version, and a release bumps both.
|
|
5
5
|
|
|
6
|
+
## 26.11.51
|
|
7
|
+
|
|
8
|
+
A stretch is the room the drop makes. Host notes: additive; a host that draws hatches may read their new `givesWay`.
|
|
9
|
+
|
|
10
|
+
- `./scene`, **a neighbor that steps down to make room gives way** (fix). One rule for marks and stretches: when the
|
|
11
|
+
item lands beside a room, a neighbor gives way if it moves away from the room, leaves the lane (the menu, a float)
|
|
12
|
+
or takes a shorter form than it has now. For the marks, "now" is the layout they are drawn in (as seen) when no
|
|
13
|
+
spot is held; with `spot` held it is the layout as seen with the held item lifted (what the window showed before
|
|
14
|
+
this drop), since in the spot's own layout the neighbor is already drawn stepped down: its striped end and
|
|
15
|
+
`givesWay` stay. Stretches compare with the layout as seen with the held item lifted.
|
|
16
|
+
- A free stretch of a bar or a toolbar rail runs from flush after the neighbor before it to flush before the one
|
|
17
|
+
after it **in the forms the drop leaves them in**, not only as seen. Where the room as seen is shorter than the
|
|
18
|
+
item but a drop there steps a neighbor down, the stretch now has its sliding spot (and its pitched spots under
|
|
19
|
+
`"pitched"`, not only its two ends), so the landing stays at the hand across that room; before, it stayed at a
|
|
20
|
+
dock at one end while the pointer crossed the open room. A dock's push of a neighbor that keeps no room for it
|
|
21
|
+
is no room made: that end stays where it is seen. The forms don't depend on the space a dock keeps, so every start
|
|
22
|
+
in the stretch finds them alike, and every start that lands as aimed (within 1 px) is in the range.
|
|
23
|
+
- **No sliding spot is a point; every landing a room offers has a spot.** A stretch with room for the item at a
|
|
24
|
+
single start (its range under a pixel), or shorter than the item, has no sliding spot: that start (flush after the
|
|
25
|
+
neighbor before it) is a plain dock, as a pitched stretch's end gives it, with the plain dock's id and no `slide`
|
|
26
|
+
(`…@<pitches kept>` where a dock between the same neighbors already has that id), `home` where it is the item's own
|
|
27
|
+
place. A spot already landing within 1 px of it (the item's own place, say) stays instead. So under `"free"` every
|
|
28
|
+
landing `"pitched"` offers is reached, by a spot within 1 px or a slide's range, and its box and striped ends come
|
|
29
|
+
from its landing. (Before this, such a stretch could show as a `…@slide` spot with `from` equal to `to`; or, where
|
|
30
|
+
no plain dock landed there, as nothing: no spot, box or hatch.)
|
|
31
|
+
- **The item's own place wins its landing** (fix, both modes): a dock landing a fraction of a pixel before it (on an
|
|
32
|
+
over-subscribed edge) no longer takes its place, so its home spot is listed.
|
|
33
|
+
- **Marks:** a box gets its striped end (`HATCH_END`) at the side of each neighbor that gives way, whether or not the
|
|
34
|
+
room as seen is shorter than the item; where none moves, leaves or steps down, the box is plain. The hatch mark
|
|
35
|
+
carries **`LaneMark.givesWay`**, the neighbor's id (data for hosts and tests; nothing to show). The old fallback for
|
|
36
|
+
short room where neither neighbor moved (a striped end at the neighbor after) is gone: there the item fits by
|
|
37
|
+
taking another form itself, and its box is plain.
|
|
38
|
+
- `./scene/cases`, **`STEP_SINCE`** (`"26.11.51"`) and the landing row `landing-step-down-room`: a toolbar slid at
|
|
39
|
+
0.3 px/ms over room a neighbor steps down to make stays within 48 px of the pointer (56 on the frame before a hop).
|
|
40
|
+
A host on an older version skips it.
|
|
41
|
+
|
|
6
42
|
## 26.11.50
|
|
7
43
|
|
|
8
44
|
Stretch positions. With `@n-uf/motion`'s sliding spots. Host notes: **a contract change**: `stretchPositions` now
|
|
@@ -3327,6 +3327,17 @@ function neighbors(after, edge, dragged, axis) {
|
|
|
3327
3327
|
const at = me ? mid(me.rect, axis) : 0;
|
|
3328
3328
|
return { before: [...others].reverse().find((o) => mid(o.r, axis) < at)?.id ?? "^", next: others.find((o) => mid(o.r, axis) >= at)?.id ?? "$" };
|
|
3329
3329
|
}
|
|
3330
|
+
function givesWay(now, after, lane, side, extent) {
|
|
3331
|
+
if (!now) return null;
|
|
3332
|
+
if (!after || after.inMenu || after.floating || after.edge !== lane) return "leaves";
|
|
3333
|
+
const [p0, p1] = extent(now.rect);
|
|
3334
|
+
const [q0, q1] = extent(after.rect);
|
|
3335
|
+
if (after.form !== now.form && q1 - q0 < p1 - p0 - 0.5) return "steps";
|
|
3336
|
+
return (side === "before" ? p1 - q1 : q0 - p0) > 0.5 ? "moves" : null;
|
|
3337
|
+
}
|
|
3338
|
+
function liftedLayout(scene, dragged, options) {
|
|
3339
|
+
return solve(lift(scene, dragged), options.previous ? { previous: options.previous } : {});
|
|
3340
|
+
}
|
|
3330
3341
|
function othersKey(layout, dragged) {
|
|
3331
3342
|
return Object.keys(layout.items).filter((id) => id !== dragged).sort().map((id) => {
|
|
3332
3343
|
const it = layout.items[id];
|
|
@@ -3359,7 +3370,7 @@ function lanes(scene, dragged, options = {}) {
|
|
|
3359
3370
|
const rebuilt = base.lanes.map((l) => {
|
|
3360
3371
|
const raws = base.raws.get(l.id);
|
|
3361
3372
|
if (!raws) return l;
|
|
3362
|
-
const again = laneFrom(l.id, raws, held.layout, base.seen, dragged, base.refusals, base.halves.has(l.id), base.share, base.marking, l.id === heldLane && !held.slide);
|
|
3373
|
+
const again = laneFrom(l.id, raws, held.layout, base.seen, dragged, base.refusals, base.halves.has(l.id), base.share, base.marking, l.id === heldLane && !held.slide, true);
|
|
3363
3374
|
if (!again) return l;
|
|
3364
3375
|
return l.id === heldLane ? again : { ...l, marks: again.marks };
|
|
3365
3376
|
});
|
|
@@ -3399,12 +3410,13 @@ function build(scene, dragged, options) {
|
|
|
3399
3410
|
raws.push({ lane, edge: null, axis: "y", id: `${lane}/${p.kind === "rail" ? "end" : "line"}`, before: "^", next: "$", landing, layout, target: t, hit: strip ?? t.hit, ...strip ? { strip: true } : {} });
|
|
3400
3411
|
}
|
|
3401
3412
|
}
|
|
3413
|
+
const lifted = liftedLayout(scene, dragged, options);
|
|
3402
3414
|
if (options.stretchPositions !== "pitched") {
|
|
3403
|
-
const { spots, absorbed } = slidingSpots(scene, dragged, options, seen, raws, pitch > 0 ? pitch : SPOT_PITCH);
|
|
3415
|
+
const { spots, absorbed } = slidingSpots(scene, dragged, options, seen, lifted, raws, pitch > 0 ? pitch : SPOT_PITCH);
|
|
3404
3416
|
for (let i = raws.length - 1; i >= 0; i--) if (absorbed.has(raws[i])) raws.splice(i, 1);
|
|
3405
3417
|
raws.push(...spots);
|
|
3406
|
-
} else if (pitch > 0) raws.push(...pitchedSpots(scene, dragged, options, seen, raws, pitch));
|
|
3407
|
-
raws.push(...takeoverSpots(scene, dragged, options, seen, raws, pitch > 0 ? pitch : SPOT_PITCH));
|
|
3418
|
+
} else if (pitch > 0) raws.push(...pitchedSpots(scene, dragged, options, seen, lifted, raws, pitch));
|
|
3419
|
+
raws.push(...takeoverSpots(scene, dragged, options, seen, lifted, raws, pitch > 0 ? pitch : SPOT_PITCH));
|
|
3408
3420
|
const byLane = /* @__PURE__ */ new Map();
|
|
3409
3421
|
for (const r of raws) byLane.set(r.lane, [...byLane.get(r.lane) ?? [], r]);
|
|
3410
3422
|
const halves = new Set(scene.edges.filter((e) => (e.side === "left" || e.side === "right") && !e.compact).map((e) => e.id));
|
|
@@ -3414,7 +3426,8 @@ function build(scene, dragged, options) {
|
|
|
3414
3426
|
const main = scene.items[id]?.forms[axis === "x" ? "row" : "column"]?.[0]?.main;
|
|
3415
3427
|
return main?.grows ? main.natural : void 0;
|
|
3416
3428
|
},
|
|
3417
|
-
gap: (edge) => nonNeg(scene.edges.find((e) => e.id === edge)?.gap)
|
|
3429
|
+
gap: (edge) => nonNeg(scene.edges.find((e) => e.id === edge)?.gap),
|
|
3430
|
+
lifted
|
|
3418
3431
|
};
|
|
3419
3432
|
const shareOf = (g, size) => g === void 0 || !Number.isFinite(g) || size <= EPS ? 0.5 : clamp(g / size, 0, 1);
|
|
3420
3433
|
const w = own?.rect.width ?? 0;
|
|
@@ -3452,7 +3465,7 @@ function build(scene, dragged, options) {
|
|
|
3452
3465
|
}
|
|
3453
3466
|
};
|
|
3454
3467
|
}
|
|
3455
|
-
function laneFrom(id, list, drawn, seen, dragged, rs, halves, share, marking, heldHere = false) {
|
|
3468
|
+
function laneFrom(id, list, drawn, seen, dragged, rs, halves, share, marking, heldHere = false, spotHeld = false) {
|
|
3456
3469
|
if (list.length === 0) return null;
|
|
3457
3470
|
const first = list[0];
|
|
3458
3471
|
const axis = first.axis;
|
|
@@ -3468,7 +3481,13 @@ function laneFrom(id, list, drawn, seen, dragged, rs, halves, share, marking, he
|
|
|
3468
3481
|
const sorted = [...list].sort((a, b) => mid(firstOf(a), axis) - mid(firstOf(b), axis) || (a.home ? -1 : b.home ? 1 : 0));
|
|
3469
3482
|
const homeAt = halves ? void 0 : list.find((r) => r.home)?.landing;
|
|
3470
3483
|
const nearHome = (r) => !!homeAt && !r.home && !r.slide && Math.abs(lo(r.landing, axis) - lo(homeAt, axis)) < Math.max(0, marking.pitch) / 2;
|
|
3471
|
-
const unique =
|
|
3484
|
+
const unique = [];
|
|
3485
|
+
for (const x of sorted) {
|
|
3486
|
+
if (nearHome(x)) continue;
|
|
3487
|
+
const k = unique.findIndex((y) => !x.slide && !y.slide && sameRect(y.landing, x.landing) || y.id === x.id);
|
|
3488
|
+
if (k < 0) unique.push(x);
|
|
3489
|
+
else if (x.home && !unique[k].home && !unique.some((y) => y.id === x.id && y !== unique[k])) unique[k] = x;
|
|
3490
|
+
}
|
|
3472
3491
|
const start = lo(laneRect, axis);
|
|
3473
3492
|
const end = start + len(laneRect, axis);
|
|
3474
3493
|
const drawnItems = first.edge && halves ? new Map(onEdge(drawn, first.edge, dragged, axis).map((o) => [o.id, o.r])) : /* @__PURE__ */ new Map();
|
|
@@ -3509,7 +3528,7 @@ function laneFrom(id, list, drawn, seen, dragged, rs, halves, share, marking, he
|
|
|
3509
3528
|
}) : [];
|
|
3510
3529
|
const landings = /* @__PURE__ */ new Map();
|
|
3511
3530
|
if (!halves) {
|
|
3512
|
-
for (const x of unique) if (!x.pitched && !x.home && !
|
|
3531
|
+
for (const x of unique) if (!x.pitched && !x.home && !landings.has(`${x.before}|${x.next}`)) landings.set(`${x.before}|${x.next}`, { landing: x.landing, layout: x.layout });
|
|
3513
3532
|
}
|
|
3514
3533
|
const extent = (iid, r) => {
|
|
3515
3534
|
const n = halves ? void 0 : marking.natural(iid, axis);
|
|
@@ -3519,7 +3538,9 @@ function laneFrom(id, list, drawn, seen, dragged, rs, halves, share, marking, he
|
|
|
3519
3538
|
besideMin: halves || marking.pitch <= 0 ? itemLen : marking.pitch,
|
|
3520
3539
|
gap: marking.gap(first.edge),
|
|
3521
3540
|
landingOf: (pair) => landings.get(pair),
|
|
3522
|
-
|
|
3541
|
+
// Judged against the layout the marks are drawn in; with a spot held, against the layout as seen with the held
|
|
3542
|
+
// item lifted (in the spot's own a neighbor has already stepped down or moved).
|
|
3543
|
+
givesWay: (iid, side, after) => givesWay((spotHeld ? marking.lifted : drawn).items[iid], after.items[iid], id, side, (r) => extent(iid, r))
|
|
3523
3544
|
}) : virtualMarks(id, unique, drawn.items[dragged]);
|
|
3524
3545
|
return { id, rect: laneRect, axis, spots, refused, marks, ...list.every((r) => r.strip) ? { owns: true } : {} };
|
|
3525
3546
|
}
|
|
@@ -3530,6 +3551,10 @@ var HATCH_END = 8;
|
|
|
3530
3551
|
var HATCH_EDGE = 8;
|
|
3531
3552
|
function edgeMarks(lane, laneRect, axis, items, refused, itemLen, lands, held, more) {
|
|
3532
3553
|
const { besideMin } = more;
|
|
3554
|
+
const hatches = (pair, a, b, p, q, gl, gr) => {
|
|
3555
|
+
if (gl && Math.abs(p - a) < EPS) out.push({ id: `${lane}/hatch/${pair}:before`, kind: "hatch", rect: along(laneRect, axis, p, p + Math.min(HATCH_END, (q - p) / 2)), givesWay: gl });
|
|
3556
|
+
if (gr && Math.abs(q - b) < EPS) out.push({ id: `${lane}/hatch/${pair}:after`, kind: "hatch", rect: along(laneRect, axis, q - Math.min(HATCH_END, (q - p) / 2), q), givesWay: gr });
|
|
3557
|
+
};
|
|
3533
3558
|
const heldAt = items.find((o) => o.id === held);
|
|
3534
3559
|
const heldSpan = heldAt ? [lo(heldAt.r, axis), lo(heldAt.r, axis) + len(heldAt.r, axis)] : null;
|
|
3535
3560
|
const out = [];
|
|
@@ -3547,33 +3572,18 @@ function edgeMarks(lane, laneRect, axis, items, refused, itemLen, lands, held, m
|
|
|
3547
3572
|
const named = `${left}|${right}`;
|
|
3548
3573
|
const beside = ends[i + 1].id === held ? "before" : ends[i].id === held ? "after" : null;
|
|
3549
3574
|
const min = beside ? Math.min(itemLen, besideMin) : itemLen;
|
|
3575
|
+
const spot = !beside && named === pair && items.length > 0 && !isRefused2((a + b) / 2) ? more.landingOf(pair) : void 0;
|
|
3576
|
+
const gl = spot && left !== "^" && more.givesWay(left, "before", spot.layout) ? left : null;
|
|
3577
|
+
const gr = spot && right !== "$" && more.givesWay(right, "after", spot.layout) ? right : null;
|
|
3550
3578
|
if (b - a < min - EPS) {
|
|
3551
|
-
|
|
3552
|
-
if (spot) {
|
|
3553
|
-
const own = (iid) => {
|
|
3554
|
-
const it = spot.layout.items[iid];
|
|
3555
|
-
return it && !it.inMenu && !it.floating && it.edge === lane ? more.extent(iid, it.rect) : null;
|
|
3556
|
-
};
|
|
3557
|
-
let gl = left !== "^" && (() => {
|
|
3558
|
-
const o = own(left);
|
|
3559
|
-
return !o || a - o[1] > 0.5;
|
|
3560
|
-
})();
|
|
3561
|
-
let gr = right !== "$" && (() => {
|
|
3562
|
-
const o = own(right);
|
|
3563
|
-
return !o || o[0] - b > 0.5;
|
|
3564
|
-
})();
|
|
3565
|
-
if (!gl && !gr) {
|
|
3566
|
-
if (right !== "$") gr = true;
|
|
3567
|
-
else if (left !== "^") gl = true;
|
|
3568
|
-
}
|
|
3579
|
+
if (spot && b - a >= besideMin - EPS) {
|
|
3569
3580
|
let ps = [[a, b]];
|
|
3570
3581
|
for (const f of refused) ps = ps.flatMap(([p, q]) => [[p, Math.min(q, f.along[0])], [Math.max(p, f.along[1]), q]]);
|
|
3571
3582
|
if (heldSpan) ps = ps.flatMap(([p, q]) => [[p, Math.min(q, heldSpan[0])], [Math.max(p, heldSpan[1]), q]]);
|
|
3572
3583
|
ps = ps.filter(([p, q]) => q - p >= MIN_BOX - EPS);
|
|
3573
3584
|
ps.forEach(([p, q], k2) => {
|
|
3574
3585
|
out.push({ id: `${lane}/box/${pair}${k2 ? `#${k2}` : ""}`, kind: "box", rect: along(laneRect, axis, p, q) });
|
|
3575
|
-
|
|
3576
|
-
if (gr && Math.abs(q - b) < EPS) out.push({ id: `${lane}/hatch/${pair}:after`, kind: "hatch", rect: along(laneRect, axis, q - Math.min(HATCH_END, (q - p) / 2), q) });
|
|
3586
|
+
hatches(pair, a, b, p, q, gl, gr);
|
|
3577
3587
|
});
|
|
3578
3588
|
if (ps.length > 0) continue;
|
|
3579
3589
|
}
|
|
@@ -3588,6 +3598,7 @@ function edgeMarks(lane, laneRect, axis, items, refused, itemLen, lands, held, m
|
|
|
3588
3598
|
if (q - p < min - EPS) continue;
|
|
3589
3599
|
const base = `${lane}/box/${named}${beside ? `:${beside}` : ""}${k++ ? `#${k - 1}` : ""}`;
|
|
3590
3600
|
out.push({ id: out.some((m) => m.id === base) ? `${base}~2` : base, kind: "box", rect: along(laneRect, axis, p, q) });
|
|
3601
|
+
hatches(pair, a, b, p, q, gl, gr);
|
|
3591
3602
|
}
|
|
3592
3603
|
}
|
|
3593
3604
|
return out;
|
|
@@ -3661,10 +3672,10 @@ function settle(l, drawn, scene, dragged, all, emptyLanes = "real") {
|
|
|
3661
3672
|
return { ...l, marks };
|
|
3662
3673
|
}
|
|
3663
3674
|
var overlaps3 = (a, b) => a.x < b.x + b.width - EPS && b.x < a.x + a.width - EPS && a.y < b.y + b.height - EPS && b.y < a.y + a.height - EPS;
|
|
3664
|
-
function pitchedSpots(scene, dragged, options, seen, raws, pitch) {
|
|
3675
|
+
function pitchedSpots(scene, dragged, options, seen, lifted, raws, pitch) {
|
|
3665
3676
|
const out = [];
|
|
3666
|
-
stretches(scene, dragged, options, seen, raws, (run) => {
|
|
3667
|
-
const { e, axis,
|
|
3677
|
+
stretches(scene, dragged, options, seen, lifted, raws, (run) => {
|
|
3678
|
+
const { e, axis, gap, middle } = run;
|
|
3668
3679
|
const taken = run.mine.map((r) => r.landing);
|
|
3669
3680
|
const emit3 = (zone, at, space, x0, flush) => {
|
|
3670
3681
|
const hit = landsAt(scene, dragged, run, { edge: e.id, zone, at, space }, x0);
|
|
@@ -3683,7 +3694,7 @@ function pitchedSpots(scene, dragged, options, seen, raws, pitch) {
|
|
|
3683
3694
|
out.push({ lane: e.id, edge: e.id, axis, id, ...n, landing: landed.rect, layout, target, hit: landed.rect, pitched: true });
|
|
3684
3695
|
return true;
|
|
3685
3696
|
};
|
|
3686
|
-
return ({ a, b, zones, atOf, spaceAt, before, after }) => {
|
|
3697
|
+
return ({ a, b, w, zones, atOf, spaceAt, before, after }) => {
|
|
3687
3698
|
const end = (x0, order, flush) => {
|
|
3688
3699
|
for (const zone of order) if (spaceAt(zone, x0) >= -EPS && emit3(zone, atOf(zone), Math.max(0, spaceAt(zone, x0)), x0, flush)) return;
|
|
3689
3700
|
};
|
|
@@ -3699,10 +3710,10 @@ function pitchedSpots(scene, dragged, options, seen, raws, pitch) {
|
|
|
3699
3710
|
});
|
|
3700
3711
|
return out;
|
|
3701
3712
|
}
|
|
3702
|
-
function stretches(scene, dragged, options, seen, raws, visit) {
|
|
3713
|
+
function stretches(scene, dragged, options, seen, lifted, raws, visit) {
|
|
3703
3714
|
if (!scene.items[dragged]) return;
|
|
3704
3715
|
const prev = options.previous ? { previous: options.previous } : {};
|
|
3705
|
-
const base =
|
|
3716
|
+
const base = lifted;
|
|
3706
3717
|
for (const e of scene.edges) {
|
|
3707
3718
|
const bar = e.side === "top" || e.side === "bottom";
|
|
3708
3719
|
if (!bar && !e.compact) continue;
|
|
@@ -3712,8 +3723,6 @@ function stretches(scene, dragged, options, seen, raws, visit) {
|
|
|
3712
3723
|
if (mine.length === 0 || !drawn) continue;
|
|
3713
3724
|
const gap = nonNeg(e.gap);
|
|
3714
3725
|
const others = onEdge(base, e.id, dragged, axis);
|
|
3715
|
-
const edgeStart = lo(drawn.rect, axis) + nonNeg(e.pad?.start);
|
|
3716
|
-
const edgeEnd = lo(drawn.rect, axis) + len(drawn.rect, axis) - nonNeg(e.pad?.end);
|
|
3717
3726
|
const zoneOf2 = (o) => o.zone ?? "start";
|
|
3718
3727
|
const w = len(mine[0].landing, axis);
|
|
3719
3728
|
const each = visit({ e, axis, w, gap, middle: mid(drawn.rect, axis), mine, fixed: others.filter((o) => scene.items[o.id]?.fixed), prev });
|
|
@@ -3721,20 +3730,52 @@ function stretches(scene, dragged, options, seen, raws, visit) {
|
|
|
3721
3730
|
const main = o ? scene.items[o.id]?.forms[axis === "x" ? "row" : "column"]?.[0]?.main : void 0;
|
|
3722
3731
|
return o && main?.grows ? Math.max(0, len(o.r, axis) - main.natural) : 0;
|
|
3723
3732
|
};
|
|
3733
|
+
const ends = (l, before, after) => {
|
|
3734
|
+
const at = (o) => {
|
|
3735
|
+
const it = l.items[o.id];
|
|
3736
|
+
return it && it.edge === e.id && !it.inMenu && !it.floating ? it.rect : null;
|
|
3737
|
+
};
|
|
3738
|
+
const rb = before ? at(before) : void 0;
|
|
3739
|
+
const ra = after ? at(after) : void 0;
|
|
3740
|
+
if (rb === null || ra === null) return null;
|
|
3741
|
+
const el = l.edges[e.id]?.rect ?? drawn.rect;
|
|
3742
|
+
return {
|
|
3743
|
+
a: before && rb ? lo(rb, axis) + len(rb, axis) - slack({ ...before, r: rb }) + gap : lo(el, axis) + nonNeg(e.pad?.start),
|
|
3744
|
+
// (Not before a growing item: a dock there keeps no space, the item it precedes takes all that is spare.)
|
|
3745
|
+
b: ra ? lo(ra, axis) - gap : lo(el, axis) + len(el, axis) - nonNeg(e.pad?.end)
|
|
3746
|
+
};
|
|
3747
|
+
};
|
|
3724
3748
|
for (let i = 0; i <= others.length; i++) {
|
|
3725
3749
|
const before = others[i - 1];
|
|
3726
3750
|
const after = others[i];
|
|
3727
|
-
const a = before ? lo(before.r, axis) + len(before.r, axis) - slack(before) + gap : edgeStart;
|
|
3728
|
-
const b = after ? lo(after.r, axis) - gap : edgeEnd;
|
|
3729
3751
|
const zones = [...!before || zoneOf2(before) === "start" ? ["start"] : [], ...!after || zoneOf2(after) === "end" ? ["end"] : []];
|
|
3730
|
-
|
|
3752
|
+
const atOf = (zone) => others.slice(0, i).filter((o) => zoneOf2(o) === zone).length;
|
|
3753
|
+
const probe = (() => {
|
|
3754
|
+
const zone = zones[0];
|
|
3755
|
+
if (!zone) return null;
|
|
3756
|
+
const next = moveTo(scene, dragged, { edge: e.id, zone, at: atOf(zone), space: 0 });
|
|
3757
|
+
if (next === scene) return null;
|
|
3758
|
+
const l = solve(next, prev);
|
|
3759
|
+
const landed = l.items[dragged];
|
|
3760
|
+
if (!landed || landed.inMenu || landed.edge !== e.id) return null;
|
|
3761
|
+
const n = neighbors(l, e.id, dragged, axis);
|
|
3762
|
+
if (n.before !== (before?.id ?? "^") || n.next !== (after?.id ?? "$")) return null;
|
|
3763
|
+
const r = ends(l, before, after);
|
|
3764
|
+
return r && { ...r, w: len(landed.rect, axis), layout: l };
|
|
3765
|
+
})();
|
|
3766
|
+
const seenEnds = ends(base, before, after);
|
|
3767
|
+
const pushed = (o, side) => !!o && !!probe && givesWay(base.items[o.id], probe.layout.items[o.id], e.id, side, (r) => [lo(r, axis), lo(r, axis) + len(r, axis) - slack({ ...o, r })]) === "moves";
|
|
3768
|
+
const a = probe && (zones.includes("start") || !pushed(before, "before")) ? probe.a : seenEnds.a;
|
|
3769
|
+
const b = probe && (zones.includes("end") || !pushed(after, "after")) ? probe.b : seenEnds.b;
|
|
3770
|
+
const wi = probe?.w ?? w;
|
|
3771
|
+
each({ before, after, a, b, w: wi, zones, atOf, spaceAt: (zone, x0) => zone === "start" ? x0 - a : b - (x0 + wi) });
|
|
3731
3772
|
}
|
|
3732
3773
|
}
|
|
3733
3774
|
}
|
|
3734
|
-
function takeoverSpots(scene, dragged, options, seen, raws, pitch) {
|
|
3775
|
+
function takeoverSpots(scene, dragged, options, seen, lifted, raws, pitch) {
|
|
3735
3776
|
const out = [];
|
|
3736
|
-
stretches(scene, dragged, options, seen, raws, (run) => {
|
|
3737
|
-
const { e, axis
|
|
3777
|
+
stretches(scene, dragged, options, seen, lifted, raws, (run) => {
|
|
3778
|
+
const { e, axis } = run;
|
|
3738
3779
|
const taken = [...run.mine.map((r) => r.landing)];
|
|
3739
3780
|
const emit3 = (zone, at, space, x0, nb) => {
|
|
3740
3781
|
const hit = landsAt(scene, dragged, run, { edge: e.id, zone, at, space }, x0);
|
|
@@ -3748,7 +3789,7 @@ function takeoverSpots(scene, dragged, options, seen, raws, pitch) {
|
|
|
3748
3789
|
const target = { id: `pitch:${e.id}:${zone}:${at}:in:${nb}`, priority: 2, hit: landed.rect, slot: landed.rect, item: dragged, place: { kind: "gap", edge: e.id, zone, at }, after: () => result };
|
|
3749
3790
|
out.push({ lane: e.id, edge: e.id, axis, id: `${e.id}/${zone}/${n.before}|${n.next}@in:${nb}`, ...n, landing: landed.rect, layout, target, hit: landed.rect });
|
|
3750
3791
|
};
|
|
3751
|
-
return ({ zones, atOf, spaceAt, before, after }) => {
|
|
3792
|
+
return ({ w, zones, atOf, spaceAt, before, after }) => {
|
|
3752
3793
|
const zoneOf2 = (id) => scene.items[id]?.align ?? "start";
|
|
3753
3794
|
if (after && zones.includes("start") && zoneOf2(after.id) === "start" && !scene.items[after.id]?.fixed) {
|
|
3754
3795
|
const x0 = lo(after.r, axis);
|
|
@@ -3775,15 +3816,15 @@ function landsAt(scene, dragged, run, place, x0) {
|
|
|
3775
3816
|
})) return null;
|
|
3776
3817
|
return { next, layout };
|
|
3777
3818
|
}
|
|
3778
|
-
function slidingSpots(scene, dragged, options, seen, raws, sample) {
|
|
3819
|
+
function slidingSpots(scene, dragged, options, seen, lifted, raws, sample) {
|
|
3779
3820
|
const spots = [];
|
|
3780
3821
|
const absorbed = /* @__PURE__ */ new Set();
|
|
3781
3822
|
const snapDistance = Number.isFinite(options.snapDistance) && options.snapDistance >= 0 ? options.snapDistance : SNAP_DISTANCE;
|
|
3782
3823
|
const own = seen.items[dragged];
|
|
3783
3824
|
const ownEdge = own && !own.floating && !own.inMenu ? own.edge : void 0;
|
|
3784
|
-
stretches(scene, dragged, options, seen, raws, (run) => ({ a, b, zones, atOf, spaceAt, before, after }) => {
|
|
3785
|
-
const { e, axis,
|
|
3786
|
-
if (zones.length === 0
|
|
3825
|
+
stretches(scene, dragged, options, seen, lifted, raws, (run) => ({ a, b, w, zones, atOf, spaceAt, before, after }) => {
|
|
3826
|
+
const { e, axis, middle, mine } = run;
|
|
3827
|
+
if (zones.length === 0) return;
|
|
3787
3828
|
{
|
|
3788
3829
|
const land = (x0) => {
|
|
3789
3830
|
const near = x0 + w / 2 < middle ? "start" : "end";
|
|
@@ -3806,6 +3847,29 @@ function slidingSpots(scene, dragged, options, seen, raws, sample) {
|
|
|
3806
3847
|
const to = ok.at(-1).x0;
|
|
3807
3848
|
const bId = before?.id ?? "^";
|
|
3808
3849
|
const nId = after?.id ?? "$";
|
|
3850
|
+
if (to - from < STEP) {
|
|
3851
|
+
if (mine.some((r) => !r.slide && Math.abs(lo(r.landing, axis) - from) <= 1)) return;
|
|
3852
|
+
const firstZone = (() => {
|
|
3853
|
+
for (const zone3 of zones) {
|
|
3854
|
+
const space = spaceAt(zone3, from);
|
|
3855
|
+
if (space < -EPS) continue;
|
|
3856
|
+
const place2 = { edge: e.id, zone: zone3, at: atOf(zone3), space: Math.max(0, space) };
|
|
3857
|
+
const hit = landsAt(scene, dragged, run, place2, from);
|
|
3858
|
+
if (hit) return { place: place2, result: { scene: hit.next, layout: hit.layout } };
|
|
3859
|
+
}
|
|
3860
|
+
return null;
|
|
3861
|
+
})();
|
|
3862
|
+
const { place, result } = firstZone ?? ok[0].hit;
|
|
3863
|
+
const landed = result.layout.items[dragged].rect;
|
|
3864
|
+
const n = neighbors(result.layout, e.id, dragged, axis);
|
|
3865
|
+
const zone2 = place.zone;
|
|
3866
|
+
const isHome = ownEdge === e.id && !!own && Math.abs(lo(own.rect, axis) - lo(landed, axis)) <= 1 && Math.abs(len(own.rect, axis) - len(landed, axis)) <= 1;
|
|
3867
|
+
const target2 = { id: `pitch:${e.id}:${zone2}:${place.at}:${Math.round(place.space ?? 0)}`, priority: 2, hit: landed, slot: landed, item: dragged, place: { kind: "gap", edge: e.id, zone: zone2, at: place.at }, after: () => result };
|
|
3868
|
+
const plain = `${e.id}/${zone2}/${n.before}|${n.next}`;
|
|
3869
|
+
const id = mine.some((r) => r.id === plain) ? `${plain}@${Math.round((place.space ?? 0) / sample)}` : plain;
|
|
3870
|
+
spots.push({ lane: e.id, edge: e.id, axis, id, ...n, landing: landed, layout: result.layout, target: target2, hit: landed, ...isHome ? { home: true } : {} });
|
|
3871
|
+
return;
|
|
3872
|
+
}
|
|
3809
3873
|
const inside = mine.filter((r) => !r.slide && r.before === bId && r.next === nId && Math.abs(len(r.landing, axis) - w) <= 1 && lo(r.landing, axis) >= from - 1 && lo(r.landing, axis) <= to + 1);
|
|
3810
3874
|
for (const r of inside) absorbed.add(r);
|
|
3811
3875
|
const homeRaw = inside.find((r) => r.home);
|
|
@@ -3949,4 +4013,4 @@ export {
|
|
|
3949
4013
|
HATCH_END,
|
|
3950
4014
|
HATCH_EDGE
|
|
3951
4015
|
};
|
|
3952
|
-
//# sourceMappingURL=chunk-
|
|
4016
|
+
//# sourceMappingURL=chunk-UPZXNTIR.js.map
|