Open develth opened 10 years ago
How about this? I've managed to make links clickable. But it works only when onClick event is set. Still working on it.
function touchstart(event) {
var touches = event.originalEvent.touches;
var touchedObject = touches[0].target;
if (touchedObject.nodeName=='A'){
$(touchedObject).click();
event.preventDefault();
return 0;
}
if(!(
typeof($._data(touchedObject, "events")) !== 'undefined'
&& $._data(touchedObject, "events").click != null
|| touchedObject.nodeName == 'A'
)){
startX = touches[0].pageX;
startY = touches[0].pageY;
$this.bind('touchmove', touchmove);
}
event.preventDefault();
}
Fixed!
function touchstart(event) {
var touches = event.originalEvent.touches;
var touchedObject = touches[0].target;
if (touchedObject.nodeName=='A'){
$(touchedObject).click();
return 1;
}
if(!(
typeof($._data(touchedObject, "events")) !== 'undefined'
&& $._data(touchedObject, "events").click != null
|| touchedObject.nodeName == 'A'
)){
startX = touches[0].pageX;
startY = touches[0].pageY;
$this.bind('touchmove', touchmove);
}
event.preventDefault();
}
Works great, thanks! But only if the click event is on a 'A' node.
yes. i think we should check all the list of clickable items. I didn't test it with input or select tags. If it's problem, it can be solved the same way
If you have a touch device & click and do not move on an empty space, and then do a touchmove, the pages changes for the amount of times you clicked. On Touch only. I used some onClick function and they didn´t worked, but the pages changed for the amount of onclick.
I added this work around for using onClick methods, but if you click on a "not onClick", it stills do the pagechange bug.
This is my function change: