vthunder70
asked on
Using the on() jquery method to attach the "touchstart" event but need to get to screenX
Hi experts,
I'm binding a "touchstart" event to a DOM element. Basically I want to be able to scroll a <ul> based on the user swiping his/her finger on the screen.
To do this I need to get to the screenX and screenY of the touch event. This properties are inside a of a touches array inside a TouchEvent Obj.
How can I get to this properties???
as of now I just want to console.log it so I can see that is working!
I'm attaching an image of the loop that I'm doing for the event obj with arrows showing the data I want to get at
I was thinking I could get to screenX this way:
I'm binding a "touchstart" event to a DOM element. Basically I want to be able to scroll a <ul> based on the user swiping his/her finger on the screen.
To do this I need to get to the screenX and screenY of the touch event. This properties are inside a of a touches array inside a TouchEvent Obj.
How can I get to this properties???
as of now I just want to console.log it so I can see that is working!
//this code logs all the properties of the event
//on the attached file you will see where I want to get at
node.on('touchstart click', function(event){
event.preventDefault();
for (var prop in event){
console.log(event[prop]);
}
});
I'm attaching an image of the loop that I'm doing for the event obj with arrows showing the data I want to get at
I was thinking I could get to screenX this way:
//but this doesn't work at all..
console.log(event.touches[0].screenX);
objConsoleLogImg.jpg
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
check this file : http://code.jquery.com/jquery-1.10.2.js
You can locate :
This come from jQuery itself, gage of browser compatibility isn't?
You can locate :
// Create a writable copy of the event object and normalize some properties
var i, prop, copy,
type = event.type,
originalEvent = event,
fixHook = this.fixHooks[ type ];
This come from jQuery itself, gage of browser compatibility isn't?
ASKER
I don't understand why they are doing that but I guess that is not the question here... so Thanks you!
ASKER
I have been deep in google for 2 days and this is the first I hear about it.
many thanks,