For implementation of onClick function which approach is better?
- Saving touch start / touch up coordinates and processing this values for closeness? Like, if starting point and up point close each other, let the click action start.
- Saving touch start / touch up time difference and processing this value? Like, if touch starting time and up time difference less than a value, let the click action start.
And why?
Depends on how many kind of touch events you want to support:
on Up : click
on Up : without moving much – > click , moved -> swipe
on Up : short duration – > click , long duration -> long press has
been triggered, ignore.
on Up and long press triggered : without moving much – > ignore , moved -> drag n drop
You go into details of duration and displacement , when you really need more kinds of touch events.Best approach depends on scenario. So, if your touchscreen doesn’t have a notion of swipe or long press or drag n drop, you might just fire a click on every up event, simplest scenario.