Skip to content

Commit fc74ac1

Browse files
committed
fix(player): keep Next available for the final slide's reveals
1 parent 89081b9 commit fc74ac1

3 files changed

Lines changed: 45 additions & 1 deletion

File tree

‎docs/guides/slideshow.mdx‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ Attach the source notes, document, page, or existing deck. Name the audience and
6363

6464
The main story should still make sense when no optional branch is opened.
6565

66+
Use **Next** to step through fragment reveals, including those on the final slide.
67+
The Next button disappears once the final slide's last reveal is shown.
68+
6669
## Review it as a presenter
6770

6871
- Each slide makes one clear point.

‎packages/player/src/slideshow/SlideshowController.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ export class SlideshowController {
7171
}
7272

7373
get canNext(): boolean {
74-
// next has a destination: a later slide in this sequence, OR (in a branch) the parent.
74+
const slide = this.currentSlide;
75+
if (slide && this.frame.fragmentIndex + 1 < slide.fragments.length) return true;
7576
const slides = this.slidesOf(this.frame.sequenceId);
7677
return this.frame.slideIndex + 1 < slides.length || this.stack.length > 1;
7778
}

‎packages/player/src/slideshow/hyperframes-slideshow.test.ts‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ import { handleRuntimeMessage } from "../runtime-message-handler.js";
44
import {
55
childrenMayStillArrive,
66
dropInvalidSlides,
7+
HyperframesSlideshow,
78
locateSlideshowParts,
89
} from "./hyperframes-slideshow.js";
10+
import { SlideshowController } from "./SlideshowController.js";
911
import { slideshowChannelName } from "./slideshowPresenter.js";
1012

1113
// Dynamic import defers custom-element registration until happy-dom is active.
@@ -131,6 +133,44 @@ describe("<hyperframes-slideshow>", () => {
131133
el.remove();
132134
});
133135

136+
it("keeps Next available until the final slide's fragments are revealed", () => {
137+
const player = {
138+
currentTime: 0,
139+
seek: (time: number) => {
140+
player.currentTime = time;
141+
},
142+
play: vi.fn(),
143+
pause: vi.fn(),
144+
onTimeUpdate: () => () => {},
145+
};
146+
const controller = new SlideshowController(player, {
147+
slides: [
148+
{ sceneId: "intro", start: 0, end: 5, fragments: [], hotspots: [] },
149+
{ sceneId: "closing", start: 5, end: 10, fragments: [6, 8, 9], hotspots: [] },
150+
],
151+
sequences: {},
152+
});
153+
const el = new HyperframesSlideshow();
154+
document.body.appendChild(el);
155+
el.__setControllerForTest(controller);
156+
157+
try {
158+
controller.goToSlide(1);
159+
expect(player.currentTime).toBe(6);
160+
expect(el.querySelector("[data-hf-next]")).not.toBeNull();
161+
162+
el.querySelector<HTMLButtonElement>("[data-hf-next]")?.click();
163+
expect(player.currentTime).toBe(8);
164+
expect(el.querySelector("[data-hf-next]")).not.toBeNull();
165+
166+
el.querySelector<HTMLButtonElement>("[data-hf-next]")?.click();
167+
expect(player.currentTime).toBe(9);
168+
expect(el.querySelector("[data-hf-next]")).toBeNull();
169+
} finally {
170+
el.remove();
171+
}
172+
});
173+
134174
it("renders an icon-only present button inside the nav cluster in normal mode", () => {
135175
const el = makeEl({ index: 1, total: 3 });
136176
const cluster = el.querySelector("[data-hf-nav-cluster]");

0 commit comments

Comments
 (0)