#1253 new
qrizly

Event.PointerX and Event.PointerY doesnt work on mobile safari (iphone/ipad)

Reported by qrizly | May 27th, 2011 @ 01:46 PM

I changed the following pointerX and pointerY function to give me an usable position.
I am not sure how to create a test for this case if somebody can give pointers to do so i will try that

  function pointerX(event) {
    var docElement = document.documentElement,
     body = document.body || { scrollLeft: 0 };

    if (event.changedTouches) return (event.changedTouches[0].clientX +
      (docElement.scrollLeft || body.scrollLeft) -
      (docElement.clientLeft || 0));

    return event.pageX || (event.clientX +
      (docElement.scrollLeft || body.scrollLeft) -
      (docElement.clientLeft || 0));
  }

  function pointerY(event) {
    var docElement = document.documentElement,
     body = document.body || { scrollTop: 0 };

    if (event.changedTouches) return (event.changedTouches[0].clientY +
      (docElement.scrollLeft || body.scrollLeft) -
      (docElement.clientLeft || 0));

    return  event.pageY || (event.clientY +
       (docElement.scrollTop || body.scrollTop) -
       (docElement.clientTop || 0));
  }

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Prototype JavaScript library.

Shared Ticket Bins

People watching this ticket

Pages