+ 5

Can anyone explain why this code doesn't work on Android?

I wrote this code to demonstrate a way to detect swipes left and right and it works fine on iOS but doesn't seem to work for Android users. Can anyone explain why? https://code.sololearn.com/WIdKWjQ5UssG/?ref=app

7th Jul 2020, 9:30 AM
Russ
Russ - avatar
9 Answers
+ 5
its interesting how different it is. usually to take touch coordinates i need to take the array-like touch object from the event, the reason for that is multitouch. ex. swipedown = e.touches[0].pageX we also cant directly take the coordinates from the touchend, because the array-like object is empty by then. and so touchmove event were used to update the touch position, that can be use later in touch end https://code.sololearn.com/WQ2uOR86jRHs/?ref=app
7th Jul 2020, 9:51 AM
Taste
Taste - avatar
+ 5
Could also use e.changedTouches[0].pageX https://code.sololearn.com/WnfjdLm96l2s/#js
7th Jul 2020, 12:31 PM
ODLNT
ODLNT - avatar
+ 4
Taste It works perfectly for me too! Thanks a lot! 👍
7th Jul 2020, 9:59 AM
Russ
Russ - avatar
+ 4
Russ the code given by Taste is working in my andorid version with popping alert when swipe left and right 👍
7th Jul 2020, 9:59 AM
Preity
Preity - avatar
+ 4
Great addition to the discussion - thanks ODLNT !
7th Jul 2020, 4:36 PM
Russ
Russ - avatar
+ 3
Taste Great answer, thank you! Would it be possible for you to build a small working demo to show how it needs to be done for Android? I wouldn't normally ask but, obviously, I'm unable to test it myself.
7th Jul 2020, 9:56 AM
Russ
Russ - avatar
+ 3
Russ i just attached the code, let me know its behavior in ios
7th Jul 2020, 9:58 AM
Taste
Taste - avatar
+ 3
i see, good to know the method i used also work in ios thank you
7th Jul 2020, 10:01 AM
Taste
Taste - avatar
0
I can't understand that what do here does Please if who know about here do help me!!!
7th Jul 2020, 2:48 PM
Abduxalil Toshtemirov
Abduxalil Toshtemirov - avatar