Skip to main content

CommonGenerateGrid

Callable


  • Automatically generate a grid based on parameters and apply a callback to each grid point.

    This function takes a list of items, grid parameters, and a callback to manage creating a grid of them. It'll find the best value for margins between each cell, then will call the callback passing each item with its calculated coordinates in turn.

    Returning true from the callback to stop the iteration, useful for click handlers so you don't keep checking items after handling one.


    Type parameters

    • T

    Parameters

    Returns number

    • The (offsetted) index for which the callback evaluated to true, or -1 if no elements satisfy the testing