bevy_pancam icon indicating copy to clipboard operation
bevy_pancam copied to clipboard

Fix incorrect drag when pressing after a movement

Open ThierryBerger opened this issue 1 year ago • 0 comments

implements suggestion from https://github.com/johanhelsing/bevy_pancam/pull/48/files#r1346483971

Description from https://github.com/johanhelsing/bevy_pancam/pull/48:

When combining pancam drag with other draggable elements, I wanted to disable pancams before it could move.

Unfortunately the current pancam movement implementation can move the camera the first frame we detect a button_grab, as if user was already button_grabing previous frame.

more context for this: https://discord.com/channels/844211600009199626/1158800311171960972/1159149631117201419

Most important information from discord's discussion: pancam's implementation leads to such scenario:

### frames

  1. no click, position(0,0)
  2. click, position(0,1) -> pancam detects a drag (because we cached last position, without checking for grab_button) and moves (green 🟢) ; but bevy_mod_input only detects the click (I think that's more correct)
  3. position(0,2) -> I disable the pancam (red 🔴), pancam doesn't run (orange 🟠 )
Italian Trulli

ThierryBerger avatar Dec 29 '23 09:12 ThierryBerger