fix(player): a held key on faded bands stays one blind press; a play asked for mid-restart is the new session's
The repeats of a Space/Enter that landed on faded bands pressed the control once the bands were up; they are swallowed with it. A play or pause while a session restart is out now sets that session's intent instead of playing the outgoing stream. Tests: Skip intro outside the bands keeps its keys, every restore takeover (wheel, finger, scrollbar, key) is covered, and the chip handoff test tells the chip before from the row's first control.
This commit is contained in:
@@ -155,7 +155,14 @@ describe("PageScroller scroll memory", () => {
|
||||
});
|
||||
|
||||
// Round 3: the give-up put the page at its end 1.5 s in, wherever the reader had scrolled to.
|
||||
it("stops where the reader takes the page over, even for a spot it has not reached", () => {
|
||||
// Every way a reader takes the page: a wheel, a finger, the scrollbar (a pointer), a key.
|
||||
it.each([
|
||||
["a wheel", (main: HTMLElement) => fireEvent.wheel(main)],
|
||||
["a finger", (main: HTMLElement) => fireEvent.touchStart(main)],
|
||||
["the scrollbar", (main: HTMLElement) => fireEvent.pointerDown(main)],
|
||||
["a key", () => fireEvent.keyDown(document.body, { key: "ArrowUp" })],
|
||||
])("stops where %s takes the page over, even for a spot it has not reached", (_, take) => {
|
||||
const removed = vi.spyOn(document, "removeEventListener");
|
||||
let frames: FrameRequestCallback[] = [];
|
||||
vi.stubGlobal("requestAnimationFrame", (cb: FrameRequestCallback) => frames.push(cb));
|
||||
const flush = (n: number) => {
|
||||
@@ -177,7 +184,9 @@ describe("PageScroller scroll memory", () => {
|
||||
setEntry(1);
|
||||
notifyNav();
|
||||
flush(5);
|
||||
fireEvent.wheel(main);
|
||||
take(main);
|
||||
// and it let go of the page-wide key listener with it
|
||||
expect(removed).toHaveBeenCalledWith("keydown", expect.any(Function), true);
|
||||
main.scrollTop = 30; // where the reader scrolled
|
||||
flush(100);
|
||||
expect(main.scrollTop).toBe(30);
|
||||
|
||||
Reference in New Issue
Block a user