Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 31, 2025

Replaces deprecated touch/mouse event handlers in webclient/stickers.js with the unified PointerEvents API, aligning with the pattern already used in canvas.js.

Changes

  • Event listeners: Consolidated 6 separate touch/mouse listeners into 4 unified pointer events

    • touchstart + mousedownpointerdown
    • touchend + mouseuppointerup
    • touchmove + mousemovepointermove
    • Added pointercancel for interrupted gestures
  • Multi-pointer tracking: Replaced evt.touches array with activePointers array that tracks pointer lifecycle using pointerId

  • Pointer capture: Added setPointerCapture()/releasePointerCapture() for reliable tracking across element boundaries

  • Helper functions: Renamed getDistanceBetweenTouchesgetDistanceBetweenPointers and getAngleBetweenTouchesgetAngleBetweenPointers, removed obsolete touchify() shim

  • Edge case handling: Added validation for division by zero when pointers overlap, race condition handling for missing pointers, and state preservation during gesture transitions

Before/After

// Before: separate event handlers + conversion shim
function touchify(evt) {
  if (evt.touches === undefined) {
    evt.touches = [ { clientX: evt.clientX, clientY: evt.clientY } ];
  }
}

sticker.addEventListener("touchstart", move_start);
sticker.addEventListener("mousedown",  move_start);
// ... 4 more listeners

// After: unified pointer events
sticker.addEventListener("pointerdown", move_start);
sticker.addEventListener("pointerup",   move_end);
sticker.addEventListener("pointermove", do_move);
sticker.addEventListener("pointercancel", move_end);
Original prompt

This section details on the original issue you should resolve

<issue_title>Use PointerEvents for stickers.js</issue_title>
<issue_description>webclient/stickers.js still uses old-style touch/mouse events, convert these to PointerEvents</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Use PointerEvents in stickers.js Convert stickers.js to PointerEvents API Oct 31, 2025
Copilot AI requested a review from floe October 31, 2025 11:17
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.

Use PointerEvents for stickers.js

2 participants