Revert "Use offsetX and offsetY if available"

This reverts commit fabf05977a.
This commit is contained in:
Frederic Junod
2015-01-13 13:32:45 +01:00
parent c726cbfcd9
commit 0bae04331d
+6 -15
View File
@@ -607,19 +607,12 @@ ol.Map.prototype.getEventCoordinate = function(event) {
* @api stable * @api stable
*/ */
ol.Map.prototype.getEventPixel = function(event) { ol.Map.prototype.getEventPixel = function(event) {
// Use the offsetX and offsetY values if available. // goog.style.getRelativePosition is based on event.targetTouches,
// See http://www.w3.org/TR/cssom-view/#dom-mouseevent-offsetx and // but touchend and touchcancel events have no targetTouches when
// http://www.w3.org/TR/cssom-view/#dom-mouseevent-offsety // the last finger is removed from the screen.
if (goog.isDef(event.offsetX) && goog.isDef(event.offsetY)) { // So we ourselves compute the position of touch events.
return [event.offsetX, event.offsetY]; // See https://github.com/google/closure-library/pull/323
} else if (goog.isDef(event.changedTouches)) { if (goog.isDef(event.changedTouches)) {
// offsetX and offsetY are not defined for Touch Event
//
// goog.style.getRelativePosition is based on event.targetTouches,
// but touchend and touchcancel events have no targetTouches when
// the last finger is removed from the screen.
// So we ourselves compute the position of touch events.
// See https://github.com/google/closure-library/pull/323
var touch = event.changedTouches[0]; var touch = event.changedTouches[0];
var viewportPosition = goog.style.getClientPosition(this.viewport_); var viewportPosition = goog.style.getClientPosition(this.viewport_);
return [ return [
@@ -627,8 +620,6 @@ ol.Map.prototype.getEventPixel = function(event) {
touch.clientY - viewportPosition.y touch.clientY - viewportPosition.y
]; ];
} else { } else {
// Compute offsetX and offsetY values for browsers that don't implement
// cssom-view specification
var eventPosition = goog.style.getRelativePosition(event, this.viewport_); var eventPosition = goog.style.getRelativePosition(event, this.viewport_);
return [eventPosition.x, eventPosition.y]; return [eventPosition.x, eventPosition.y];
} }