@n-uf/placement 26.12.10 → 26.12.11

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 CHANGED
@@ -5,6 +5,30 @@ Versions are calendar versions, `YY.M.R` (year, month of the release, counter wi
5
5
 
6
6
  Unreleased entries live in `changes/` until a release joins them.
7
7
 
8
+ ## 26.12.11
9
+
10
+ - **Added:** `TilingHitOptions.start`. A hit made at a pickup starts at home: make it with `start: "home"`. A hit made
11
+ in mid-drag starts from nothing held. With `"home"` the drag's one hold holds home before its first step, so the
12
+ first read is the read from home at that point (on the base basis a strip is read from the lift, the frame drawn at
13
+ home). With no home (`hit.home` is null) it starts from nothing held, as when the option is left out. The option
14
+ counts on the drag's first `hit(basis)` call, as every hit option does. The start applies once, to the first step;
15
+ the pure `hold(state, point)` does not read it.
16
+ - **Added:** `TilingHit.cap`, the cap the hit resolved (`TilingHitOptions.cap`, default 0.25, never below 0), read-only,
17
+ beside the edge measure it resolved (`intent.tuning.band`).
18
+ - **Changed (breaking in behavior, not in types):** strips are read from the frame on screen; places from the basis's
19
+ map. Before: "Off that frame's rails the hold is the basis's map (its own rails take no place)", so on the base basis a
20
+ rail of the base let any hold go, also where the frame on screen (the lift at home, `after(held)` for a place) paints
21
+ no strip there: a press on home over a strip of the base that the lift does not paint let home go. Now: "Off that
22
+ frame's rails the hold is the basis's map (the rails that take no place are those of the frame drawn for the hold)".
23
+ A rail of the base the frame does not paint plays no part: a hold inside its own keep stays, and the place is the
24
+ map's, so such a press stays home. A painted strip keeps the hold and is named, as before; with nothing held the frame
25
+ is the base, so its strips still take no drop, and `placeAt(point)` still gives null on them. The lift basis is
26
+ unchanged. Only a host with folds (`TilingDragOptions.fold`) can see this.
27
+ - **Changed:** the zone map under `placeAt`, `hold` and `read` reads no rail; only the frame drawn for the hold does.
28
+ So `read(frame, point).refused` follows the same rule: at a point on a rail of the base that the frame drawn for the
29
+ hold does not paint, a read that holds nothing names the refused place under the pointer in `refused`, as anywhere
30
+ off a painted strip (before, it was null on every rail of the base).
31
+
8
32
  ## 26.12.10
9
33
 
10
34
  - **Changed (breaking in behavior, not in types):** under a fold, on the base basis, a pane you see folded takes no
package/dist/tiling.d.ts CHANGED
@@ -724,14 +724,19 @@ interface TilingAfter<T, K> extends TilingLaidOut<T, K> {
724
724
  * place. Over a rail of that frame, at the host's offset, the read names the pane painted there and the frame stays:
725
725
  * on the lift basis nothing is held (the lift is drawn whatever is held), on the base basis the hold stays as it was
726
726
  * (home stays home, a held place stays held and a release commits it as previewed, nothing stays nothing). Off the
727
- * frame's rails the hold follows the basis's zone map. So on the base basis the open panes are tested against the
728
- * base while another frame may be painted; only a painted strip is read from the frame on screen.
727
+ * frame's rails the hold follows the basis's zone map, and a rail of the basis that frame does not paint plays no
728
+ * part: a hold inside its own keep stays, and the place is the map's. With nothing held the frame is the basis's
729
+ * layout, so its strips take no drop. Strips are read from the frame on screen; places from the basis's map.
729
730
  * - **A pane you see folded takes no drop** (under a fold, on the base basis). The hold does not change to a place
730
731
  * whose pane is a strip both at the lift and in the frame drawn for the hold, unless the hold is already a place of
731
732
  * that pane; where such a place is refused the hold stays as it is, and so does its frame. Off the strip the read
732
733
  * names no strip (`folded` is null). It is one check on the place's pane, no geometry: a pane open at the lift, a
733
734
  * pane the frame draws open (with nothing held the base is drawn), the lift basis and a layout without a fold are
734
735
  * held as before. So the place beside such a pane is reached only from a frame that draws it open.
736
+ * - **Where the hold starts**: a hit made at a pickup starts at home: make it with `start: "home"`. A hit made in
737
+ * mid-drag starts from nothing held. The start applies once, to the first step of the drag's one hold; with no home it
738
+ * is nothing held, so a host never branches on `home`. The resolved cap is `hit.cap`, beside the edge measure
739
+ * (`hit.intent.tuning.band`).
735
740
  *
736
741
  * See docs/placement.md, Entry: tiling, "A tiling drag's hit half".
737
742
  */
@@ -768,6 +773,14 @@ interface TilingHitOptions<K> {
768
773
  readonly cap?: number;
769
774
  /** A run neighbor's swap across the run, a share of its extent there (default 0.56): each side strip is half the rest. */
770
775
  readonly neighborSwap?: number;
776
+ /**
777
+ * Where the drag's one hold starts. A hit made at a pickup starts at home: make it with `start: "home"`. A hit made
778
+ * in mid-drag starts from nothing held. Left out, the hold starts from nothing held; with `"home"` its first step is
779
+ * the hold rule from home taken at that point (`hold({ place: "home", from: point }, point)`), and with no home
780
+ * (`TilingHit.home` is null) it starts from nothing held as well. The start applies once, to the first step; a later
781
+ * read never applies it again. The pure `hold(state, point)` does not read it.
782
+ */
783
+ readonly start?: "home";
771
784
  }
772
785
  /**
773
786
  * The hit's defaults: 6 px past the edge, 24 px of travel inside one pane, each at most a quarter of the zone (`cap`);
@@ -863,8 +876,16 @@ interface TilingHit<T, K> {
863
876
  readonly home: Rect | null;
864
877
  /** Every target, fixed for the drag. */
865
878
  readonly targets: readonly TilingHitTarget<K>[];
866
- /** The options for a drag intent (`createDragIntent({ ...hit.intent })`). */
879
+ /**
880
+ * The options for a drag intent (`createDragIntent({ ...hit.intent })`). Its `tuning.band` is the edge measure the
881
+ * hit resolved, px.
882
+ */
867
883
  readonly intent: TilingHitIntent<K>;
884
+ /**
885
+ * The cap the hit resolved: the most either measure is of the held zone's extent, per axis (`TilingHitOptions.cap`,
886
+ * default 0.25, never below 0). Read-only; the edge measure beside it is `intent.tuning.band`.
887
+ */
888
+ readonly cap: number;
868
889
  /** The zone map: the place id at `point` with nothing held (`"home"` for home), or null. Pure. */
869
890
  placeAt(point: Point): string | null;
870
891
  /**
@@ -1002,7 +1023,8 @@ interface TilingDrag<T, K> {
1002
1023
  * per place: every call on one basis gives the same hit, with its one hold, and the first call's options stand. A
1003
1024
  * fresh hold is the pure `hit.hold(state, point)`. Under a fold, on the base basis, a pane you see folded takes no
1004
1025
  * drop: the hold does not change to a place of a pane drawn as a strip at the lift and in the frame drawn for the
1005
- * hold, unless it already holds a place of that pane.
1026
+ * hold, unless it already holds a place of that pane. A hit made at a pickup starts at home: make it with
1027
+ * `start: "home"`. A hit made in mid-drag starts from nothing held.
1006
1028
  */
1007
1029
  hit(basis: TilingBasis, options?: TilingHitOptions<K>): TilingHit<T, K>;
1008
1030
  }
package/dist/tiling.js CHANGED
@@ -1352,7 +1352,6 @@ function createTilingHit(ctx, basis, options = {}) {
1352
1352
  }
1353
1353
  Object.freeze(targets);
1354
1354
  const rawAt = (p) => {
1355
- if (onRail(p)) return { place: null, refused: null };
1356
1355
  if (home && inside(home, p)) return { place: homePlace, refused: null };
1357
1356
  const pane = panes.find((ph) => inside(ph.body.hit, p));
1358
1357
  if (!pane) return { place: null, refused: null };
@@ -1371,7 +1370,7 @@ function createTilingHit(ctx, basis, options = {}) {
1371
1370
  return live(place) ? { place, refused: null } : { place: null, refused: refused ?? place };
1372
1371
  };
1373
1372
  const effective = (p) => p && homeLike(p) ? homePlace : p;
1374
- const placeAt = (p) => effective(rawAt(p).place)?.id ?? null;
1373
+ const placeAt = (p) => onRail(p) ? null : effective(rawAt(p).place)?.id ?? null;
1375
1374
  let homeLikeAll = null;
1376
1375
  const homePieces = () => {
1377
1376
  homeLikeAll ??= [...byId.values()].filter((p) => p !== homePlace && homeLike(p));
@@ -1415,7 +1414,6 @@ function createTilingHit(ctx, basis, options = {}) {
1415
1414
  };
1416
1415
  const hold = (state2, p) => {
1417
1416
  if (onRailOf(frameOf(state2), p)) return basis === "lift" ? null : state2;
1418
- if (onRail(p)) return null;
1419
1417
  const now = effective(rawAt(p).place);
1420
1418
  if (state2) {
1421
1419
  if (now && now.id === state2.place) return state2;
@@ -1426,10 +1424,15 @@ function createTilingHit(ctx, basis, options = {}) {
1426
1424
  return now ? { place: now.id, from: { x: p.x, y: p.y } } : null;
1427
1425
  };
1428
1426
  let state = null;
1427
+ let startAtHome = options.start === "home" && home !== null;
1429
1428
  let stepFrom = null;
1430
1429
  let last = null;
1431
1430
  const current = (p) => {
1432
1431
  if (!last || last.x !== p.x || last.y !== p.y) {
1432
+ if (startAtHome) {
1433
+ startAtHome = false;
1434
+ state = { place: "home", from: { x: p.x, y: p.y } };
1435
+ }
1433
1436
  stepFrom = state;
1434
1437
  state = hold(state, p);
1435
1438
  last = { x: p.x, y: p.y };
@@ -1461,6 +1464,7 @@ function createTilingHit(ctx, basis, options = {}) {
1461
1464
  return {
1462
1465
  basis,
1463
1466
  home: home ? { ...home } : null,
1467
+ cap,
1464
1468
  targets,
1465
1469
  intent: {
1466
1470
  tuning: { aimSpeed: Infinity, dwell: 0, switchHold: 0, roomAfter: 0, band: edge, bandShare: 1, breakthrough: 0, gapGrace: 0 },
@@ -1996,7 +2000,7 @@ var TILING_HIT_PROPERTIES = [
1996
2000
  * every point of that frame's rail boxes (edges included) reads `folded` with that rail and the pane painted there
1997
2001
  * (`paintedSpines` at the drag's rail offsets), null in a gap; the frame stays (the lift basis holds nothing, the base
1998
2002
  * basis keeps the hold), a second step changes nothing, a release gives what the frame shows, nothing is refused, and
1999
- * with nothing held there is no place.
2003
+ * with nothing held there is no place (the rails that take no place are those of the frame drawn for the hold).
2000
2004
  */
2001
2005
  "spine-no-place",
2002
2006
  /**