Skip to content

Commit d2fbedb

Browse files
committed
don't trigger drag events if there's no movement (#16950)
# Objective - Fixes #16571 ## Solution - When position delta is zero, don't trigger `Drag` or `DragOver` events ## Testing - tested with the code from the issue
1 parent 49560ae commit d2fbedb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

crates/bevy_picking/src/events.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,14 +657,18 @@ pub fn pointer_events(
657657

658658
// Emit Drag events to the entities we are dragging
659659
for (drag_target, drag) in state.dragging.iter_mut() {
660+
let delta = location.position - drag.latest_pos;
661+
if delta == Vec2::ZERO {
662+
continue; // No need to emit a Drag event if there is no movement
663+
}
660664
let drag_event = Pointer::new(
661665
*drag_target,
662666
pointer_id,
663667
location.clone(),
664668
Drag {
665669
button,
666670
distance: location.position - drag.start_pos,
667-
delta: location.position - drag.latest_pos,
671+
delta,
668672
},
669673
);
670674
commands.trigger_targets(drag_event.clone(), *drag_target);

0 commit comments

Comments
 (0)