You need to sign in to do that
Don't have an account?
Remco Sellmeijer 4
How to catch touch events on lightning components?
Hi all,
I'm currently exploring how to build a mobile application using Lightning Components.
At some point, I want to integrate swipe functionality which should work the same as the left and right swiping of emails in the Google Gmail app for Android.
I created a Lightning component with a simple div in it and I added a simple touch event to see if it's possible to create the swipe functionality using the standard javascript touch events (touchstart, touchend, touchcancel etc.)
Does anybody have an idea of how I can get this to work? Or is it simply not possible using Lightning Components.
Thanks in advance and have a nice day.
I'm currently exploring how to build a mobile application using Lightning Components.
At some point, I want to integrate swipe functionality which should work the same as the left and right swiping of emails in the Google Gmail app for Android.
I created a Lightning component with a simple div in it and I added a simple touch event to see if it's possible to create the swipe functionality using the standard javascript touch events (touchstart, touchend, touchcancel etc.)
doInit : function(component, event, helper) { var box1 = document.getElementById('box1'); box1.addEventListener('touchstart', function(e){ console.log(e.touches[0].pageX); }) }On clicking the component, it should log the x coordinates of the touch event. Instead pageX is undefined.
Does anybody have an idea of how I can get this to work? Or is it simply not possible using Lightning Components.
Thanks in advance and have a nice day.
tl;dr; Per this stackexchange (http://salesforce.stackexchange.com/a/129168/25289), `touches` is not yet supported. Read the comments.
I tested this:
and with my mouse I was able to get:
but when I slid with my finger, nothing happened. Taps, however were recognized.