mwg API
    Preparing search index...

    Function spinValue

    • Steps a number by delta, snapped to step and kept in [min, max]. With wrap, passing the top starts again at the bottom and dropping below the bottom lands on the top; without it, the value clamps - a level cap or a bag size, where wrapping would be a surprise.

      Parameters

      • value: number
      • delta: number
      • min: number
      • max: number
      • step: number = 1
      • wrap: boolean = false

      Returns number

      import { spinValue } from '@datamoc/mw_games/two-d/ui';

      console.log(spinValue(10, 1, 0, 10, 1)); // 10, clamped
      console.log(spinValue(10, 1, 0, 10, 1, true)); // 0, wrapped