Skip to content

Commit

Permalink
don't trigger drag events if there's no movement (#16950)
Browse files Browse the repository at this point in the history
# Objective

- Fixes #16571

## Solution

- When position delta is zero, don't trigger `Drag` or `DragOver` events

## Testing

- tested with the code from the issue
  • Loading branch information
mockersf authored Dec 24, 2024
1 parent 99c869d commit 4acb34e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crates/bevy_picking/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -692,14 +692,18 @@ pub fn pointer_events(

// Emit Drag events to the entities we are dragging
for (drag_target, drag) in state.dragging.iter_mut() {
let delta = location.position - drag.latest_pos;
if delta == Vec2::ZERO {
continue; // No need to emit a Drag event if there is no movement
}
let drag_event = Pointer::new(
pointer_id,
location.clone(),
*drag_target,
Drag {
button,
distance: location.position - drag.start_pos,
delta: location.position - drag.latest_pos,
delta,
},
);
commands.trigger_targets(drag_event.clone(), *drag_target);
Expand Down

0 comments on commit 4acb34e

Please sign in to comment.