onLayoutRectChanged

Functions summary

Modifier
Modifier.onLayoutRectChanged(
    throttleMillis: Long,
    debounceMillis: Long,
    callback: (RelativeLayoutBounds) -> Unit
)

Invokes callback with the position of this layout node relative to the coordinate system of the root of the composition, as well as in screen coordinates and window coordinates.

Cmn

Functions

Modifier.onLayoutRectChanged

fun Modifier.onLayoutRectChanged(
    throttleMillis: Long = 0,
    debounceMillis: Long = 64,
    callback: (RelativeLayoutBounds) -> Unit
): Modifier

Invokes callback with the position of this layout node relative to the coordinate system of the root of the composition, as well as in screen coordinates and window coordinates. This will be called after layout pass. This API allows for throttling and debouncing parameters in order to moderate the frequency with which the callback gets invoked during high rates of change (e.g. scrolling).

Specifying throttleMillis will prevent callback from being executed more than once over that time period. Specifying debounceMillis will delay the execution of callback until that amount of time has elapsed without a new position, scheduling the callback to be executed when that amount of time expires.

Specifying 0 for both throttleMillis and debounceMillis will result in the callback being executed every time the position has changed. Specifying non-zero amounts for both will result in both conditions being met. Specifying a non-zero throttleMillis but a zero debounceMillis is equivalent to providing the same value for both throttleMillis and debounceMillis.

Parameters
throttleMillis: Long = 0

The duration, in milliseconds, to prevent callback from being executed more than once over that time period.

debounceMillis: Long = 64

The duration, in milliseconds, to delay the execution of callback until that amount of time has elapsed without a new position.

callback: (RelativeLayoutBounds) -> Unit

The callback to be executed.