Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Swipe is buggy on Chrome/Android #5534

Open
dzhongxu opened this issue Jan 26, 2013 · 108 comments
Open

Swipe is buggy on Chrome/Android #5534

dzhongxu opened this issue Jan 26, 2013 · 108 comments

Comments

@dzhongxu
Copy link

A panel should be closed when users swipe left or right. But this function does not work in Galaxy S1 and S3 for 1.3.0 beta.

@jaspermdegroot
Copy link
Contributor

@dzhongxu

Do you mean swipe on the panel or on the page? The latter has been added after 1.3 beta 1 so that works with latest code. Haven't noticed issues with that on Android.

Closing as fixed. If you still see an issue, please comment and provide a test page. Also, include information about Android version, jQuery core version, etc.. See the contributing guidelines.

@dzhongxu
Copy link
Author

The panel is not closed when swipe both on the panel and page. Only closed
when touch the page. It seems the swipe event is not captured.

On Sat, Jan 26, 2013 at 1:21 AM, Jasper de Groot
notifications@github.comwrote:

@dzhongxu https://github.com/dzhongxu

Do you mean swipe on the panel or on the page? The latter has been added
after 1.3 beta 1 so that works with latest code. Haven't noticed issues
with that on Android.

Closing as fixed. If you still see an issue, please comment and provide a
test page. Also, include information about Android version, jQuery core
version, etc.. See the contributing guidelineshttps://github.com/jquery/jquery-mobile/blob/master/CONTRIBUTING.md#issues
.


Reply to this email directly or view it on GitHubhttps://github.com//issues/5534#issuecomment-12733094.

@dzhongxu
Copy link
Author

The panel is not closed when swipe both on the panel and page. Only closed when touch the page. It seems the swipe event is not captured in Android.

Testing page:
http://jquerymobile.com/demos/1.3.0-beta.1/docs/panels/index.html

@dzhongxu
Copy link
Author

Testing page:
http://jquerymobile.com/demos/1.3.0-beta.1/docs/panels/index.html

On Sat, Jan 26, 2013 at 10:54 AM, Xu Zhong dzhongxu@gmail.com wrote:

The panel is not closed when swipe both on the panel and page. Only closed
when touch the page. It seems the swipe event is not captured.

On Sat, Jan 26, 2013 at 1:21 AM, Jasper de Groot <notifications@github.com

wrote:

@dzhongxu https://github.com/dzhongxu

Do you mean swipe on the panel or on the page? The latter has been added
after 1.3 beta 1 so that works with latest code. Haven't noticed issues
with that on Android.

Closing as fixed. If you still see an issue, please comment and provide a
test page. Also, include information about Android version, jQuery core
version, etc.. See the contributing guidelineshttps://github.com/jquery/jquery-mobile/blob/master/CONTRIBUTING.md#issues
.


Reply to this email directly or view it on GitHubhttps://github.com//issues/5534#issuecomment-12733094.

@jaspermdegroot
Copy link
Contributor

@dzhongxu

Same page, latest code: http://jquerymobile.com/test/docs/panels/index.html
A swipe left on the panel or the page should close the left panel. Swipe right for right panel.
Can you still reproduce it?
Also, what Android version?

@dzhongxu
Copy link
Author

I can still reproduce it in Android 2.3.0 Galaxy S3 and 2.3.6 Galaxy S1.
On Sat, Jan 26, 2013 at 11:01 AM, Jasper de Groot
notifications@github.comwrote:

@dzhongxu https://github.com/dzhongxu

Same page, latest code:
http://jquerymobile.com/test/docs/panels/index.html
A swipe left on the panel or the page should close the left panel. Swipe
right for right panel.
Can you still reproduce it?
Also, what Android version?


Reply to this email directly or view it on GitHubhttps://github.com//issues/5534#issuecomment-12740192.

@dzhongxu
Copy link
Author

Sorry for Galaxy S3. It is Android 4.1.1.

On Sat, Jan 26, 2013 at 11:14 AM, Xu Zhong dzhongxu@gmail.com wrote:

I can still reproduce it in Android 2.3.0 Galaxy S3 and 2.3.6 Galaxy S1.

On Sat, Jan 26, 2013 at 11:01 AM, Jasper de Groot <
notifications@github.com> wrote:

@dzhongxu https://github.com/dzhongxu

Same page, latest code:
http://jquerymobile.com/test/docs/panels/index.html
A swipe left on the panel or the page should close the left panel. Swipe
right for right panel.
Can you still reproduce it?
Also, what Android version?


Reply to this email directly or view it on GitHubhttps://github.com//issues/5534#issuecomment-12740192.

@jaspermdegroot
Copy link
Contributor

Just tested http://jquerymobile.com/test/docs/panels/index.html on a Galaxy Nexus running Android 4.1.1 and I don't see any issue.

Does swipe work on your device if you test these demos?
swipe to open panel: http://jquerymobile.com/test/docs/demos/demos/panels/panel-swipe-open.html
swipe to nav between pages: http://jquerymobile.com/test/docs/demos/demos/swipe/newyork.html

@dzhongxu
Copy link
Author

No. The swipe does not work in those two links, on Android S1 and Android
S3.

On Sat, Jan 26, 2013 at 12:14 PM, Jasper de Groot
notifications@github.comwrote:

Just tested http://jquerymobile.com/test/docs/panels/index.html on a
Galaxy Nexus running Android 4.1.1 and I don't see any issue.

Does swipe work on your device if you test these demos?
swipe to open panel:
http://jquerymobile.com/test/docs/demos/demos/panels/panel-swipe-open.html
swipe to nav between pages:
http://jquerymobile.com/test/docs/demos/demos/swipe/newyork.html


Reply to this email directly or view it on GitHubhttps://github.com//issues/5534#issuecomment-12741431.

@jerone
Copy link
Contributor

jerone commented Jan 26, 2013

I just tested all links above on Samsung Galaxy S3 (Android 4.1.2) on the native browser and aldo all swipes work, it's very hard en not consistent, I had to try multiple times in most cases.
For example on the image demo, if I do multiple swipes in the same direction and same way, some times it doesn't work. I couldn't find any reason why.

I also tested it on Chrome, Chrome beta, Firefox, Firefox beta and Opera Mobile, I had no issues with the swipes.
Opera Mini didn't work, but I expected that.

@jaspermdegroot
Copy link
Contributor

I changed the title of this ticket because it is not a panel issue but a swipe problem.

Swipe doesn't work on:
Samsung Galaxy S1 / Android 2.3.6
Samsung Galaxy S3 / Android 4.1.1

Issue cannot be reproduced on:
Samsung/Google Galaxy Nexus / Android 4.1.1

test pages:
swipe to close panel: http://jquerymobile.com/test/docs/panels/index.html
swipe to open panel: http://jquerymobile.com/test/docs/demos/demos/panels/panel-swipe-open.html
swipe to nav between pages: http://jquerymobile.com/test/docs/demos/demos/swipe/newyork.html

@jaspermdegroot
Copy link
Contributor

@jerone

Thanks!
Was closing the panel buggy too?
What Android version is your S3 running? Also 4.1.1?

@dzhongxu
Copy link
Author

http://www.photoswipe.com/latest/examples/04-jquery-mobile.html#&ui-state=dialog

Swipe works on Galaxy S1, S3 and Note2.

On Sat, Jan 26, 2013 at 12:34 PM, Xu Zhong dzhongxu@gmail.com wrote:

No. The swipe does not work in those two links, on Android S1 and Android
S3.

On Sat, Jan 26, 2013 at 12:14 PM, Jasper de Groot <
notifications@github.com> wrote:

Just tested http://jquerymobile.com/test/docs/panels/index.html on a
Galaxy Nexus running Android 4.1.1 and I don't see any issue.

Does swipe work on your device if you test these demos?
swipe to open panel:
http://jquerymobile.com/test/docs/demos/demos/panels/panel-swipe-open.html
swipe to nav between pages:
http://jquerymobile.com/test/docs/demos/demos/swipe/newyork.html


Reply to this email directly or view it on GitHubhttps://github.com//issues/5534#issuecomment-12741431.

@jerone
Copy link
Contributor

jerone commented Jan 26, 2013

@uGoMobi

Yeah every swipe action was buggy. In the end the action always executed, but I had to try multiple times before it worked.

@uGoMobi, @dzhongxu
Confirmed that link works (jQM 1.0 😢 )

@jaspermdegroot
Copy link
Contributor

Thanks again @jerone !

I changed the title again... from broken to buggy.

Not sure if that PhotoSwipe demo is a good reference, because I would have to see their code if they modify anything. But if swipe works better on that demo with JQM 1.0rc2 than with latest code we should check if this is a regression.

@dzhongxu
Copy link
Author

After testing a couple of swipe apps. Even In old version, the swipe is
buggy on Android. But they work on iPhone.

1.1.1 is buggy. Check this one:
http://www.moretechtips.net/2012/07/building-web-presentations-using-jquery.html

The 1.2.0 is also buggy. Check this one:
http://lazcreative.com/blog/how-to/how-to-adding-swipe-support-to-bootstraps-carousel/

On Sat, Jan 26, 2013 at 1:48 PM, Jasper de Groot
notifications@github.comwrote:

Thanks again @jerone https://github.com/jerone !

I changed the title again... from broken to buggy.

Not sure if that PhotoSwipe demo is a good reference, because I would have
to see their code if they modify anything. But if swipe works better on
that demo with JQM 1.0rc2 than with latest code we should check if this is
a regression.


Reply to this email directly or view it on GitHubhttps://github.com//issues/5534#issuecomment-12742957.

@dzhongxu
Copy link
Author

Hi Jerone,

Have you fixed the bug?

I met a difficulty to change the width of the panel. I simply set the width
of the panel with css but it makes the panel always showing. Can you show
me how to override the panel width with css?

Thanks a lot?

David

On Sat, Jan 26, 2013 at 1:48 PM, Jasper de Groot
notifications@github.comwrote:

Thanks again @jerone https://github.com/jerone !

I changed the title again... from broken to buggy.

Not sure if that PhotoSwipe demo is a good reference, because I would have
to see their code if they modify anything. But if swipe works better on
that demo with JQM 1.0rc2 than with latest code we should check if this is
a regression.


Reply to this email directly or view it on GitHubhttps://github.com//issues/5534#issuecomment-12742957.

@arschmitz
Copy link
Contributor

testing on http://jsbin.com/uzaret/891 swipe works perfectly and very responsive on all devices test this includes.
Samasung Galaxy S3 4.1
Samsung Galaxy S2 4.1
Samasung Galaxy S1 2.3.5
Samsung Galaxy Note2 4.1
LG Optimus 2.2
HTC Thunderbolt 4g 2.3.7
HTC Incredible 2.3.4
Motorola Xoom 4.0
Nokia Lumia 520 WP8
iPhone 4 ios5
iPhone 4 ios6
iPhone 5 ios6
iPad 2 ios 5
iPad 2 ios 6
Blacberry 10
Blackberry Playbook
Closing this as Fixed on master

@jyohere
Copy link

jyohere commented Jul 13, 2013

Swiping is not working properly when we use Jquery Mobile on Android and Windows devices. Swiping is not smooth or sometimes it does not work at all.

$(document).off('swipeleft swiperight','.test')
.on('swipeleft swiperight','.test', function(event) {

swipe(event);
});
.test - refers to a div class.

Please help. And, what is the problem in JQM, even it is not working on Samsung galaxy S4 native browser. Is there any easy way to achieve this.

This is not panel Swipe. This is swipe of a div section in a page. Am using jqm 1.3.1. If there is any fix, please let me know how should i incorporate this fix.

@agentfitz
Copy link

I am also noticing very inconsistent swiping behavior on my android device (Galaxy Nexus) running Chrome mobile. Swiping almost always takes 2-5 attempts before the event finally triggers. I even noticed this behavior on the jquery mobile swipe demo page: http://jquerymobile.com/demos/1.3.0-beta.1/docs/demos/swipe/newyork.html

the swiping is 100% consistent and smooth on my iOS test devices such as an iPhone 4.

@arschmitz
Copy link
Contributor

@agentfitz you are trying an old beta version on a demo thats not something thats actually part of the library to test please try the jsbin in my previous comment

@agentfitz
Copy link

Hi there, thank you for the response. I just visited the page referenced in your post: http://jsbin.com/uzaret/891

But I'm not quite sure what the demo is. I tried swiping on the page and nothing happened. I then drilled down on jquerymobile.com/test and went to the demo showcase where I eventually found the "swipe to navigate" and "swipe to delete list item" demos. I wasn't able to get either of them to behave as I expected using swiping.

Did I go to the wrong place?

@arschmitz
Copy link
Contributor

@agentfitz on that page simply swipe left or right and it throws an alert "swipeleft" or "swiperight" just tested on additional devices
HTC Desire S 4.0
Motorola Atrix 2 4.0
Samsung Galaxy S4 4.2.2
Samsung Galaxy Nexus 4.2.2
LG Nexus 4 4.2.2
Firefox OS

@agentfitz
Copy link

I understand Alexander. I was on 1.3.1 and the swipe was misbehaving, but when I looked at the source on your demo page and switched my app to the "latest" jquerymobile code, the swipe worked perfectly. Being in a pre-release state though, it did break some other stuff on me, such as formatting of controlgroups and such.

Anyway, really pleased this will be fully addressed in an upcoming release! Thank you for your help.

@TNT-RoX
Copy link

TNT-RoX commented Jul 1, 2014

My team of engineers and I have come up with a proof-of-concept shim that provides a workaround for this issue. https://github.com/TNT-RoX/android-swipe-shim

@TNT-RoX
Copy link

TNT-RoX commented Aug 4, 2014

@simonpapworth6742
Copy link

Chrome 36 has resolved this issue for me, anybody else?

@arschmitz
Copy link
Contributor

@simonpapworth6742 yes they changed their thinking again on this. Talked with the head of web input at google a bit about this today and they are moving towards synchronous event processing in chrome for touch and scroll and have gone back on the idea of touch cancel. This fixes this problem in chrome.

@RByers
Copy link

RByers commented Aug 28, 2014

Note that prior to Chrome 36 the recommended way to address this problem is to check the direction of movement on the first touchmove event and decide based on that whether to call preventDefault(). I.e. if the touchstart->touchmove distance is primarily horizontal than preventDefault the touchmove to continue to get events and trigger a swipe. If it's primarily vertical then don't call preventDefault and you'll get scrolling instead. Many sites follow this pattern, and it's sometimes necessary on browsers other than just Chrome (eg. in Safari if horizontal scrolling is possible, and now in IE mobile if you're using touch events instead of pointer events, possibly also in Firefox).

In Chrome 36+ as you've discovered you can use 'touch-action: pan-y' to make this simpler (although you still have to be careful to handle events only in the horizontal direction). You may also get away with handling the events without calling preventDefault or using touch-action, but it's probably not going to do exactly what you want in all cases. Eg. try swiping horizontally then changing directions and moving vertically - once you've started handling the swipe you probably don't want to allow vertical scrolling anymore, right?

@arschmitz
Copy link
Contributor

@RByers we only support horizontal swipe. Scrolling during swipe in the vertical direction we really are ok with either way and would prefer to leave this up to the devs where possible since this is just a generic event like click. so if it should block scrolling or not would depend on the developers specific use case for the event. This is why the touchcancel event handling here was troublesome it forced us to pick scrolling vs swipe even when the desired effect had no need to block but may just be recording that the event occurred.

In general in apps made with jQuery mobile horizontal scrolling does not exist and would not be desirable this means that touch-action did fix this issue for the majority of situations. However the behavior in Chrome 36+ allows us to once again avoid making these decisions for the developers and just provide a generic event as we intended.

@RByers Thanks for sharing the background from the Chrome team!

@RByers
Copy link

RByers commented Aug 28, 2014

Great, that's exactly why I pushed on this change - I'm glad it has worked for you!

Note that most browsers still require you to make some choice between scrolling and event handling - eg. even in Chrome 36+ if active scrolling actually occurs (i.e. it is scrollable horizontally) we'll start throttling the touchmove events to ensure scrolling remains smooth. In Safari once scrolling has started you won't receive the touch events at all. But the key thing here is that in both cases it depends on scrolling actually occurring - if the page doesn't scroll horizontally then you'll get a reliable event stream.

FWIW I just wrote a demo of the simple scenario (where relying on preventDefault is OK) here: https://plus.sandbox.google.com/u/3/+RickByers/posts/Ad5wGCceU2e

@simonpapworth6742
Copy link

Hi Rick,

Thank you, Chrome 36 did arrive 24 hours later (I had no Idea that it was coming) and JQuery Mobile Swipe is working again, and luckily for me touch events are handled by JQM for me mostly.

Also thank you for your “RE: Web facing change PSA: touch scrolling will no longer send touchcancel in Chrome 35” email, I am today looking at Touch Cancel to see if JQM does correctly use it.

Again thank you

SImon

From: Rick Byers [mailto:notifications@github.com]
Sent: 28 August 2014 01:09
To: jquery/jquery-mobile
Cc: simonpapworth6742
Subject: Re: [jquery-mobile] Swipe is buggy on Chrome/Android (#5534)

Note that prior to Chrome 36 the recommended way to address this problem is to check the direction of movement on the first touchmove event and decide based on that whether to call preventDefault(). I.e. if the touchstart->touchmove distance is primarily horizontal than preventDefault the touchmove to continue to get events and trigger a swipe. If it's primarily vertical then don't call preventDefault and you'll get scrolling instead. Many sites follow this pattern, and it's sometimes necessary on browsers other than just Chrome (eg. in Safari if horizontal scrolling is possible, and now in IE mobile if you're using touch events instead of pointer events, possibly also in Firefox).

In Chrome 36+ as you've discovered you can use 'touch-action: pan-y' to make this simpler (although you still have to be careful to handle events only in the horizontal direction). You may also get away with handling the events without calling preventDefault or using touch-action, but it's probably not going to do exactly what you want in all cases. Eg. try swiping horizontally then changing directions and moving vertically - once you've started handling the swipe you probably don't want to allow vertical scrolling anymore, right?


Reply to this email directly or view it on GitHub #5534 (comment) . https://github.com/notifications/beacon/4234429__eyJzY29wZSI6Ik5ld3NpZXM6QmVhY29uIiwiZXhwaXJlcyI6MTcyNDgwMzc0MCwiZGF0YSI6eyJpZCI6NjQ4MDA4Nn19--b544503ac3b7c92d9331c9a552cd6a0db4a8628b.gif

@simonpapworth6742
Copy link

Thank you

From: Alexander Schmitz [mailto:notifications@github.com]
Sent: 28 August 2014 01:34
To: jquery/jquery-mobile
Cc: simonpapworth6742
Subject: Re: [jquery-mobile] Swipe is buggy on Chrome/Android (#5534)

@RByers https://github.com/RByers we only support horizontal swipe. Scrolling during swipe in the vertical direction we really are ok with either way and would prefer to leave this up to the devs where possible since this is just a generic event like click. so if it should block scrolling or not would depend on the developers specific use case for the event. This is why the touchcancel event handling here was troublesome it forced us to pick scrolling vs swipe even when the desired effect had no need to block but may just be recording that the event occurred.

In general in apps made with jQuery mobile horizontal scrolling does not exist and would not be desirable this means that touch-action did fix this issue for the majority of situations. However the behavior in Chrome 36+ allows us to once again avoid making these decisions for the developers and just provide a generic event as we intended.

@RByers https://github.com/RByers Thanks for sharing the background from the Chrome team!


Reply to this email directly or view it on GitHub #5534 (comment) . https://github.com/notifications/beacon/4234429__eyJzY29wZSI6Ik5ld3NpZXM6QmVhY29uIiwiZXhwaXJlcyI6MTcyNDgwNTI0NiwiZGF0YSI6eyJpZCI6NjQ4MDA4Nn19--4f042b8e1ca8b2440b34792b73d2a44c8b8e2b7c.gif

arschmitz pushed a commit that referenced this issue May 28, 2015
Fixes swipe events for all pixel densities.
This is a partial fix for some swipe related issues.

Ref gh-5534
closes gh-7431
@dpa99c
Copy link

dpa99c commented May 29, 2015

It's nice that Chrome 36 fixed this, unfortunately there's a lot of old versions of Android out there with Webviews that contain this bug, so it still affects Cordova/Phonegap apps running on older devices.
I used Hammer.js to detect the swipe gestures as a workaround.

@mrextreme
Copy link

or give Crosswalk a try

@dpa99c
Copy link

dpa99c commented May 29, 2015

Crosswalk's great but has its cons too: ~20Mb additional size on the APK and the need to build a separate package for x86 and ARM

@Carlos487
Copy link

@dpa99c but i've tried hammer.js when the issue was reported and it didn't work... There is a new version with this fix?

@dpa99c
Copy link

dpa99c commented May 29, 2015

@Carlos487 I'm using v2.0.4 of hammer with Cordova 3.1.0 and JQM 1.4.5
Testing on Android 4.4.4 and iOS 8.3 and that seems to work fine

@Carlos487
Copy link

@dpa99c I have a cordova 3.5 app with jquery mobile 1.3.2... I'm gonna try the new hammer.js thanks for the advice

@jackspaniel
Copy link

Still seeing this problem with an up-to-date S5 (AT&T) running Android native browser and Android 4.4.2. Not surprisingly angular ng-swipe-left and ng-swipe-right are also effected.

I did notice a discrepancy in the user-agent strings between Chrome and Native Browser on this device:
Chrome: ...(HTML, Like Gecko) Chrome/43.0.2357.78...
Native Browser: ...(HTML, Like Gecko) Version 1.6 Chrome/28.0.1500.94...

So apparently an up-to-date S5 is running Chrome 28 as the rendering engine in it's default browser? Note that remote debugging in the native browser seems to have died when Android switched from Apple's rendering engine to Chrome.

Unfortunately S5 is the most popular Android out there and most people still use the big Internet button by default. So even though this is Google/Samsung's problem, it's our problem.

Can anyone give me a straightforward monkey patch to get some kind of swipe to work on the old Chrome rendering engine?

Edit: I see the ez-shim above by @TNT-RoX . I am going to try that.*

Edit edit: no dice. I can only get the "swipeLeft" and "swipeRight" events to fire (using test.html) on desktop chrome - but not on either the Native Browser or Chrome on the device referenced above. Seems like el.onscroll doesn't fire at all on those browsers on the test app.

@arschmitz
Copy link
Contributor

Want to give an update here that i have been talking to @jtangler the creator of hammer.js for about 6 months about the future of Hammer.js and interoperability with jQuery Mobile. I can now say that i have officially taken over Hammer.js and am leading this project as well jQuery Mobile and we are looking into completely replacing jQuery Mobiles gestures with Hammer.js we cant say any thing concrete on this yet but it is likely we will be going in this direction.

@jackspaniel
Copy link

@arschmitz - do you have any idea if hammer.js horizontal swipe works better than jQuery Mobile or Angular swipe on Android native browser? I will give it a try on Monday when I have access.

@arschmitz
Copy link
Contributor

@jackspaniel yes i believe it does. It allows use of touch-action on platforms that don't support it like the android native browser. This makes it possible to make a proper swipe event.

@jackspaniel
Copy link

Hmm. Well if this is what creating your own proper swipe event looks like, that might be a little out of scope for us on this project. ;) I tried hacking around with that to get it to work on the latest Android native browser, and there's some pretty intense calculations and synchronicity going on.

kapilgarg1996 pushed a commit to kapilgarg1996/jquery-mobile that referenced this issue Jun 27, 2015
Fixes swipe events for all pixel densities.
This is a partial fix for some swipe related issues.

Ref jquery-archivegh-5534
closes jquery-archivegh-7431
@arschmitz arschmitz modified the milestones: 1.6.0, 1.5.0 Jun 29, 2015
@oreqizer
Copy link

Android 5.2 Galaxy S5, swipeleft works no problem, however, swiperight is buggy a lot

@RyxMedia
Copy link

Still having problems with that on Samsung Galaxy S4, Android 4.4.2.
Swipe works like 1 of 7 times :(

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

No branches or pull requests