How to get pageX and pageY for on-tap event?


#1

Any idea how to get pageX and pageY for on-tap event?

$scope.clickEvent = function(event) {
    	console.log(event.pageX + "   " + event.pageY);
    	}

by using

on-tap="clickEvent($event)"

All I got are undefined for pageX and pageY.


#2

You need to dig into the event to get the details you want.

$scope.clickEvent = function(event) {
	$scope.data.tapX = event.gesture.touches[0].clientX;
	$scope.data.tapY = event.gesture.touches[0].clientY;
} 

#3

Hi Calendee, thanks a lot for your help. It works! But could you please tell me where I can find the official webpage about this event.gesture.touches?


#4

There are no specific documents about those details. You just need to pick through the event itself.

http://ionicframework.com/docs/nightly/api/utility/ionic.EventController/
http://ionicframework.com/docs/nightly/api/service/$ionicGesture/