PR pixi-reels
All recipes
skip UX

How to slam-stop

Let the player tap the spin button again to land the reels immediately — with the result still correct.

Steps
  1. If the reels are spinning, reelSet.skip() — otherwise reelSet.spin()
  2. Ensure setResult() has already fired so skip lands on target
  3. Inspect result.wasSkipped to adjust animations (shorter win celebration, etc.)
APIs ReelSet.skipReelSet.isSpinningSpinResult.wasSkipped

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

  1. Emits skip:requested.
  2. Force-completes every active spin phase (including GSAP tweens).
  3. Calls reel.placeSymbols(targetRow) on every reel with the result from setResult(), or the current symbols if none was set.
  4. Snaps the reel container y back to 0.
  5. 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']);