@songsid/agend 2.4.0-beta.5 → 2.4.0-beta.6
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
|
-
{"format":1,"commit":"
|
|
1
|
+
{"format":1,"commit":"24b48383072112728398934f80c7e58d251cbc8b","ref":"v2.4.0-beta.6","channel":"release","modified":false,"from":"git"}
|
|
@@ -1253,7 +1253,13 @@ export function Shell({ panels, onNewInstance, viewOnly = false }) {
|
|
|
1253
1253
|
// The keyboard rises and falls over a few hundred ms, and the view's resize comes when it has settled (iOS): for that
|
|
1254
1254
|
// long after a field gains or loses focus the shell follows the view every frame — both ways — instead of jumping.
|
|
1255
1255
|
const FOLLOW_MS = 800;
|
|
1256
|
-
|
|
1256
|
+
// M-3206 (the user, iPhone, beta.5): with "down" on hold, typing still flickered. While typing, iOS reports the view a
|
|
1257
|
+
// little differently from key to key (the suggestion bar, a few px of pan) and the shell followed each reading — its
|
|
1258
|
+
// height and its place — so the box (and what is above it) moved on every key and back. Once the keyboard has settled
|
|
1259
|
+
// (past the follow window, the field still focused, the same width), the shell's height and place change only when a
|
|
1260
|
+
// new reading has held for DOWN_HOLD_MS; one that comes and goes with a keystroke moves nothing. The keyboard coming up
|
|
1261
|
+
// (the view a keyboard shorter) and a turn (a new width) are followed at once.
|
|
1262
|
+
let raf = 0, followUntil = 0, fitH = 0, fitTop = 0, fitW = -1, moveSince = 0, moveTimer = 0;
|
|
1257
1263
|
const now = () => (typeof performance !== "undefined" ? performance.now() : Date.now());
|
|
1258
1264
|
const frame = typeof requestAnimationFrame === "function" ? requestAnimationFrame : null;
|
|
1259
1265
|
const unfit = (el) => { if (el?.style) { el.style.removeProperty("height"); el.style.removeProperty("transform"); } };
|
|
@@ -1264,13 +1270,24 @@ export function Shell({ panels, onNewInstance, viewOnly = false }) {
|
|
|
1264
1270
|
// says for the moment: a reading that dips must not hand the height back to the stylesheet for one frame.
|
|
1265
1271
|
const typingNow = coarse() && isTextEntry(document.activeElement);
|
|
1266
1272
|
const on = coarse() && (shellStore.get().keyboard || typingNow || now() < followUntil) && Math.abs((Number(vv.scale) || 1) - 1) < 0.01;
|
|
1267
|
-
if (!on) { unfit(el); fitH = 0; return; }
|
|
1273
|
+
if (!on) { unfit(el); fitH = 0; fitTop = 0; fitW = -1; moveSince = 0; return; }
|
|
1274
|
+
const h = Math.round(vv.height), top = Math.max(0, Math.round(Number(vv.offsetTop) || 0)), w = Math.round(vv.width);
|
|
1275
|
+
const settled = fitH && typingNow && w === fitW && now() >= followUntil;
|
|
1276
|
+
if (settled && (h !== fitH || top !== fitTop) && !(fitH - h > KEYBOARD_MIN_PX)) {
|
|
1277
|
+
if (!moveSince) moveSince = now();
|
|
1278
|
+
const left = DOWN_HOLD_MS - (now() - moveSince);
|
|
1279
|
+
if (left > 0) { // not held yet: the shell stays as it is
|
|
1280
|
+
if (!moveTimer && typeof setTimeout === "function") moveTimer = setTimeout(() => { moveTimer = 0; fit(); }, left + 20);
|
|
1281
|
+
return;
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
moveSince = 0;
|
|
1268
1285
|
// A reading that says "down" while the field keeps focus is on hold (below): until it holds, the shell keeps the height
|
|
1269
1286
|
// it had, so the box does not drop under a keyboard that is still there.
|
|
1270
1287
|
const pending = downSince && now() - downSince < DOWN_HOLD_MS && fitH;
|
|
1271
|
-
fitH = pending ? fitH :
|
|
1288
|
+
fitH = pending ? fitH : h;
|
|
1289
|
+
fitTop = top; fitW = w;
|
|
1272
1290
|
el.style.setProperty("height", `${fitH}px`);
|
|
1273
|
-
const top = Math.max(0, Math.round(Number(vv.offsetTop) || 0));
|
|
1274
1291
|
if (top) el.style.setProperty("transform", `translateY(${top}px)`); else el.style.removeProperty("transform");
|
|
1275
1292
|
};
|
|
1276
1293
|
const follow = () => {
|
|
@@ -1322,6 +1339,7 @@ export function Shell({ panels, onNewInstance, viewOnly = false }) {
|
|
|
1322
1339
|
vv.removeEventListener("resize", check); vv.removeEventListener("scroll", fit); document.removeEventListener("focusin", focusChanged); document.removeEventListener("focusout", focusChanged);
|
|
1323
1340
|
if (raf && typeof cancelAnimationFrame === "function") cancelAnimationFrame(raf);
|
|
1324
1341
|
if (downTimer && typeof clearTimeout === "function") clearTimeout(downTimer);
|
|
1342
|
+
if (moveTimer && typeof clearTimeout === "function") clearTimeout(moveTimer);
|
|
1325
1343
|
unfit(root.current);
|
|
1326
1344
|
document.removeEventListener("compositionstart", start, true); document.removeEventListener("compositionend", end, true);
|
|
1327
1345
|
};
|
|
@@ -11,6 +11,27 @@
|
|
|
11
11
|
import { html, useLayoutEffect, useRef } from "./app-html.js";
|
|
12
12
|
import { Icon } from "./ui-icons.js";
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Grow the box with its text, up to 240px; empty, it is one line. M-3206 (the user, iPhone, beta.5: typing flickered):
|
|
16
|
+
* the box was collapsed ("auto") and measured again on every key, two writes to the focused field's own style per
|
|
17
|
+
* keystroke even when its height stayed — on iOS a change to the focused field redraws the keyboard's bars, and the
|
|
18
|
+
* page followed them. Now a key that only adds text writes nothing unless the text no longer fits (a new line); only a
|
|
19
|
+
* deletion, a replaced draft, or a box with no height of its own yet collapses and measures it.
|
|
20
|
+
*/
|
|
21
|
+
export function fitComposerHeight(el, value, before) {
|
|
22
|
+
if (!el?.style) return;
|
|
23
|
+
const cap = 240;
|
|
24
|
+
const set = (px) => { const next = px == null ? "auto" : `${px}px`; if (el.style.height !== next) el.style.height = next; };
|
|
25
|
+
if (!value) { set(null); return; }
|
|
26
|
+
const grew = typeof before === "string" && value.length > before.length && el.style.height !== "";
|
|
27
|
+
if (grew) {
|
|
28
|
+
if (el.scrollHeight > el.clientHeight) set(Math.min(el.scrollHeight, cap));
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
el.style.height = "auto";
|
|
32
|
+
set(Math.min(el.scrollHeight, cap));
|
|
33
|
+
}
|
|
34
|
+
|
|
14
35
|
/** A coarse pointer (a phone, a tablet): Enter makes a new line there and the box says "enter" to the keyboard. */
|
|
15
36
|
export const touchScreen = () => typeof matchMedia === "function" && matchMedia("(pointer: coarse)").matches;
|
|
16
37
|
|
|
@@ -27,10 +48,10 @@ export function ComposerInput({ inputRef, value, placeholder, onValue, onKeyDown
|
|
|
27
48
|
// A render while composing (another part of the page changed) gives the box what it holds, so it never writes it.
|
|
28
49
|
const boxValue = composing.current && input.current ? input.current.value : value;
|
|
29
50
|
// Grow with the text, up to a limit. Empty, it is one line (#2478 — a long name's placeholder made the box two lines).
|
|
51
|
+
const fitted = useRef(null);
|
|
30
52
|
useLayoutEffect(() => {
|
|
31
53
|
const el = input.current; if (!el || composing.current) return;
|
|
32
|
-
el.
|
|
33
|
-
if (value) el.style.height = `${Math.min(el.scrollHeight, 240)}px`;
|
|
54
|
+
fitComposerHeight(el, value, fitted.current); fitted.current = value;
|
|
34
55
|
}, [value]);
|
|
35
56
|
const onInput = (e) => { if (composing.current || e.isComposing) return; onValue(e.target.value); };
|
|
36
57
|
const onCompositionStart = () => { composing.current = true; };
|