fix(player): stop the seek bar resizing as its clocks count
Two different things moved it and they need different answers. Digits in a proportional font are different widths, so 1:11 is narrower than 4:08 and the bar breathed once a second -- tabular figures fix that. The character *count* changes too, at the hundredth minute and whenever the right-hand clock is toggled to remaining and grows a minus sign, which a figure width cannot fix -- so each clock reserves the widest string this track can put in it. The budget is per track rather than a constant: reserving six characters on every track would push the slider in by a character at each end to buy nothing. Measured in the component tier: 4.5px of drift across three positions before, none after. Refs #13
This commit is contained in:
@@ -227,6 +227,41 @@ describe('<seek-bar>', () => {
|
||||
expect(text(el, '[data-testid="remaining-time"]')).toBe('01:30');
|
||||
});
|
||||
|
||||
it('keeps the slider still as the clocks count', async () => {
|
||||
const el = await fixture('seek-bar');
|
||||
|
||||
emit(Events.TrackChanged, { ...TRACK, trackChangeId: 31 });
|
||||
await flush();
|
||||
await el.updateComplete;
|
||||
|
||||
const slider = () =>
|
||||
shadow(el, 'wa-slider')!.getBoundingClientRect();
|
||||
const before = slider();
|
||||
|
||||
// 1:11 against 4:08 is the reported jitter: different digits, and
|
||||
// in a proportional font different widths. Toggling the right-hand
|
||||
// clock is the other half -- the minus sign is a whole character.
|
||||
for (const positionSeconds of [8, 71, 88]) {
|
||||
emit(Events.PlaybackPositionChanged, {
|
||||
positionSeconds,
|
||||
trackLength: 90,
|
||||
trackChangeId: 31,
|
||||
seq: positionSeconds,
|
||||
playing: true,
|
||||
});
|
||||
await flush();
|
||||
await el.updateComplete;
|
||||
|
||||
expect(slider().width).toBeCloseTo(before.width, 1);
|
||||
expect(slider().left).toBeCloseTo(before.left, 1);
|
||||
}
|
||||
|
||||
await click(el, '[data-testid="remaining-time"]');
|
||||
await el.updateComplete;
|
||||
|
||||
expect(slider().width).toBeCloseTo(before.width, 1);
|
||||
});
|
||||
|
||||
it('renders the position the backend reports rather than its own count', async () => {
|
||||
const el = await fixture('seek-bar');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user