@graview/pages 0.2.7 → 0.2.9

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.
@@ -1 +1 @@
1
- {"version":3,"file":"one-place-city.d.ts","sourceRoot":"","sources":["../src/one-place-city.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAmd,KAAK,SAAS,EAAc,MAAM,yBAAyB,CAAC;AACthB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAsGxD,iGAAiG;AACjG,eAAO,MAAM,OAAO,MAAM,CAAC;AA6C3B,wBAAgB,YAAY,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,iBAAiB,+BAmiEtN;AAED,YAAY,EAAE,SAAS,EAAE,CAAC;AAE1B,2IAA2I;AAC3I,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,CAI1D"}
1
+ {"version":3,"file":"one-place-city.d.ts","sourceRoot":"","sources":["../src/one-place-city.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAmd,KAAK,SAAS,EAAc,MAAM,yBAAyB,CAAC;AACthB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAsGxD,iGAAiG;AACjG,eAAO,MAAM,OAAO,MAAM,CAAC;AA6C3B,wBAAgB,YAAY,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,iBAAiB,+BA0oEtN;AAED,YAAY,EAAE,SAAS,EAAE,CAAC;AAE1B,2IAA2I;AAC3I,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,CAI1D"}
@@ -373,6 +373,19 @@ export function OnePlaceCity({ where, out, sheet, connected, boards, current, bo
373
373
  };
374
374
  /** The camera between stops this frame, as painted — the last one seen while the view takes in a move just let go. */
375
375
  let painted = LEVEL_LIVE;
376
+ /*
377
+ * THE ZOOM THE PICTURE IS LAID OUT AT, which `painted` is over. Letting
378
+ * go writes the hand's zoom into the Scene's at once, while the city is
379
+ * still laid out at the old one under the transform held until React
380
+ * commits: a frame drawn in between counted the hand's zoom twice, and
381
+ * at Nearby a board as wide as the zoom allows drew a fifth wider for
382
+ * that one frame (one-face's
383
+ * `letGoOfAZoomEveryBoardAndNameGoesOnFromWhereTheLastFrameDrewIt`,
384
+ * "ctrl and the wheel over a district, further", under GRAVIEW_SLOW=4
385
+ * on GitHub's runner). While the view takes the move in, the zoom the
386
+ * last frame drew at is the one.
387
+ */
388
+ let laidZoom = null;
376
389
  /** The level the camera rests at, and the altitude this frame. */
377
390
  let rest = PAGE;
378
391
  let altitude = PAGE;
@@ -411,6 +424,8 @@ export function OnePlaceCity({ where, out, sheet, connected, boards, current, bo
411
424
  let resized = false;
412
425
  let handSince = 0;
413
426
  let lastPlace = "";
427
+ /** The place a scrub under way left from. */
428
+ let scrubbedFrom = null;
414
429
  let lastReported = "";
415
430
  /* When the camera was last written into the view: the Scene settles what is painted a beat after (its wheel's rule), so nothing new is painted until that beat has passed. */
416
431
  let committedAt = -Infinity;
@@ -514,6 +529,15 @@ export function OnePlaceCity({ where, out, sheet, connected, boards, current, bo
514
529
  });
515
530
  return { plots, buildings };
516
531
  };
532
+ /** What says the city was laid out again: its plots' own offset, which the view's pan and zoom write. */
533
+ const laidOut = (holder) => holder.querySelector(".graview-plots > g")?.getAttribute("transform") ?? "";
534
+ /** The offset the city was last read at. */
535
+ let laidAt = "";
536
+ /** The picture read with a hand's camera painted over it, back in the picture's own pixels. */
537
+ const beneath = (w, cam) => {
538
+ const back = (b) => ({ x: (b.x - cam.x) / cam.s, y: (b.y - cam.y) / cam.s, width: b.width / cam.s, height: b.height / cam.s });
539
+ return { plots: new Map([...w.plots].map(([key, b]) => [key, back(b)])), buildings: new Map([...w.buildings].map(([key, b]) => [key, back(b)])) };
540
+ };
517
541
  /** What a page stands on in the picture as it is laid out. */
518
542
  const placeIn = (at, w) => ({
519
543
  building: at.type === "record" ? (w.buildings.get(at.id) ?? null) : null,
@@ -994,6 +1018,20 @@ export function OnePlaceCity({ where, out, sheet, connected, boards, current, bo
994
1018
  move.start += lost;
995
1019
  if (settle)
996
1020
  settle.start += lost;
1021
+ /*
1022
+ * And the moment the hand has been off the city: a stall is no time
1023
+ * the hand was seen off it. A finger put down in a stall reaches the
1024
+ * page only after the frame that ends it, so counted, a pinch let go
1025
+ * of and a pan begun straight after (on a slow phone, as the zoom is
1026
+ * laid out) had been "off a moment" before the pan's finger was
1027
+ * heard: the zoom was placed for under it, and every board slid off
1028
+ * its district as the ground began to move (one-face's
1029
+ * `duringAPinchThatPansEveryBoardAndNameStaysFastenedToItsDistrictEveryFrame`,
1030
+ * "a pinch let go of, and a pan straight after", under GRAVIEW_SLOW=4).
1031
+ * One frame counts as half the moment at most, so no single stall
1032
+ * lets go, and a machine whose every frame is slow lets go as soon.
1033
+ */
1034
+ handAt += Math.max(0, now - lastTick - LET_GO_MS / 2);
997
1035
  }
998
1036
  calmRun = lastTick > 0 && now - lastTick < 50 ? calmRun + 1 : 0;
999
1037
  lastTick = now;
@@ -1058,6 +1096,36 @@ export function OnePlaceCity({ where, out, sheet, connected, boards, current, bo
1058
1096
  settle = null;
1059
1097
  heldHalfWay = true;
1060
1098
  }
1099
+ /*
1100
+ * THE CITY LAID OUT AGAIN UNDER THE HAND. On a slow machine the view
1101
+ * takes a let-go zoom or pan after the next gesture has begun — a
1102
+ * second turn of a pinch, a pan straight after one — and the city is
1103
+ * laid out anew beneath the hand's offset. Drawn on through the city
1104
+ * as last read, a line's end stood off its building and every board
1105
+ * off its district until the hand let go (one-face's
1106
+ * `atNearbyAPinchOverTheCityZoomsItAndThePanelAndTheLevelStay` and
1107
+ * `duringAPinchThatPansEveryBoardAndNameStaysFastenedToItsDistrictEveryFrame`,
1108
+ * under GRAVIEW_SLOW=4). Read again through the camera painted now,
1109
+ * and what was drawn carried by what the districts say moved; a zoom
1110
+ * among it is placed for once the hand is off, as any hand's zoom is.
1111
+ */
1112
+ const laid = laidOut(holder);
1113
+ if (!move && !asking.scrubbing && world.plots.size > 0 && laid !== laidAt) {
1114
+ const before = world;
1115
+ world = beneath(readWorld(holder), live);
1116
+ laidAt = laid;
1117
+ const carry = carriedBetween(before.plots, world.plots);
1118
+ if (carry) {
1119
+ slots = carriedThrough(carry, drawnSlots(now));
1120
+ names = carriedThrough(carry, drawnNames(now));
1121
+ scales = drawnScales(now);
1122
+ posts = new Map([...posts].map(([one, length]) => [one, length * carry.s]));
1123
+ whole = whole ? { ...project(carry, whole), width: whole.width * carry.s, height: whole.height * carry.s } : null;
1124
+ settle = null;
1125
+ if (Math.abs(carry.s - 1) >= 1e-3)
1126
+ regrow = true;
1127
+ }
1128
+ }
1061
1129
  painted = live;
1062
1130
  drawnThrough = live;
1063
1131
  }
@@ -1082,6 +1150,7 @@ export function OnePlaceCity({ where, out, sheet, connected, boards, current, bo
1082
1150
  if (world.plots.size === 0 || (!move && (readKey !== lastReadKey || committedAt > lastRead || now - lastRead > 500))) {
1083
1151
  const before = world;
1084
1152
  world = readWorld(holder);
1153
+ laidAt = laidOut(holder);
1085
1154
  if (move)
1086
1155
  placeFor(move.toAltitude, move.to, cam.zoom());
1087
1156
  else {
@@ -1170,9 +1239,17 @@ export function OnePlaceCity({ where, out, sheet, connected, boards, current, bo
1170
1239
  * THE HAND OFF THE CITY A MOMENT, a zoom it wrote is placed for: each
1171
1240
  * board and name goes from where it is drawn to where it stands at the
1172
1241
  * new zoom, as a zoom let go of always did — once nothing is moving
1173
- * the ground under them.
1242
+ * the ground under them. A finger down is a hand on the city, moving
1243
+ * it or not yet: a pan put down straight after a pinch is let go of
1244
+ * moves no ground until the browser has seen it move past a touch's
1245
+ * slop, and on a slow phone that was past the moment, so the zoom was
1246
+ * placed for under the finger and the boards slid off their districts
1247
+ * as the pan began (one-face's
1248
+ * `duringAPinchThatPansEveryBoardAndNameStaysFastenedToItsDistrictEveryFrame`,
1249
+ * "a pinch let go of, and a pan straight after", under GRAVIEW_SLOW=4
1250
+ * on GitHub's runner).
1174
1251
  */
1175
- if (between || settling || cam.pinching())
1252
+ if (between || settling || cam.pinching() || asking.held)
1176
1253
  handAt = now;
1177
1254
  if (regrow && world.plots.size > 0 && rest !== PAGE && !move && !asking.scrubbing && level(painted) && now - handAt >= LET_GO_MS) {
1178
1255
  regrow = false;
@@ -1184,7 +1261,9 @@ export function OnePlaceCity({ where, out, sheet, connected, boards, current, bo
1184
1261
  standAll(world, cam.zoom(), LEVEL_LIVE, shownAt(rest), rest);
1185
1262
  }
1186
1263
  const anchor = world.plots.size > 0 ? anchorIn(at.where, world) : null;
1187
- const zoomNow = cam.zoom();
1264
+ const zoomNow = settling && laidZoom !== null ? laidZoom : cam.zoom();
1265
+ if (!settling)
1266
+ laidZoom = zoomNow;
1188
1267
  const placeKey = `${keyOf(at.where)}|${at.view.width}x${at.view.height}`;
1189
1268
  /* At the page, the camera waits where stepping out begins: aimed for each place before anything moves. */
1190
1269
  let ready = rest !== PAGE || move !== null || asking.scrubbing;
@@ -1210,6 +1289,9 @@ export function OnePlaceCity({ where, out, sheet, connected, boards, current, bo
1210
1289
  moveTo(cam, toLevel, anchor, now);
1211
1290
  lastPlace = placeKey;
1212
1291
  }
1292
+ // A scrub ended another way (a press without a drag, a pointer canceled) leaves no place it left from behind.
1293
+ if (!asking.scrubbing)
1294
+ scrubbedFrom = null;
1213
1295
  if (ready && calm && anchor && asking.scrub !== 0 && !settling) {
1214
1296
  // As far as the hand has gone, but no more than a step a frame: a hand ahead of the camera is caught up with, never jumped to.
1215
1297
  const delta = Math.max(-0.12, Math.min(0.12, asking.scrub));
@@ -1227,10 +1309,24 @@ export function OnePlaceCity({ where, out, sheet, connected, boards, current, bo
1227
1309
  altitude = target;
1228
1310
  handSince = now;
1229
1311
  asking.scrubbing = true;
1312
+ scrubbedFrom ??= placeKey;
1230
1313
  }
1231
1314
  if (asking.scrubbing && !asking.held && now - handSince > LET_GO_MS && !settling && calm) {
1232
1315
  asking.scrubbing = false;
1233
1316
  restCam = null;
1317
+ /*
1318
+ * SCRUBBED TO A LEVEL, THE PAGE IS AT HOME THERE. The place a scrub
1319
+ * leaves from, still the place when it settles, is the place it
1320
+ * settles at: said so, or the city read it as another place gone to
1321
+ * at the City and took it down to Nearby (`moveTo(…PANEL…)` below) —
1322
+ * the slider dragged from the Page up to the Map came back down to
1323
+ * Nearby 0.8 s after it rested, on any machine (one-face's
1324
+ * `draggingTheSliderScrubsTheLevels`, read once the face rests). A
1325
+ * place chosen while the scrub went on is still gone to as one.
1326
+ */
1327
+ if (scrubbedFrom === placeKey)
1328
+ lastPlace = placeKey;
1329
+ scrubbedFrom = null;
1234
1330
  if (anchor)
1235
1331
  moveTo(cam, restingLevel(altitude), anchor, now, false);
1236
1332
  }
@@ -1480,8 +1576,20 @@ export function OnePlaceCity({ where, out, sheet, connected, boards, current, bo
1480
1576
  // Put away under the bar or the control by a pan (a phone's City is panned to reach it): said, for whoever reads the page.
1481
1577
  button.toggleAttribute("data-graview-under", covered);
1482
1578
  const seen = slot && !covered ? (key === at.current ? shownOwn : shownBoards) * arriving * leaving : 0;
1579
+ /*
1580
+ * This page's own board, drawn wherever it stands (it is the page on
1581
+ * its way into a board), is not offered to a press where the bar or
1582
+ * the control stands over it: a press there lands on them (the
1583
+ * Harbor's home at the City, 844 wide, its board under the bar —
1584
+ * the watch's control-covered, seen once one-face waited for the
1585
+ * face to rest).
1586
+ */
1587
+ const ownUnder = key === at.current && footAt !== null && under({ x: footAt.x - w / 2, y: footAt.y - h, width: w, height: h });
1483
1588
  // Not seen, it is not reached: out of the keyboard's order and the pointer's, as a board going away is.
1484
- const reached = seen > 0.5 && (key === at.current ? a > 1.5 : a > 0.95) && !move;
1589
+ const reached = seen > 0.5 && (key === at.current ? a > 1.5 && !ownUnder : a > 0.95) && !move;
1590
+ // The keyboard on its own board as the bar comes over it goes to the level control, not to the page's body.
1591
+ if (ownUnder && !reached && document.activeElement === button)
1592
+ fab.current?.querySelector("[data-graview-one-face-dock] button, [data-graview-one-face-dock] [role='slider']")?.focus({ preventScroll: true });
1485
1593
  if (button.inert === reached)
1486
1594
  button.inert = !reached;
1487
1595
  if (!slot || seen <= 0.001) {