Hi everybody,
i’m writing this post to sum up some little research i did about click events on mobile Meteor apps.
This is not strictly related to Meteor but i like to share it on meteor forum too
As you may know each click event on mobile platforms is automatically delayed of 300ms to allows to capture the double click event.
Usually we just want our app being faster than that, for this reason it is possibile to use the precious Fastclick package by percolate that is a simple wrapper of the original source by FT Labs.
As it states:
This package is included by default on all Meteor Phonegap/Cordova apps. If you would like to use Fastclick for mobile web as well, add it to your app directly with meteor add fastclick.
Now it comes the pain (and the tests as well) :
On my Android (4.4) i tested the fastclick thing in my app and
- on the default mobile browser IT DOES NOT WORK
- on the cordova version IT DOES NOT WORK
- on the chrome browser IT DOES WORK
So i tried to dig a little bit more and i’ve found this :
This issue reports that fastclick DOES NOT WORK on Android webview browser (how frustrating!) and the only workaround is using the touchstart event:
$('#myid').on( 'touchstart', function ( startEvent ) {
};
I did not test this solution yet but i started to think how to make my code base compatibile to desktop browser too and i found this http://stackoverflow.com/questions/18201361/how-to-replace-click-with-touchstart-on-ios-devices
In particular i quote :
var clickHandler = ('ontouchstart' in document.documentElement ? "touchstart" : "click");
$("a").bind(clickHandler, function(e) {
alert("clicked or tapped. This button used: " + clickHandler);
});
This will trigger click on non-touch devices and touchstart on touch devices.
When that is said, I will strongly recommend using Fast click instead, and use regular click-events. With the above solution, you will trigger "touchstart" on links when you swipe on it to scroll the page for instance - which is not ideal.
So, at the end of the day, it seems that using touchstart could be a workaround for the issue but it breaks the scrolling behaviour of the app… not a fair conclusion
Well this what i have found so far, i hope this could be a good starting point to bring the tests one step forward.
If someone knows another solution already exists i would love to hear him
Thanks for reading!