views:

34

answers:

2

for some reason, i can't use jquey ,

this is my code :

document.addEventListener("touchstart", function(e) {
              e.preventDefault();
              var orig = e.originalEvent;
              var x = orig.changedTouches[0].pageX;
              var y = orig.changedTouches[0].pageY;

              //id("#draggable").css({top: y, left: x});
              id("draggable").style.left=x;
              id("draggable").style.top=y;

            });

use jquery , you can get the originalEvent , but if you don't use it ,

how to get it ,

thanks

A: 
var x = e.pageX;

If you have Safari on your desktop, open it in iPhone mode
Develop-> User Agent-> Mobile Safari...
And put a breakpoint inside your function, the you can inspect the e object and all its properties.

Mic
That doesn't really seem to answer the question to me, but the OP seems happy...
Tim Down
@Tim, I guess he took my line of code, put it in his code and it worked. While you were explaining the nature of jQuery's `originalEvent`, which he can't use here.
Mic
+1  A: 

jQuery's event object that it passes to event listener function is jQuery's own creation. Its originalEvent property is the actual Event object created by the browser, so if you attach an event listener without jQuery, the event object that is passed to your listener is exactly the same as the originalEvent property of a jQuery event object. Therefore in your example, e is precisely what e.originalEvent would point to if you'd used jQuery.

Tim Down