Slideshow example
This RSG 2.0 SDK app demonstrates the @roku-sdk/slideshow package with four rendering strategies. The following screenshot shows the virtual mode:
Variants
The example includes the following variants:
| Config | Mode | Description |
|---|---|---|
roku-config-eager.ts | Eager | All slides rendered and kept alive. Suited to small slide counts. |
roku-config-focus.ts | Focus (Eager) | Eager mode with interactive slides containing nested FocusBoundary and focusable buttons. |
roku-config-pooled.ts | Pooled | Slides drawn from an object pool. Suited to homogeneous slides with recycled templates. |
roku-config-virtual.ts | Virtual | Only slides within a window around the current index are mounted. Suited to large slide counts. |
Running
To run a variant, use these commands:
# Default (eager)
rk dev
# Specific variant
rk dev --config roku-config-virtual.ts
# Or build and sideload
rk build --config roku-config-pooled.ts
rk dev --no-build --out-dir dist-buildHow it works
Each variant creates a slideshow using a different factory function from @roku-sdk/slideshow:
createSlideshow(eager and focus): Renders all slides in a horizontal strip.FocusBoundarywithnavigation="horizontal"handles navigation.createPooledSlideshow: Uses a singleuseFocusableleaf with imperativeonKeyhandlers. Pool templates render increateRootoutside the focus tree.createVirtualSlideshow: Mounts and unmounts slides through<Show>based on proximity tocurrentIndex.onUnhandledKeydrives navigation imperatively to avoid mount-timing issues with the virtual window.
Shared features
All modes support:
- Chevrons: Left and right arrow indicators (customizable through the
chevronsprop) - Dot indicator: Shows the current position (customizable through the
dotsprop) - Edge callbacks:
onEdgeReached("first" | "last")fires at boundaries - Animated transitions: Configurable easing and duration through the
animationprop - Programmatic control: The factory returns
goTo(index),next(), andprev()
Controls
You can use these keys to navigate the app:
- Left and Right: Navigate between slides
- OK: Triggers the
onSelectcallback (if configured)
Updated about 4 hours ago
Did this page help you?