Make browserEvent property public
This commit is contained in:
@@ -11,17 +11,16 @@ goog.require('ol.MapEvent');
|
||||
* @extends {ol.MapEvent}
|
||||
* @param {string} type Event type.
|
||||
* @param {ol.Map} map Map.
|
||||
* @param {goog.events.BrowserEvent} browserEventObject Browser event object.
|
||||
* @param {goog.events.BrowserEvent} browserEvent Browser event.
|
||||
*/
|
||||
ol.MapBrowserEvent = function(type, map, browserEventObject) {
|
||||
ol.MapBrowserEvent = function(type, map, browserEvent) {
|
||||
|
||||
goog.base(this, type, map);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {goog.events.BrowserEvent}
|
||||
*/
|
||||
this.browserEventObject_ = browserEventObject;
|
||||
this.browserEvent = browserEvent;
|
||||
|
||||
};
|
||||
goog.inherits(ol.MapBrowserEvent, ol.MapEvent);
|
||||
@@ -41,19 +40,10 @@ ol.MapBrowserEvent.prototype.getCoordinate = function() {
|
||||
if (goog.isDef(this.coordinate_)) {
|
||||
return this.coordinate_;
|
||||
} else {
|
||||
var browserEventObject = this.getBrowserEventObject();
|
||||
var pixel = new ol.Coordinate(
|
||||
browserEventObject.offsetX, browserEventObject.offsetY);
|
||||
var browserEvent = this.browserEvent;
|
||||
var pixel = new ol.Coordinate(browserEvent.offsetX, browserEvent.offsetY);
|
||||
var coordinate = this.map.getCoordinateFromPixel(pixel);
|
||||
this.coordinate_ = coordinate;
|
||||
return coordinate;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {goog.events.BrowserEvent} Browser event object.
|
||||
*/
|
||||
ol.MapBrowserEvent.prototype.getBrowserEventObject = function() {
|
||||
return this.browserEventObject_;
|
||||
};
|
||||
|
||||
@@ -26,8 +26,8 @@ ol.control.DblClickZoom.prototype.handleMapBrowserEvent =
|
||||
map.whileFrozen(function() {
|
||||
// FIXME compute correct center for zoom
|
||||
map.setCenter(mapBrowserEvent.getCoordinate());
|
||||
var browserEventObject = mapBrowserEvent.getBrowserEventObject();
|
||||
var scale = browserEventObject.shiftKey ? 2 : 0.5;
|
||||
var browserEvent = mapBrowserEvent.browserEvent;
|
||||
var scale = browserEvent.shiftKey ? 2 : 0.5;
|
||||
map.setResolution(scale * map.getResolution());
|
||||
});
|
||||
mapBrowserEvent.preventDefault();
|
||||
|
||||
@@ -90,14 +90,14 @@ ol.control.Drag.prototype.handleMapBrowserEvent = function(mapBrowserEvent) {
|
||||
if (!goog.isDef(center) || !goog.isDef(resolution)) {
|
||||
return;
|
||||
}
|
||||
var browserEventObject;
|
||||
var browserEvent;
|
||||
if (this.dragging_) {
|
||||
if (mapBrowserEvent.type == goog.events.EventType.MOUSEMOVE ||
|
||||
mapBrowserEvent.type == goog.events.EventType.MOUSEOUT ||
|
||||
mapBrowserEvent.type == goog.events.EventType.MOUSEUP) {
|
||||
browserEventObject = mapBrowserEvent.getBrowserEventObject();
|
||||
this.deltaX = browserEventObject.offsetX - this.startX;
|
||||
this.deltaY = browserEventObject.offsetY - this.startY;
|
||||
browserEvent = mapBrowserEvent.browserEvent;
|
||||
this.deltaX = browserEvent.offsetX - this.startX;
|
||||
this.deltaY = browserEvent.offsetY - this.startY;
|
||||
if (mapBrowserEvent.type == goog.events.EventType.MOUSEMOVE) {
|
||||
this.handleDrag(mapBrowserEvent);
|
||||
} else {
|
||||
@@ -108,9 +108,9 @@ ol.control.Drag.prototype.handleMapBrowserEvent = function(mapBrowserEvent) {
|
||||
}
|
||||
} else {
|
||||
if (mapBrowserEvent.type == goog.events.EventType.MOUSEDOWN) {
|
||||
browserEventObject = mapBrowserEvent.getBrowserEventObject();
|
||||
this.startX = browserEventObject.offsetX;
|
||||
this.startY = browserEventObject.offsetY;
|
||||
browserEvent = mapBrowserEvent.browserEvent;
|
||||
this.startX = browserEvent.offsetX;
|
||||
this.startY = browserEvent.offsetY;
|
||||
this.deltaX = 0;
|
||||
this.deltaY = 0;
|
||||
this.startCenter = center;
|
||||
|
||||
@@ -33,9 +33,9 @@ ol.control.DragPan.prototype.handleDrag = function(mapBrowserEvent) {
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.control.DragPan.prototype.handleDragStart = function(mapBrowserEvent) {
|
||||
var browserEventObject = mapBrowserEvent.getBrowserEventObject();
|
||||
if (!browserEventObject.shiftKey) {
|
||||
browserEventObject.preventDefault();
|
||||
var browserEvent = mapBrowserEvent.browserEvent;
|
||||
if (!browserEvent.shiftKey) {
|
||||
browserEvent.preventDefault();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
@@ -42,9 +42,9 @@ ol.control.DragZoom.prototype.handleDragEnd = function(mapBrowserEvent) {
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.control.DragZoom.prototype.handleDragStart = function(mapBrowserEvent) {
|
||||
var browserEventObject = mapBrowserEvent.getBrowserEventObject();
|
||||
if (browserEventObject.shiftKey) {
|
||||
browserEventObject.preventDefault();
|
||||
var browserEvent = mapBrowserEvent.browserEvent;
|
||||
if (browserEvent.shiftKey) {
|
||||
browserEvent.preventDefault();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
@@ -25,7 +25,7 @@ ol.control.MouseWheelZoom.prototype.handleMapBrowserEvent =
|
||||
goog.events.MouseWheelHandler.EventType.MOUSEWHEEL) {
|
||||
var map = mapBrowserEvent.map;
|
||||
var mouseWheelEvent = /** @type {goog.events.MouseWheelEvent} */
|
||||
mapBrowserEvent.getBrowserEventObject();
|
||||
mapBrowserEvent.browserEvent;
|
||||
goog.asserts.assert(mouseWheelEvent instanceof goog.events.MouseWheelEvent);
|
||||
if (mouseWheelEvent.deltaY !== 0) {
|
||||
map.whileFrozen(function() {
|
||||
|
||||
Reference in New Issue
Block a user