If there is no movement, DragStart is not triggered. (#17233)

# Objective

Fixed the issue where DragStart was triggered even when there was no
movement
https://github.com/bevyengine/bevy/issues/17230

## Solution

- When position delta is zero, don't trigger DragStart events, DragStart
is not triggered, so DragEnd is not triggered either. Everything is
fine.

## Testing

- tested with the code from the issue

---

## Migration Guide

> Fix the missing part of Drag
https://github.com/bevyengine/bevy/pull/16950
This commit is contained in:
DaoLendaye 2025-01-09 15:17:56 +08:00 committed by GitHub
parent 9f1b8b4769
commit 7b56a1aa98
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -662,6 +662,9 @@ pub fn pointer_events(
} }
// Moved // Moved
PointerAction::Moved { delta } => { PointerAction::Moved { delta } => {
if delta == Vec2::ZERO {
continue; // If delta is zero, the following events will not be triggered.
}
// Triggers during movement even if not over an entity // Triggers during movement even if not over an entity
for button in PointerButton::iter() { for button in PointerButton::iter() {
let state = pointer_state.get_mut(pointer_id, button); let state = pointer_state.get_mut(pointer_id, button);