fun TrackpadInjectionScope.panWithVelocity(
offset: Offset,
@FloatRange(from = 0.0) endVelocity: Float,
durationMillis: Long =
VelocityPathFinder.calculateDefaultDuration(Offset.Zero, offset, endVelocity),
)
Performs a pan gesture on the associated node such that it ends with the given endVelocity.
The pan will go from Offset.Zero at t=0 to offset at t=durationMillis. In between, the pan will go monotonically from Offset.Zero and offset, but not strictly. Due to imprecision, no guarantees can be made for the actual velocity at the end of the gesture, but generally it is within 0.1 of the desired velocity.
When a pan cannot be created that results in the desired velocity (because the input is too restrictive), an exception will be thrown with suggestions to fix the input.
The coordinates are in the pan coordinate system, which has the same scale as the display in pixel coordinates, where Offset.Zero indicates no panning.
Use pan(curve, duration, durationMillis) to directly control the curve of the pan.
Parameters
| offset | The end position of the pan |
| endVelocity | The velocity of the gesture at the moment it ends in px/second. Must be positive. |
| durationMillis | The duration of the gesture in milliseconds. Must be long enough that at least 3 input events are generated, which happens with a duration of 40ms or more. If omitted, a duration is calculated such that a valid pan with velocity can be created. |