mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 09:42:21 +00:00
Move only the anchor's height when the floor height arrives
- The first height that replaces the entry frame's now moves only the anchor's height. The anchor keeps its place and its eased lift, so the camera no longer jumps to a corrected fix or steps back. - A detail line is measured with the title's glyph widths. They are a little wide for its smaller type, so a long detail line is no longer clipped. - The first aircraft update is checked in the existing test, and the copy is removed; test fixtures are simpler. - Comments, the release note and CURRENT-STATE match the code.
This commit is contained in:
1 parent
c190e662bc
commit
83081730c0
9 files changed
+176
-138
No files matched your search
+7
-21
@@ -34,36 +34,22 @@ const stronger = (a, b) =>
|
||||
const WIDE_GLYPHS =
|
||||
/[\u1100-\u115F\u2E80-\u303E\u3041-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uA960-\uA97F\uAC00-\uD7A3\uF900-\uFAFF\uFE30-\uFE4F\uFF00-\uFF60\uFFE0-\uFFE6]/g;
|
||||
|
||||
/** What a full-width glyph and any other UTF-16 unit take in a title (px). */
|
||||
const TITLE_PX = Object.freeze({ wide: 10.6, narrow: 6.4 });
|
||||
/** The same in a detail line (px). */
|
||||
const DETAIL_PX = Object.freeze({
|
||||
wide: 10 / 1.2 + 0.6,
|
||||
narrow: 5.8 / 1.2 + 0.6,
|
||||
});
|
||||
|
||||
/**
|
||||
* One line's width (px) in `.cockpit-progress-label` type (cockpitSubject.css:
|
||||
* 10 px, 0.06 em spacing) at the glyph widths `px`: about 1 em a full-width
|
||||
* glyph and 0.58 em each UTF-16 unit of any other, so an astral glyph (an
|
||||
* emoji, a CJK extension) counts as two and an emoji in the BMP (☕) as one,
|
||||
* narrower than it is drawn. The detail line's `<small>` is 1/1.2 the size;
|
||||
* the 0.6 px spacing it inherits is not scaled.
|
||||
* 10 px, 0.06 em spacing): 10.6 px a full-width glyph and 6.4 px each UTF-16
|
||||
* unit of any other, so an astral glyph (an emoji, a CJK extension) counts as
|
||||
* two and an emoji in the BMP (☕) as one, narrower than it is drawn. The
|
||||
* detail line's `<small>` draws smaller, so these widths only overestimate it.
|
||||
*/
|
||||
function lineWidthPx(line, px) {
|
||||
function lineWidthPx(line) {
|
||||
const text = String(line ?? '');
|
||||
const wide = text.match(WIDE_GLYPHS)?.length ?? 0;
|
||||
return wide * px.wide + (text.length - wide) * px.narrow;
|
||||
return wide * 10.6 + (text.length - wide) * 6.4;
|
||||
}
|
||||
|
||||
/** A label's width estimate (px): its wider line and 8 px of padding. */
|
||||
export function estimateProgressLabelPx(label) {
|
||||
return (
|
||||
Math.max(
|
||||
lineWidthPx(label?.text, TITLE_PX),
|
||||
lineWidthPx(label?.detail, DETAIL_PX),
|
||||
) + 8
|
||||
);
|
||||
return Math.max(lineWidthPx(label?.text), lineWidthPx(label?.detail)) + 8;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user