@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 +1 -1
- package/src/layout/engine.ts +13 -4
package/package.json
CHANGED
package/src/layout/engine.ts
CHANGED
|
@@ -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
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
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
|
|