Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Touch events not working in Android 4.4.2 #1729

Closed
marcsyp opened this issue Jul 5, 2014 · 52 comments
Closed

Touch events not working in Android 4.4.2 #1729

marcsyp opened this issue Jul 5, 2014 · 52 comments
Assignees
Milestone

Comments

@marcsyp
Copy link

marcsyp commented Jul 5, 2014

It appears that Android 4.4.2 is not playing nicely with touch events. Using the on-swipe directives in Ionic is extremely unreliable, with swipe events detected only 1 in 10 or 1 in 50 times on a Samsung Galaxy S5 or Nexus 5. Swipe detection is fine in earlier Android versions.

This appears to be similar if not identical to an issue that is known to be causing problems in other frameworks like JQuery Mobile. Some reference material:

JQM issue (still open):
jquery-archive/jquery-mobile#5534 (comment)

Android shim (workaround):
https://github.com/TNT-RoX/android-swipe-shim

I would also be interested in understanding why the swipes for ion-slide-box are unaffected...

@AlmogBaku
Copy link

same here, with #master branch

@jansent
Copy link

jansent commented Jul 7, 2014

Also noticed this, nothing else to add really but this is a pretty big issue.

@mlynch
Copy link
Contributor

mlynch commented Jul 7, 2014

So, can you guys be more specific? Are you talking about all touch events, or only the new gesture based ones?

Can you share a demo of what you are trying to do?

@marcsyp
Copy link
Author

marcsyp commented Jul 8, 2014

Not all touch events, and not even all gesture-based events. Specifically the swipe-related directives.

Working:
Swiping on Slide Box
on-tap gesture directive events
on-hold gesture directive events

Not working (one out of 10-50 tries):
on-swipe gesture directive
on-swipe-left, on-swipe-right, on-swipe-up, on-swipe-down gesture directives

Not tried:
on-touch
on-release
on-drag

Don't have a demo, no codepen, as everything works on web browsers... but a simple hello world Cordova app should do the trick. Will see if I can find some time to put one together. Let me know.

@marcsyp
Copy link
Author

marcsyp commented Jul 8, 2014

HelloSwipe showing a sample of the gesture problems:

https://drive.google.com/file/d/0B1ClGdseCfJdRlhzWWxLMUs5REU/edit?usp=sharing

This is a Cordova 3.3 project with only Android platform installed, using Ionic nightlies.

@perrygovier
Copy link
Contributor

Thanks @marcsyp, I can reproduce this now. Digging in...

@perrygovier
Copy link
Contributor

Note, my first attempt at resolving this will be to bind touchcancel in the same way touchend is bound.

@marcsyp
Copy link
Author

marcsyp commented Jul 14, 2014

Any thoughts? Make sure you check out the JQuery Mobile issue link above, it may give you some insight.

@TNT-RoX
Copy link

TNT-RoX commented Aug 4, 2014

Shim working now :
https://github.com/TNT-RoX/android-swipe-shim

@alexbainbridge
Copy link

@TNT-RoX Hi Andrew, when you say shim working - that requires changes to Ionic to permit that shim to work? Thank you for helping on this

@TNT-RoX
Copy link

TNT-RoX commented Aug 5, 2014

@alexbainbridge Hi, not really it should fire it's own swipe events on the elements you want. The android swipe issues are rather complex. As @perrygovier correctly states binding touchcancel to touchend will solve the kitkat issue. However older android devices will stop sending touch events to webview if preventDefault is not set; and if it is set, native scrolling is prevented (less than ideal). So if you want native scrolling and swipe events across all android versions use my shim(in beta). It overlays a contained native scrolling element that is 300% larger and centered, and converts the scroll offsets to swipe events before re-centering the element.

@adamdbradley adamdbradley self-assigned this Aug 7, 2014
@joeyhipolito
Copy link

I'm on android 4.3 and accessing my app through my network,
using google chrome both in mobile and in pc

When I am dragging out my side-menu , it works just fine in both platform, but when I drag it to close, it only works on pc.

Is this issue have something to do with what I am experiencing?

@mlegenhausen
Copy link
Contributor

I have other touch issues but maybe they are related. I have a side-menu that contains a content panel which contains a list of clickable items. I can open the panel but when clicking on any item nothing happens. But scrolling is working. This is working with no problems on iOS and Desktop Browsers. Even when using Desktop Chrome emulation for mobile touch events.

@kavuri
Copy link

kavuri commented Aug 19, 2014

+1
I have Android 4.4.4 and Cordova 3.4.0 with ionic 1.0.0-beta and I see this issue. I am able to touch the Tabs at the bottom, but touch for buttons, links do not work.
All my items in ng-repeat and buttons do not work. This is a blocker

After some investigation, found that if "scroll" is false in then tap events work (but then I cannot od that since my content goes beyond the screen size of a 5'' phone)

@perrygovier
Copy link
Contributor

Note that @voliva has a good test in his duplicate ticket #2115 that demonstrates all the events that do and don't work. I believe updating our ionic-ified implementation of hammer.js would help.

@perrygovier perrygovier modified the milestones: 1.1, 1.0.0-rc0 Oct 1, 2014
@perrygovier
Copy link
Contributor

This fits in nicely with some larger changes we'd like to make after the 1.0

@stvhanna
Copy link

Any updates on this issue? @TNT-RoX I'm using Ionic cards and still unable to get the shim to work. I've added "_ezswipe" class to swipeable cards, but still can't swipe on Android 4.4.2 or Android 4.4.4.

@rafaellop
Copy link

@DEllingsworth I'm sorry, but this seems like a stupid mistake from my side. Please ignore.

@Tomino2112
Copy link

This is also not working for me, I tried to use drag events to replicate very simple version of 9 point mobile lock. Everything works fine on the desktop but on mobile it selects only the first point and does nothing while dragging. There is alert at the drag end that shows the combination you selected, and that fires correctly on the dragend event. So I suppose dragstart and dragend are fine, but drag isn't .

I seen above someone said it woud be good to fix after version1, which is a little surprising, I mean ionic is framework for hybrid apps, I would think that touch events would be among the highest priorities...

You can clone the repo here: https://github.com/Tomino2112/ionic-mobile-lock I didn't do almost anything with it, so simply add platform (android) and build.

I have been testing it on Nexus 5, Android 5.0.1

@SashaGeekette
Copy link

@Tomino2112 You may want to see if using mnTouch for those gestures will fix the issue for now, as it worked with our issue with onhold

@madgrizzle
Copy link

mn-touch worked as a replacement for on-swipe-left and on-swipe-right for me and my 4.4.4 phone. Was very easy to implement as a replacement (add mn dependency, add mn-touch to the element and change on-swipe-right and on-swipe-left to swipe-right and swipe-left, respectively). Vertical scrolling of my overflow-scroll list was unaffected.

@Tomino2112
Copy link

@SashaGeekette I don't really see easy way to implement mntouch, it takes care of swiping, but I really need dragging.

@adamdbradley adamdbradley modified the milestones: 1.0.0-rc0, 1.1 Feb 9, 2015
@adamdbradley
Copy link
Contributor

@rafaellop I'm sorry but I'm not seeing the differences in you codepen examples.

@adamdbradley
Copy link
Contributor

Please give the nightly build a test to see if it fixes your issues with this fix: a5881ea

@Tomino2112
Copy link

I can test it couple of hours

@Tomino2112
Copy link

Ok, I am happy to tell you that the drag event is being triggered correctly now. BUT there is still problem that is fatal for my app. After a lot of debugging I noticed that the event target doesn't change while dragging.

This means if I have a div with .class1 and another div with .class2 when I drag over from .class1 to .class2 , the target of the event is still .class1 (drag event is attached to the parent of these two)

What I do in my script is on every drag fire I check "does the e.target=.class2 element?" if yes, do something, if not, ignore.

This sounds to me like some bug in HammerJS?

By the way I checked the e.gesture.target, same thing

Works fine on desktop.

@MartinMa
Copy link

👍 Thanks! @adamdbradley 's patch fixes the touchcancel issue for me too! It appeared after I updated a Samsung Galaxy Tab 3 device to Android 4.4.2 (from 4.0 something).

The first touchmove event (drag respectively) was fired reliably, but immediately followed by touchcancel, which results in a release event by the ionic-ified hammer.js implementation.

@Fayozjon
Copy link

Ildar

http://zag-zag.ru/klient

25.03.2015, 11:50, "Ildar Kayumov" notifications@github.com:Hi, i'm using Ionic Version: 1.0.0-rc.0. It's good working on web, but when i run on real device app didn't show swipe animation, but swipe is working. Maybe i didn't understand the swipe animation process on Android and it didn't show that animation on Android.

For example,
No swipe/default state -
With swipe animation -

You can repeat that using only browser Google Chrome:

  1. open
  2. open development tools - Shift+Ctrl+I
  3. click on mobile icon on top left corner -
  4. select any Android device, for example: nexus 5
  5. reload page
    Then i can't see swipe animation. It didn't repeats with WP or iOs - they are working normal. The same bug on real Android device. Do any have the same problem?

Thank you.

—Reply to this email directly or .

@abeninski
Copy link

on-release is not working for me guys.
It is fired when moving my finger a little without releasing.

@MartinMa
Copy link

Hey, I think there was a regression regarding the fix above with this commit from 19 Mar.

Maybe @perrygovier can have a look into this? What exactly do you mean by "Prevent gestures from breaking native scrolling"? Is there a use/test case? I could't find a related issue.

@abeninski There is a work around. You have to pass {prevent_default_directions = ['left', 'up', 'right', 'down']} as fourth argument to $ionicGesture.on.

edit: Here is a codepen that demonstrates the issue: http://codepen.io/MartinMa/pen/vOEmVR

To get it up and running on your Android device, run the following commands using Ionic CLI.

ionic start dragtest http://codepen.io/MartinMa/pen/vOEmVR
cd dragtest
ionic platform add android
ionic run android

@gregor-srdic
Copy link

I have also encountered a problem with "on-hold" not working on galaxy S6 android 5.0.2
In web browser and in emulator android 4.4.2 it works no problem

<a class="button" ng-class="..." ng-click="doStuffOnClick()" on-hold="doStuffOnHold()"></a> doStuffOnHold function is not invoked on the devicewith android 5.0.2

my ionic cli is version 1.3.22 though the current project was created with one of the earlier versions

@MartinMa
Copy link

MartinMa commented May 5, 2015

Please reopen this issue or should a new one be created?

@perrygovier
Copy link
Contributor

Please open a new issue, this is different enough from the original issue.

@manugb
Copy link

manugb commented Jun 11, 2015

On-hold events sometimes is not working, testing with motog android 5.0.1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests