API
Arguments

Passing arguments

In this library, function parameters are not limited to static values. They can also be functions that return the respective parameter value. This is facilitated by the ValueOrGetter (opens in a new tab) type, which allows for dynamic computation or retrieval of parameter values.

This can be useful to isolate complex parameters, or to omit problems when creating parameters in a server environment and there is no access to the window api.

createMotion(
  () => /* your motion */,
  {
    enable: true // static value
  }
)
createMotion(
  () => /* your motion */,
  {
    enable: () => true // using a function
  }
)
createMotion(
  () => /* your motion */,
  () => ({ // even the whole parameter object may be returned from a function
    enable: () => true
  })
)

This feature is implemented across all presets and is also incorporated in the createMotion function. This means that whenever you're working with these elements, you have the flexibility to use a getter function for your parameters.