jquery-archive / jquery-mobile

jQuery Mobile Framework
https://jquerymobile.com
Other
9.69k stars 2.41k forks source link

Tap event issues and possible fix: HTC Hero, Android 2.1 #280

Closed rodo61 closed 13 years ago

rodo61 commented 13 years ago

Hi,

I load the demo (http://jquerymobile.com/demos/1.0a1/) on my HTC Hero (android 2.1). Then I touch the "Intro to jQuery Mobile" button. The page loads. Then the back button does not work. I have to use the hardware back button. That works. The same with "Features" and other buttons like "Toolbars". It seems as if the back button doesn't work on HTC Hero, Android 2.1

I wrote a sample app (http://speibl.com/jquerymobile/test01/). The same here. The back button doesn't work.

Firmware-Version: 2.1-update1 Browser-Version: WebKit 3.1

Tell me if you need need more information (build-number or other).

Regards, Rolf

depeele commented 13 years ago

This also occurs on a Nexus 1 with Android 2.2.

Seems to be an issue with the implementation of the 'tap' event, which the 'back' button requires. The 'tap' event is a combination of the 'touchStart', 'touchMove', and 'touchEnd' events. If there's movement registered between start and end, a 'tap' is not triggered. On the Nexus 1, any movement (even a single pixel) triggers touchMove and results in no triggering of a 'tap' event.

One fix is to require a specific delta in the movement before it effects the overall event. That can be added in the 'touchStart' handler of the 'tap' event around line 68 of jquery.mobile.event.

rodo61 commented 13 years ago

Thanks for the information.

I'll try to fix this so that I can go on testing with my smartphone. Can you tell me how to access the movement informations/coordinates.

Will this be fixed in coming versions?

Thanks, Rolf

depeele commented 13 years ago

The quick hack that I'm current using -- around line 65 of jquery.mobile.event.js, $.event.special.tap, in the bind callback for touchStartEvent: var moved = false, touching = true, origPos = [ event.pageX, event.pageY ], originalType, timer;

            function moveHandler() {
                if ((Math.abs(origPos[0] - event.pageX) > 10) ||
                    (Math.abs(origPos[1] - event.pageY) > 10)) {
                    moved = true;
                }
            }

Hope that helps.

rodo61 commented 13 years ago

Elmo, you made my day!! It works. That tap-event is the troublemaker :-) I hope it will be fixed in the next version. Thanks a lot, Rolf

golov commented 13 years ago

We had an issue with android not clicking, and while Elmo's fix sorts it out, it created another issue that it would click everything, even when you're trying to drag. In the end the issue was fixed with by changing:

Link name <a href='whatever'></a>

to:

<a href='whatever'>Link name</a>

Don't know why it was like that in the first place, but that's a possible reason for Android not clicking.