Files
mtg-online-drafter/docs/development/devlog/2025-12-17-021000_mobile_touch_fix.md

1.1 KiB

Mobile Touch Interaction Logic

Objective

Enhance mobile usability by modifying the long-press behavior. The preview should persist while the user moves their finger across the screen (e.g., to inspect different parts of the card or simply drift) and only disappear upon releasing the finger (touchend).

Changes

  • Modified src/client/src/components/CardPreview.tsx:
    • Updated handleTouchMove in CardHoverWrapper.
    • Removed the setIsLongPressing(false) call inside the movement threshold check.
    • Logic:
      • If the user moves their finger before the 500ms long-press timer completes, the timer is cleared (canceling the preview), interpreting the action as a scroll.
      • If the user moves their finger after the preview has appeared (isLongPressing is true), the movement is ignored, and the preview remains visible.
    • The preview is now effectively closed only by handleTouchEnd (lifting the finger).

Result

This creates a much more forgiving and "tactile" experience on mobile, allowing users to hold their thumb on a card and shift it slightly without the preview abruptly vanishing.