Fix for touch event coordinates.
This commit is contained in:
@@ -63,14 +63,34 @@ import flash.Lib;
|
||||
|
||||
if (window != null && window.element != null) {
|
||||
|
||||
var rect = window.element.getBoundingClientRect ();
|
||||
eventInfo.x = (touch.pageX - rect.left) * (window.width / rect.width);
|
||||
eventInfo.y = (touch.pageY - rect.top) * (window.height / rect.height);
|
||||
if (window.canvas != null) {
|
||||
|
||||
var rect = window.canvas.getBoundingClientRect ();
|
||||
eventInfo.x = (touch.clientX - rect.left) * (window.width / rect.width);
|
||||
eventInfo.y = (touch.clientY - rect.top) * (window.height / rect.height);
|
||||
|
||||
} else if (window.div != null) {
|
||||
|
||||
var rect = window.div.getBoundingClientRect ();
|
||||
//eventInfo.x = (event.clientX - rect.left) * (window.div.style.width / rect.width);
|
||||
eventInfo.x = (touch.clientX - rect.left);
|
||||
//eventInfo.y = (event.clientY - rect.top) * (window.div.style.height / rect.height);
|
||||
eventInfo.y = (touch.clientY - rect.top);
|
||||
|
||||
} else {
|
||||
|
||||
var rect = window.element.getBoundingClientRect ();
|
||||
eventInfo.x = (touch.clientX - rect.left) * (window.width / rect.width);
|
||||
eventInfo.y = (touch.clientY - rect.top) * (window.height / rect.height);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
eventInfo.x = touch.pageX;
|
||||
eventInfo.y = touch.pageY;
|
||||
eventInfo.x = touch.clientX;
|
||||
eventInfo.y = touch.clientY;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user