tapHintPointerOffsetAt function

Offset tapHintPointerOffsetAt({
  1. required TapHintGesture gesture,
  2. required double t,
  3. required Offset start,
  4. Offset? end,
  5. double bob = 8,
})

Pointer position along a tap/swipe hint at animation t (0..1).

Tap: stays at start, bobbing bob logical px downward on a half sine. Swipe: glides start -> end over the first 70% (eased), then rests at end for the last 30% before the loop restarts.

Implementation

Offset tapHintPointerOffsetAt({
  required TapHintGesture gesture,
  required double t,
  required Offset start,
  Offset? end,
  double bob = 8,
}) {
  final p = t.clamp(0.0, 1.0);
  if (gesture == TapHintGesture.tap) {
    return start + Offset(0, bob * math.sin(p * math.pi));
  }
  final target = end ?? start;
  final glide = Curves.easeInOut.transform((p / 0.7).clamp(0.0, 1.0));
  return Offset.lerp(start, target, glide)!;
}