Change the interaction condition signature
This commit is contained in:
@@ -7,16 +7,17 @@ goog.require('goog.functions');
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {function(goog.events.BrowserEvent): boolean}
|
* @typedef {function(ol.MapBrowserEvent): boolean}
|
||||||
*/
|
*/
|
||||||
ol.interaction.ConditionType;
|
ol.interaction.ConditionType;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {goog.events.BrowserEvent} browserEvent Browser event.
|
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
|
||||||
* @return {boolean} True if only the alt key is pressed.
|
* @return {boolean} True if only the alt key is pressed.
|
||||||
*/
|
*/
|
||||||
ol.interaction.condition.altKeyOnly = function(browserEvent) {
|
ol.interaction.condition.altKeyOnly = function(mapBrowserEvent) {
|
||||||
|
var browserEvent = mapBrowserEvent.browserEvent;
|
||||||
return (
|
return (
|
||||||
browserEvent.altKey &&
|
browserEvent.altKey &&
|
||||||
!browserEvent.platformModifierKey &&
|
!browserEvent.platformModifierKey &&
|
||||||
@@ -25,10 +26,11 @@ ol.interaction.condition.altKeyOnly = function(browserEvent) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {goog.events.BrowserEvent} browserEvent Browser event.
|
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
|
||||||
* @return {boolean} True if only the alt and shift keys are pressed.
|
* @return {boolean} True if only the alt and shift keys are pressed.
|
||||||
*/
|
*/
|
||||||
ol.interaction.condition.altShiftKeysOnly = function(browserEvent) {
|
ol.interaction.condition.altShiftKeysOnly = function(mapBrowserEvent) {
|
||||||
|
var browserEvent = mapBrowserEvent.browserEvent;
|
||||||
return (
|
return (
|
||||||
browserEvent.altKey &&
|
browserEvent.altKey &&
|
||||||
!browserEvent.platformModifierKey &&
|
!browserEvent.platformModifierKey &&
|
||||||
@@ -37,26 +39,28 @@ ol.interaction.condition.altShiftKeysOnly = function(browserEvent) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {goog.events.BrowserEvent} browserEvent Browser event.
|
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
|
||||||
* @return {boolean} True.
|
* @return {boolean} True.
|
||||||
*/
|
*/
|
||||||
ol.interaction.condition.always = goog.functions.TRUE;
|
ol.interaction.condition.always = goog.functions.TRUE;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {goog.events.BrowserEvent} browserEvent Browser event.
|
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
|
||||||
* @return {boolean} True only the event is a click event.
|
* @return {boolean} True only the event is a click event.
|
||||||
*/
|
*/
|
||||||
ol.interaction.condition.clickOnly = function(browserEvent) {
|
ol.interaction.condition.clickOnly = function(mapBrowserEvent) {
|
||||||
|
var browserEvent = mapBrowserEvent.browserEvent;
|
||||||
return browserEvent.type == goog.events.EventType.CLICK;
|
return browserEvent.type == goog.events.EventType.CLICK;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {goog.events.BrowserEvent} browserEvent Browser event.
|
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
|
||||||
* @return {boolean} True if only the no modifier keys are pressed.
|
* @return {boolean} True if only the no modifier keys are pressed.
|
||||||
*/
|
*/
|
||||||
ol.interaction.condition.noModifierKeys = function(browserEvent) {
|
ol.interaction.condition.noModifierKeys = function(mapBrowserEvent) {
|
||||||
|
var browserEvent = mapBrowserEvent.browserEvent;
|
||||||
return (
|
return (
|
||||||
!browserEvent.altKey &&
|
!browserEvent.altKey &&
|
||||||
!browserEvent.platformModifierKey &&
|
!browserEvent.platformModifierKey &&
|
||||||
@@ -65,10 +69,11 @@ ol.interaction.condition.noModifierKeys = function(browserEvent) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {goog.events.BrowserEvent} browserEvent Browser event.
|
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
|
||||||
* @return {boolean} True if only the platform modifier key is pressed.
|
* @return {boolean} True if only the platform modifier key is pressed.
|
||||||
*/
|
*/
|
||||||
ol.interaction.condition.platformModifierKeyOnly = function(browserEvent) {
|
ol.interaction.condition.platformModifierKeyOnly = function(mapBrowserEvent) {
|
||||||
|
var browserEvent = mapBrowserEvent.browserEvent;
|
||||||
return (
|
return (
|
||||||
!browserEvent.altKey &&
|
!browserEvent.altKey &&
|
||||||
browserEvent.platformModifierKey &&
|
browserEvent.platformModifierKey &&
|
||||||
@@ -77,10 +82,11 @@ ol.interaction.condition.platformModifierKeyOnly = function(browserEvent) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {goog.events.BrowserEvent} browserEvent Browser event.
|
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
|
||||||
* @return {boolean} True if only the shift key is pressed.
|
* @return {boolean} True if only the shift key is pressed.
|
||||||
*/
|
*/
|
||||||
ol.interaction.condition.shiftKeyOnly = function(browserEvent) {
|
ol.interaction.condition.shiftKeyOnly = function(mapBrowserEvent) {
|
||||||
|
var browserEvent = mapBrowserEvent.browserEvent;
|
||||||
return (
|
return (
|
||||||
!browserEvent.altKey &&
|
!browserEvent.altKey &&
|
||||||
!browserEvent.platformModifierKey &&
|
!browserEvent.platformModifierKey &&
|
||||||
@@ -89,10 +95,11 @@ ol.interaction.condition.shiftKeyOnly = function(browserEvent) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {goog.events.BrowserEvent} browserEvent Browser event.
|
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
|
||||||
* @return {boolean} True if the target element is not editable.
|
* @return {boolean} True if the target element is not editable.
|
||||||
*/
|
*/
|
||||||
ol.interaction.condition.targetNotEditable = function(browserEvent) {
|
ol.interaction.condition.targetNotEditable = function(mapBrowserEvent) {
|
||||||
|
var browserEvent = mapBrowserEvent.browserEvent;
|
||||||
var tagName = browserEvent.target.tagName;
|
var tagName = browserEvent.target.tagName;
|
||||||
return (
|
return (
|
||||||
tagName !== goog.dom.TagName.INPUT &&
|
tagName !== goog.dom.TagName.INPUT &&
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ ol.interaction.DragPan.prototype.handleDragEnd = function(mapBrowserEvent) {
|
|||||||
*/
|
*/
|
||||||
ol.interaction.DragPan.prototype.handleDragStart = function(mapBrowserEvent) {
|
ol.interaction.DragPan.prototype.handleDragStart = function(mapBrowserEvent) {
|
||||||
var browserEvent = mapBrowserEvent.browserEvent;
|
var browserEvent = mapBrowserEvent.browserEvent;
|
||||||
if (browserEvent.isMouseActionButton() && this.condition_(browserEvent)) {
|
if (browserEvent.isMouseActionButton() && this.condition_(mapBrowserEvent)) {
|
||||||
if (this.kinetic_) {
|
if (this.kinetic_) {
|
||||||
this.kinetic_.begin();
|
this.kinetic_.begin();
|
||||||
this.kinetic_.update(browserEvent.clientX, browserEvent.clientY);
|
this.kinetic_.update(browserEvent.clientX, browserEvent.clientY);
|
||||||
|
|||||||
@@ -117,8 +117,7 @@ ol.interaction.DragRotateAndZoom.prototype.handleDragEnd =
|
|||||||
*/
|
*/
|
||||||
ol.interaction.DragRotateAndZoom.prototype.handleDragStart =
|
ol.interaction.DragRotateAndZoom.prototype.handleDragStart =
|
||||||
function(mapBrowserEvent) {
|
function(mapBrowserEvent) {
|
||||||
var browserEvent = mapBrowserEvent.browserEvent;
|
if (this.condition_(mapBrowserEvent)) {
|
||||||
if (this.condition_(browserEvent)) {
|
|
||||||
this.lastAngle_ = undefined;
|
this.lastAngle_ = undefined;
|
||||||
this.lastMagnitude_ = undefined;
|
this.lastMagnitude_ = undefined;
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ ol.interaction.DragRotate.prototype.handleDragEnd = function(mapBrowserEvent) {
|
|||||||
ol.interaction.DragRotate.prototype.handleDragStart =
|
ol.interaction.DragRotate.prototype.handleDragStart =
|
||||||
function(mapBrowserEvent) {
|
function(mapBrowserEvent) {
|
||||||
var browserEvent = mapBrowserEvent.browserEvent;
|
var browserEvent = mapBrowserEvent.browserEvent;
|
||||||
if (browserEvent.isMouseActionButton() && this.condition_(browserEvent)) {
|
if (browserEvent.isMouseActionButton() && this.condition_(mapBrowserEvent)) {
|
||||||
var map = mapBrowserEvent.map;
|
var map = mapBrowserEvent.map;
|
||||||
map.requestRenderFrame();
|
map.requestRenderFrame();
|
||||||
this.lastAngle_ = undefined;
|
this.lastAngle_ = undefined;
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ ol.interaction.DragZoom.prototype.handleDragEnd =
|
|||||||
ol.interaction.DragZoom.prototype.handleDragStart =
|
ol.interaction.DragZoom.prototype.handleDragStart =
|
||||||
function(mapBrowserEvent) {
|
function(mapBrowserEvent) {
|
||||||
var browserEvent = mapBrowserEvent.browserEvent;
|
var browserEvent = mapBrowserEvent.browserEvent;
|
||||||
if (browserEvent.isMouseActionButton() && this.condition_(browserEvent)) {
|
if (browserEvent.isMouseActionButton() && this.condition_(mapBrowserEvent)) {
|
||||||
this.dragBox_ = new ol.control.DragBox({
|
this.dragBox_ = new ol.control.DragBox({
|
||||||
startCoordinate: this.startCoordinate
|
startCoordinate: this.startCoordinate
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -59,7 +59,8 @@ ol.interaction.KeyboardPan.prototype.handleMapBrowserEvent =
|
|||||||
var keyEvent = /** @type {goog.events.KeyEvent} */
|
var keyEvent = /** @type {goog.events.KeyEvent} */
|
||||||
(mapBrowserEvent.browserEvent);
|
(mapBrowserEvent.browserEvent);
|
||||||
var keyCode = keyEvent.keyCode;
|
var keyCode = keyEvent.keyCode;
|
||||||
if (this.condition_(keyEvent) && (keyCode == goog.events.KeyCodes.DOWN ||
|
if (this.condition_(mapBrowserEvent) &&
|
||||||
|
(keyCode == goog.events.KeyCodes.DOWN ||
|
||||||
keyCode == goog.events.KeyCodes.LEFT ||
|
keyCode == goog.events.KeyCodes.LEFT ||
|
||||||
keyCode == goog.events.KeyCodes.RIGHT ||
|
keyCode == goog.events.KeyCodes.RIGHT ||
|
||||||
keyCode == goog.events.KeyCodes.UP)) {
|
keyCode == goog.events.KeyCodes.UP)) {
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ ol.interaction.KeyboardZoom.prototype.handleMapBrowserEvent =
|
|||||||
var keyEvent = /** @type {goog.events.KeyEvent} */
|
var keyEvent = /** @type {goog.events.KeyEvent} */
|
||||||
(mapBrowserEvent.browserEvent);
|
(mapBrowserEvent.browserEvent);
|
||||||
var charCode = keyEvent.charCode;
|
var charCode = keyEvent.charCode;
|
||||||
if (this.condition_(keyEvent) &&
|
if (this.condition_(mapBrowserEvent) &&
|
||||||
(charCode == '+'.charCodeAt(0) || charCode == '-'.charCodeAt(0))) {
|
(charCode == '+'.charCodeAt(0) || charCode == '-'.charCodeAt(0))) {
|
||||||
var map = mapBrowserEvent.map;
|
var map = mapBrowserEvent.map;
|
||||||
var delta = (charCode == '+'.charCodeAt(0)) ? this.delta_ : -this.delta_;
|
var delta = (charCode == '+'.charCodeAt(0)) ? this.delta_ : -this.delta_;
|
||||||
|
|||||||
@@ -56,15 +56,15 @@ goog.inherits(ol.interaction.Select, ol.interaction.Interaction);
|
|||||||
/**
|
/**
|
||||||
* @inheritDoc.
|
* @inheritDoc.
|
||||||
*/
|
*/
|
||||||
ol.interaction.Select.prototype.handleMapBrowserEvent = function(evt) {
|
ol.interaction.Select.prototype.handleMapBrowserEvent =
|
||||||
var browserEvent = evt.browserEvent;
|
function(mapBrowserEvent) {
|
||||||
if (this.condition_(browserEvent)) {
|
if (this.condition_(mapBrowserEvent)) {
|
||||||
var map = evt.map;
|
var map = mapBrowserEvent.map;
|
||||||
var layers = map.getLayerGroup().getLayersArray();
|
var layers = map.getLayerGroup().getLayersArray();
|
||||||
if (!goog.isNull(this.layerFilter_)) {
|
if (!goog.isNull(this.layerFilter_)) {
|
||||||
layers = goog.array.filter(layers, this.layerFilter_);
|
layers = goog.array.filter(layers, this.layerFilter_);
|
||||||
}
|
}
|
||||||
var clear = !ol.interaction.condition.shiftKeyOnly(browserEvent);
|
var clear = !ol.interaction.condition.shiftKeyOnly(mapBrowserEvent);
|
||||||
|
|
||||||
var that = this;
|
var that = this;
|
||||||
var select = function(featuresByLayer) {
|
var select = function(featuresByLayer) {
|
||||||
@@ -73,7 +73,7 @@ ol.interaction.Select.prototype.handleMapBrowserEvent = function(evt) {
|
|||||||
|
|
||||||
map.getFeatures({
|
map.getFeatures({
|
||||||
layers: layers,
|
layers: layers,
|
||||||
pixel: evt.getPixel(),
|
pixel: mapBrowserEvent.getPixel(),
|
||||||
success: select
|
success: select
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user