mwg API
    Preparing search index...

    Function scrollOffset

    • Clamps a scroll offset so the content never pulls away from the top or leaves a gap past the bottom. When the content is shorter than the viewport the only offset is 0.

      Parameters

      • offset: number
      • contentSize: number
      • viewportSize: number

      Returns number

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

      console.log(scrollOffset(-5, 500, 200)); // 0
      console.log(scrollOffset(900, 500, 200)); // 300