@swiftbrowser/web 0.5.1 → 0.5.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swiftbrowser/web",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "type": "module",
5
5
  "description": "SwiftBrowser web renderer and dev server: applies render ops from a Swift/Wasm app to the DOM inside an iPhone frame.",
6
6
  "repository": {
@@ -3262,10 +3262,19 @@ export class LayoutPass {
3262
3262
  );
3263
3263
  const trailingUsed = trailingWidth > 0 || chrome['more'] !== undefined || inlineSecondary.length > 0;
3264
3264
  const rightUsed = trailingUsed ? x + size.width - (trailingEdge + NAV_GROUP_SPACING) : 0;
3265
- const side = Math.max(leftUsed, rightUsed) + 8;
3266
- const available = Math.max(0, size.width - 2 * side);
3267
- const titleWidth = Math.min(Math.ceil(this.measurer.measureWidth(title, titleFont) - 0.001), Math.floor(size.width * 0.56), Math.floor(available));
3268
- chrome['title'] = { x: x + (size.width - titleWidth) / 2, y: rowY, width: titleWidth, height: NAV_BAR_HEIGHT };
3265
+ // As UIKit places it: centered in the bar when it fits there; else slid
3266
+ // off-center into the room the items leave (between them, 8 clear of
3267
+ // each side), and truncated only when it does not fit even there.
3268
+ const roomStart = x + leftUsed + 8;
3269
+ const roomEnd = x + size.width - rightUsed - 8;
3270
+ const titleWidth = Math.min(
3271
+ Math.ceil(this.measurer.measureWidth(title, titleFont) - 0.001),
3272
+ Math.floor(size.width * 0.56),
3273
+ Math.floor(Math.max(0, roomEnd - roomStart)),
3274
+ );
3275
+ const centered = x + (size.width - titleWidth) / 2;
3276
+ const titleX = Math.max(roomStart, Math.min(centered, roomEnd - titleWidth));
3277
+ chrome['title'] = { x: titleX, y: rowY, width: titleWidth, height: NAV_BAR_HEIGHT };
3269
3278
  }
3270
3279
  this.setChrome(node, chrome);
3271
3280