Multitouch touchEvents not triggered as they should on Safari Mobile - javascript

I have various touchEvents detection on a page on Safari Mobile (a controller, if you want to know...). They all work well indepedantly, but whenever I have a first touchpoint pressed, If I touch a new point, the events are triggered when I trigger a new one.
For example :
I hold the stick with a finger. It's not moving
I press a button, a touchStart event should be triggered but is not
If I move the stick, the touchStart event is triggered
If I let go of the button, the touchStart is triggered, but not the touchEnd
If I move the stick (touchMove), the touchEnd is triggered
You understand how in my case it's a problem. I get buttons triggered with delay, or getting stuck until I move the stick, etc...
Is there a workaround ? thanks

Related

Triggering action if user canceled touch on mobile device

I have a situation where I need to track if a user has cancelled a touch on a mobile device. I thought it would be pretty easy with touch events, but I've been stuck on it for two days now. Here's what I've been experimenting with:
$("#element)
.bind('touchstart', function() {
action1();
})
.bind('touchcancel', function() {
action2();
})
.bind('touchend', function() {
action3();
})
touchstart and touchend work fine, but touchcancel never runs. Even if I release my finger outside the element, the touchend action will run but not touchcancel.
Have you tried dragging your finger off the edge of the display panel? That used to cause a touchcancel on older android phones.
Edit: The touchcancel happens when the system needs to cancel the touch so you might experiment with application- or OS-initiated behavior that could interrupt what the user is doing. Some examples that might cause this
Receive an onscreen notification, like an incoming call
Modify the dom so the element that was the focus of the touchstart is rerendered in a different location
Remove the dom element that was the focus of the touchstart

Javascript/JQuery - Controlling the iOS keypad

Based on my previous post where I attempt to fire off an event before the keypad opens on iOS, I am using the "touchstart" option to fire off an event.
Fire Event before 'focus' kicks in / Fire Event before keyboard appears on iOS
This works great, but when the device is slightly delayed the touchstart doesn't fire quick enough before the blur so the keyboard appears before the code is fired which is a major issue (we are working around the position: fixed;) issue.
My question is this:
Is there any way to control the keypad? Adding a timer or anything (even a code break) on the touchstart doesn't stop the keypad appearing on blur (when the touch is removed).
Thank you!

Does buttons and links increase mobile responsivness?

I am curious about this one. Does creating a div imitating a button (with 'click' event binded to it) is user-friendly? I mean, does all mobile browsers accurately treat it and always fire event when div is clicked?
Does replacing such constructions with normal buttons increases responsivness on mobile devices?
Google describes this pretty well i think here.
So as described there, handling the click event adds a 300ms delay because it is waiting to see if it is a double-tap.
The technique involves a bit of JavaScript that allows the button to
respond to touchend events rather than click events. Touchend events
are fired with no delay so this is significantly faster than click
events, however there are a few problems to consider:
If the user tapped somewhere else on the screen and then invokes a
touchend on the button then we should not fire a click.
If the user touches down on the button and then drags the screen a bit and then
invokes a touchend on the button then we should not fire a click.
We want to highlight the button when the user touches down to give it a
pressed state.
We can solve the first two problems by monitoring touchstart and touchmove events as well.
We should only consider a touchend on the button if there was previously a touchstart on the button. Also if there exists a touchmove anywhere that goes past a
certain threshold from the touchstart then we should not handle the
touchend as a click.
We can solve the third problem by adding an onclick handler to the
button as well. Doing so will allow the browser to properly treat it
as a button, and our touchend handler will ensure that the button is
still fast. Also, the presence of an onclick handler serves as a good
fallback for browsers that don’t support touch events.
Another advice from experience would be to avoid anchors for buttons.
They recommend using Touchend instead of click.

Two pages grabbing click event on iPad

I have a website I have written which is cross platform. On the iPad I have to use the mouseup and mouseup events to simulate a click (because it is events imbedded within SVG inside an iFrame and there are special events if someone presses and holds, or presses and drags or presses and releases (clicks))
Here is what is happening.
touchStart event triggered.
touchEnd event triggered.
My script sees that this is a click event and then triggers the following event:
window.parent.window.location.href = "../TRL/SelectHotspot.aspx" + returnString
The browser then goes to that page, but then (strange this...) the control that is in that exact position on the target page recieves a click event. This means that it then moves onto the next page.
Does anyone know what would cause this and how to stop it please? It doesn't happen on desktops (they don't expose the touchstart / touchend event anyway) and not on any android devices.

Click Event makes jQuery Mobile very slow on Mobile Devices - What is the easiest way to unbind Click event and add 'Tap' events?

I've scoured the internet for this answer and been unsuccessful.
Mobile devices are by default slower using the 'click' event because it continues to listen for other types of gestures, such as the double click, scroll, click and hold, etc. Hence, jquery mobile is slow and unresponsive when trying to expand a collapsible list using 'Click'. It delays about .5 second before triggering.
What is the easiest way that I can unbind 'Click' events from these elements and bind the 'tap' event to perform the SAME action?
My plan is to detect if the device is mobile, and if yes, then add the Tap event and thus making the site more responsive.
THANKS!

Categories

Resources