The minimum code
spinButton.addEventListener('click', async () => {
if (reelSet.isSpinning) {
reelSet.skip();
return;
}
const promise = reelSet.spin();
const response = await fetch('/api/spin').then((r) => r.json());
reelSet.setResult(response.symbols);
const result = await promise;
if (result.wasSkipped) {
// skip paths can use shorter/no win animations
}
});
What skip() actually does
- Emits
skip:requested.
- Force-completes every active spin phase (including GSAP tweens).
- Calls
reel.placeSymbols(targetRow) on every reel with the result from setResult(), or the current symbols if none was set.
- Snaps the reel container
y back to 0.
- Fires
skip:completed then spin:complete with wasSkipped: true.
Test it
import { createTestReelSet, captureEvents } from 'pixi-reels';
const { reelSet, spinAndLand } = createTestReelSet({ reels: 5, visibleRows: 3, symbolIds: ['a','b','c'] });
const log = captureEvents(reelSet, ['skip:requested', 'skip:completed', 'spin:complete']);
const result = await spinAndLand([['a','a','a'],['b','b','b'],['c','c','c'],['a','b','c'],['c','b','a']]);
expect(result.wasSkipped).toBe(true);
expect(log.map((e) => e.event)).toEqual(['skip:requested','spin:complete','skip:completed']);