On Monday, February 9, 2015 at 8:55:51 PM UTC+2, Khalid Jebbari wrote:
> No need to fiddle with other libs or complicated build steps, React js handle
> this very well.
>
> Simply handle the touchend event and preventDefault().
>
> In React's JSX syntax :
>
> <div onClick={myHandler} onTouchEnd={myHandler}>...</div>
>
> myHandler: function(event) {
> event.preventDefault();
> ... // do your stuff
> }
>
> The preventDefault() call avoids the click to trigger 300ms after the touch
> event.
This works, but simply swapping onClick with onTouchEnd introduces usability
issues. For example, scrolling a list of clickable elements will always result
in a trigger, which is not what we want. A comprehensive solution needs to take
in account mobile-centric idiosyncracies. A good summary can be found here:
https://developers.google.com/mobile/articles/fast_buttons
Consider this:
If the user tapped somewhere else on the screen and then invokes a touchend on
the button then we should not fire a click.
If the user touches down on the button and then drags the screen a bit and then
invokes a touchend on the button then we should not fire a click.
This is where libraries like FastClick help. Ideally, I would like to see a
generic and reusable Om component with no external dependencies.
--
Note that posts from new members are moderated - please be patient with your
first post.
---
You received this message because you are subscribed to the Google Groups
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.