transformingMovable
public fun SubspaceModifier.transformingMovable(
enabled: Boolean = true,
scaleWithDistance: Boolean = true,
onMove: ((SpatialMoveEvent) -> Unit)? = null,
): SubspaceModifier
Configures this subspace element to be interactive and movable, delegating the pose transformation to the system.
When this modifier is present and enabled, draggable UI controls will be shown that allow the user to move the element in 3D space. The system intercepts spatial input events, calculates the resulting Pose and scale, and automatically applies these transformations to the element's layout. This is the default behavior for standard movable UI elements where a 1:1 transformation is desired, and custom gesture handling or manual state management is not required. Input events used for moving in this way are consumed.
There are some limitations that should be considered when using this modifier: 1) the draggable UI controls of nested composables using the transformingMovable modifier and movable modifier may conflict with each other, 2) attaching multiple transformingMovable modifiers to the same element will compound the movement distance, since each modifier independently applies the drag offset upon release. 3) It should not be used with the following composables androidx.xr.compose.subspace.SpatialExternalSurfaceHemisphere and androidx.xr.compose.subspace.SpatialExternalSurfaceSphere due to their similarity with the system environment and not having any layout size.
Parameters
| enabled | true if this composable should be movable. Setting this to false will remove the interactable affordance associated with the content. Disabling the modifier after movement keeps the composable at its last dragged position. Removing the modifier entirely resets the composable to its original layout position. |
| scaleWithDistance | true if this composable should scale in size when moved in depth. When enabled, the subspace element will grow if pushed away from the user or shrink when pulled toward the user in order to maintain the interact-ability and legibility of the panel. Scaling with distance respects other transformations applied to this layout. |
| onMove | Optional observer callback invoked during the manipulation. Since the system automatically applies the move, this callback is strictly for monitoring changes and should not control the position. The onMove callback values can be used to position other sibling composables with the offset modifier. This callback reports a SpatialMoveEvent which will contain a Pose. The Pose contained in this event is the sum of all previous events in the move gesture. |