ScaleEndDetailsCancel extension
Partially cancel translation velocity based on scale velocity. Call at
the start of onScaleEnd and use the returned details as the gesture's
velocity for the rest of the release pipeline.
Two-stage cancellation: below a small threshold, no cancellation at all
(the pinch was too subtle to count). Past the threshold, a baseline 30%
cancellation kicks in, plus a quadratic growth term in the excess scale
velocity. k ∈ [0, 1] scales the whole effect, so k=0 disables.
amount = k × (0.3 + (|scaleVelocity| − threshold)²) if past threshold factor = clamp(1 − amount, 0, 1)
k = 0→ never cancel.k = 0.5, threshold = 0.1: scaleVel 0.1 → 15%; 0.5 → 23%; 1.0 → 55%.k = 0.8, threshold = 0.1: scaleVel 0.1 → 24%; 0.5 → 37%; 1.0 → 89%.k = 1.0, threshold = 0.1: scaleVel 0.1 → 30%; 0.5 → 46%; 1.0 → full.
Methods
-
cancelTranslation(
double k) → ScaleEndDetails -
Available on ScaleEndDetails, provided by the ScaleEndDetailsCancel extension
Constants
- cancelTranslationBaseline → const double
-
Cancellation amount applied the moment
|scaleVelocity|crosses cancelTranslationThreshold (before the quadratic growth term), scaled byk. - cancelTranslationThreshold → const double
-
|scaleVelocity|below this is treated as no-pinch — no cancellation.