preventDefault and stopPropagation convenience functions.
These functions can directly be used as browser event listeners.
This commit is contained in:
+4
-11
@@ -43,8 +43,8 @@ ol.event.Drag = function(target) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// no default for mousemove and touchmove events to avoid page scrolling.
|
// no default for mousemove and touchmove events to avoid page scrolling.
|
||||||
target.register('mousemove', this.preventDefault);
|
target.register('mousemove', ol.event.preventDefault);
|
||||||
target.register('touchmove', this.preventDefault);
|
target.register('touchmove', ol.event.preventDefault);
|
||||||
|
|
||||||
dragger.defaultAction = function(x, y) {};
|
dragger.defaultAction = function(x, y) {};
|
||||||
dragger.addEventListener(goog.fx.Dragger.EventType.START, function(evt) {
|
dragger.addEventListener(goog.fx.Dragger.EventType.START, function(evt) {
|
||||||
@@ -83,17 +83,10 @@ ol.event.Drag = function(target) {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
ol.event.Drag.prototype.preventDefault = function(evt) {
|
|
||||||
evt.preventDefault();
|
|
||||||
};
|
|
||||||
|
|
||||||
/** @inheritDoc */
|
/** @inheritDoc */
|
||||||
ol.event.Drag.prototype.destroy = function() {
|
ol.event.Drag.prototype.destroy = function() {
|
||||||
this.target_.unregister('mousemove', this.preventDefault);
|
this.target_.unregister('mousemove', ol.event.preventDefault);
|
||||||
this.target_.unregister('touchmove', this.preventDefault);
|
this.target_.unregister('touchmove', ol.event.preventDefault);
|
||||||
this.dragger_.dispose();
|
this.dragger_.dispose();
|
||||||
goog.object.clear(this);
|
goog.object.clear(this);
|
||||||
};
|
};
|
||||||
|
|||||||
+12
-7
@@ -42,16 +42,21 @@ ol.event.isMultiTouch = function(evt) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is the event a keyboard event with Enter or Space pressed?
|
* Call preventDefault on the provided event.
|
||||||
*
|
*
|
||||||
* @param {!Event} evt
|
* @param {!Event} evt
|
||||||
* @return {boolean}
|
|
||||||
*/
|
*/
|
||||||
ol.event.isEnterOrSpace = function(evt) {
|
ol.event.preventDefault = function(evt) {
|
||||||
return evt.type === "keypress" &&
|
evt.preventDefault();
|
||||||
(evt.keyCode === goog.events.KeyCodes.ENTER ||
|
};
|
||||||
evt.keyCode === goog.events.KeyCodes.SPACE ||
|
|
||||||
evt.keyCode === goog.events.KeyCodes.MAC_ENTER);
|
/**
|
||||||
|
* Call stopPropagation on the provided event.
|
||||||
|
*
|
||||||
|
* @param {!Event} evt
|
||||||
|
*/
|
||||||
|
ol.event.stopPropagation = function(evt) {
|
||||||
|
evt.stopPropagation();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user