animateMoveTo
Function
Common
fun MouseInjectionScope.animateMoveTo(
position: Offset,
durationMillis: Long = DefaultMouseGestureDurationMillis,
)
Move the mouse from the current position
to the given
position
, sending a stream of move events to get an animated path of durationMillis
milliseconds. Move
the mouse to the desired start position if you want to start from a
different position. The position
is in the node's local coordinate system, where (0, 0) is the
top left corner of the node.
Example of moving the mouse along a line:
Parameters
position | The position where to move the mouse to, in the node's local coordinate system |
durationMillis | The duration of the gesture. By default 300 milliseconds. |
Code Examples
mouseInputAnimateMoveTo
fun mouseInputAnimateMoveTo() {
composeTestRule.onNodeWithTag("myComponent").performMouseInput {
// Hover over the node, making an X shape
moveTo(topLeft)
animateMoveTo(bottomRight)
// Note that an actual user wouldn't be able to instantly
// move from the bottom right to the top right
moveTo(topRight)
animateMoveTo(bottomLeft)
}
}