How Random Selection Works

WheelOfSpins chooses a result first and then animates the wheel so the visual landing point matches the selected entry.

1. Add and validate entries

WheelOfSpins chooses a result first and then animates the wheel so the visual landing point matches the selected entry.

The wheel starts with the active entries provided by the user or template. Empty entries are removed, labels are normalized for display, and the wheel only spins when there is a usable list.

  • Use the active entries only
  • Remove empty options
  • Display the final list before spinning

2. Generate a random value

The client prefers Web Crypto when `crypto.getRandomValues()` is available. If that browser API is unavailable, the code falls back to `Math.random()` so the wheel still works in less capable environments.

  • Web Crypto preferred
  • Math.random fallback
  • No unsupported cryptographic claims

3. Determine the winner

The random unit value is converted into a weighted or unweighted selection depending on the active wheel settings and entries. That chosen result is then used as the outcome for the spin.

  • Respect the active entry set
  • Apply weighting only when configured
  • Select the result before the animation ends

4. Animate the wheel to the result

After the winner is determined, the wheel animation lands on the chosen entry so the visible spinner and the underlying random result stay aligned.

  • Visual landing matches the selected entry
  • Animation does not replace the draw
  • Result behavior follows the current wheel settings

Frequently asked questions

Does WheelOfSpins always use cryptographically secure randomness?

No. The implementation prefers Web Crypto where available, but it falls back to Math.random when that API is not available.

Is the animation what decides the winner?

No. The winner is selected first, and the animation is aligned to that selected result.

Can weighting affect the result?

Yes. If the wheel uses weighted or repeated entries, the selection reflects the configured chances.