fix(tvos): stop a single Siri Remote flick moving focus two steps
Touch travel banked during the swipe repeat cooldown was released as a second focus step by the first post-cooldown move frame, even when the finger had stopped or was lifting. Re-anchor the swipe delta on every frame inside the cooldown so a discrete flick emits exactly one step while a sustained drag keeps repeating. close #1756
This commit is contained in:
@@ -172,12 +172,19 @@ class AppleTvRemoteTouchService {
|
||||
|
||||
final deltaX = _anchorX - x;
|
||||
final deltaY = _anchorY - y;
|
||||
final axis = _resolveSwipeAxis(x: x, y: y, deltaX: deltaX, deltaY: deltaY);
|
||||
if (axis == null) return;
|
||||
|
||||
final now = _now();
|
||||
final lastSwipeAt = _lastSwipeAt;
|
||||
if (lastSwipeAt != null && now.difference(lastSwipeAt) < swipeRepeatInterval) {
|
||||
// Travel during the repeat cooldown never counts toward the next step:
|
||||
// re-anchor on every frame so a fast flick's deceleration tail is
|
||||
// discarded instead of banked. Without this, the first post-cooldown
|
||||
// move frame — even a stationary or lift-drift one — released the
|
||||
// banked delta as a second focus step for a single intentional swipe.
|
||||
// A deliberate continuous drag still repeats because it covers a fresh
|
||||
// swipe threshold after each cooldown expires.
|
||||
_anchorX = x;
|
||||
_anchorY = y;
|
||||
final age = now.difference(lastSwipeAt).inMilliseconds;
|
||||
_log(
|
||||
'suppress swipe reason=repeat-cooldown age=${age}ms dx=${_formatDouble(deltaX)} dy=${_formatDouble(deltaY)}',
|
||||
@@ -185,6 +192,9 @@ class AppleTvRemoteTouchService {
|
||||
return;
|
||||
}
|
||||
|
||||
final axis = _resolveSwipeAxis(x: x, y: y, deltaX: deltaX, deltaY: deltaY);
|
||||
if (axis == null) return;
|
||||
|
||||
final logicalKey = axis == _SwipeAxis.horizontal
|
||||
? (deltaX >= 0 ? LogicalKeyboardKey.arrowLeft : LogicalKeyboardKey.arrowRight)
|
||||
: (deltaY >= 0 ? LogicalKeyboardKey.arrowUp : LogicalKeyboardKey.arrowDown);
|
||||
|
||||
Reference in New Issue
Block a user