Skip to content

Fix mobile swipe-down input triggering unintended jump - #2

Merged
jankln merged 2 commits into
mainfrom
copilot/fix-player-jump-on-scroll
Aug 18, 2026
Merged

jankln merged 2 commits into
mainfrom
copilot/fix-player-jump-on-scroll

Conversation

Copilot AI commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Mobile touch input was firing jump() at gesture start, so a downward swipe intended to duck could trigger a jump first. This change separates tap vs swipe intent before applying jump logic.

  • Input routing on mobile

    • Pointer handlers now ignore touch pointers (event.pointerType === "touch"), so touch is handled in one path only.
    • This prevents duplicate/early mobile actions from overlapping pointer + touch streams.
  • Tap-vs-swipe gesture handling

    • Removed jump trigger from touchstart.
    • touchend now triggers jump only for tap-like gestures (deltaY <= 40).
    • Downward swipe behavior continues to activate ducking while preserving game-over tap restart.
  • Representative change

    // before: jump on touchstart
    // now: jump only after confirming tap on touchend
    if (state.gameOver && deltaY <= 40) {
      resetGame();
      startGame();
    } else if (deltaY <= 40 && (!state.started || state.running)) {
      jump();
    } else {
      releaseJump();
    }

Co-authored-by: jankln <77668140+jankln@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix player jump issue on mobile version during scroll Fix mobile swipe-down input triggering unintended jump Aug 18, 2026
Copilot AI requested a review from jankln August 18, 2026 12:45
@jankln
jankln marked this pull request as ready for review August 18, 2026 12:48
Copilot AI lite review requested due to automatic review settings August 18, 2026 12:48
@jankln
jankln merged commit 1f6e00b into main Aug 18, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts mobile input handling to prevent a downward swipe (duck) from triggering an unintended jump by separating tap intent from swipe intent and avoiding duplicate touch routing through pointer events.

Changes:

  • Pointer event handlers now ignore touch pointers to avoid overlapping pointer + touch input streams.
  • touchstart no longer triggers jump(), and touchend triggers jump() only for tap-like gestures (deltaY <= 40).
  • Swipe-down duck behavior is preserved while maintaining tap-to-restart on game over.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread app.js
Comment on lines 528 to 535
if (state.gameOver && deltaY <= 40) {
resetGame();
startGame();
} else if (deltaY <= 40 && (!state.started || state.running)) {
jump();
} else {
releaseJump();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mobile version: when scroll down to duck, player will jump first

3 participants