Commit c90aaa4
committed
fix(timeline): size a keyboard-created region by the zoom too
Reported on rc.8: adding a pill on a 30-minute recording still produced
something invisible, hidden behind the playhead it was created at.
The previous commit scaled only the toolbar buttons, because the zoom lives in
V4Timeline's local `nav` state and the shortcuts are handled in NewEditorShell.
That was the wrong line to draw: the empty lanes advertise the shortcut ("Press
Z to add zoom") and the buttons are labelled "Add Zoom (Z)", so the keyboard is
how most regions actually get created — and it kept the flat 2 s, which is 0.8px
at 0.42 px/s. Measured in a browser on the reported case (30 min across a 761px
panel): the button asked for 94.6 s, the shortcut for 2 s.
The rule now lives in timeline/newRegionDuration, outside the component: the
timeline publishes its scale (px per second) and both creation paths read it at
the moment the user acts. Module state read imperatively, never subscribed —
the value changes on every zoom notch and nothing renders it, so a subscription
would re-render the whole editor shell for a number only a keypress reads. Same
reasoning as playheadSec() in useTimeline.
Reading it at CLICK time rather than at render time also drops a one-notch
staleness: the old handler captured the duration computed by the render that
preceded the effect publishing the new scale.
Verified in a real browser, both paths: 761px / 1800 s → 94.61 s → a pill 40.0px
wide, identical for the button and for what the shortcut passes. Unit-tested in
newRegionDuration.test.ts, including the invariant that duration × scale is
PILL_CREATE_PX at any zoom.1 parent ef2adab commit c90aaa4
4 files changed
Lines changed: 135 additions & 36 deletions
File tree
- src
- components/ai-edition
- v4
- lib/ai-edition/timeline
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
911 | 912 | | |
912 | 913 | | |
913 | 914 | | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
914 | 920 | | |
915 | 921 | | |
916 | | - | |
| 922 | + | |
917 | 923 | | |
918 | 924 | | |
919 | 925 | | |
920 | 926 | | |
921 | | - | |
| 927 | + | |
922 | 928 | | |
923 | 929 | | |
924 | 930 | | |
925 | 931 | | |
926 | | - | |
| 932 | + | |
927 | 933 | | |
928 | 934 | | |
929 | 935 | | |
930 | 936 | | |
931 | | - | |
| 937 | + | |
932 | 938 | | |
933 | 939 | | |
934 | 940 | | |
935 | 941 | | |
936 | | - | |
| 942 | + | |
937 | 943 | | |
938 | 944 | | |
939 | 945 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
42 | 46 | | |
43 | 47 | | |
44 | 48 | | |
| |||
125 | 129 | | |
126 | 130 | | |
127 | 131 | | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
147 | 135 | | |
148 | 136 | | |
149 | 137 | | |
| |||
470 | 458 | | |
471 | 459 | | |
472 | 460 | | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
480 | 468 | | |
481 | 469 | | |
482 | 470 | | |
| |||
1339 | 1327 | | |
1340 | 1328 | | |
1341 | 1329 | | |
1342 | | - | |
1343 | | - | |
1344 | | - | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
1345 | 1336 | | |
1346 | 1337 | | |
1347 | 1338 | | |
| |||
1352 | 1343 | | |
1353 | 1344 | | |
1354 | 1345 | | |
1355 | | - | |
| 1346 | + | |
1356 | 1347 | | |
1357 | 1348 | | |
1358 | 1349 | | |
| |||
1375 | 1366 | | |
1376 | 1367 | | |
1377 | 1368 | | |
1378 | | - | |
| 1369 | + | |
1379 | 1370 | | |
1380 | 1371 | | |
1381 | 1372 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
0 commit comments