Skip to content

Commit

Permalink
#50 Call drag callback with GestureState::Began
Browse files Browse the repository at this point in the history
  • Loading branch information
wtholliday committed Jun 16, 2023
1 parent d34f2a0 commit f8242da
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/views/drag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,18 @@ where
) {
match &event {
Event::TouchBegin { id, position } => {
if self.hittest(vid, *position, cx).is_some() {
if cx.touches[*id].is_default() && self.hittest(vid, *position, cx).is_some() {
cx.touches[*id] = vid;
cx.starts[*id] = *position;
cx.previous_position[*id] = *position;
cx.grab_cursor = self.grab;

actions.push(Box::new((self.func)(
cx,
[0.0,0.0].into(),
GestureState::Began,
cx.mouse_button,
)));
}
}
Event::TouchMove {
Expand Down Expand Up @@ -312,7 +319,7 @@ mod tests {
ui.process(event, cx.root_id, &mut cx, &mut actions);
}

assert_eq!(cx[s], vec![GestureState::Changed, GestureState::Ended]);
assert_eq!(cx[s], vec![GestureState::Began, GestureState::Changed, GestureState::Ended]);

}
}

0 comments on commit f8242da

Please sign in to comment.