You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
1.5 KiB
78 lines
1.5 KiB
|
3 years ago
|
/**
|
||
|
|
* @module ol/events/Event
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @classdesc
|
||
|
|
* Stripped down implementation of the W3C DOM Level 2 Event interface.
|
||
|
|
* See https://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-interface.
|
||
|
|
*
|
||
|
|
* This implementation only provides `type` and `target` properties, and
|
||
|
|
* `stopPropagation` and `preventDefault` methods. It is meant as base class
|
||
|
|
* for higher level events defined in the library, and works with
|
||
|
|
* {@link module:ol/events/Target~Target}.
|
||
|
|
*/
|
||
|
|
class BaseEvent {
|
||
|
|
/**
|
||
|
|
* @param {string} type Type.
|
||
|
|
*/
|
||
|
|
constructor(type) {
|
||
|
|
/**
|
||
|
|
* @type {boolean}
|
||
|
|
*/
|
||
|
|
this.propagationStopped;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @type {boolean}
|
||
|
|
*/
|
||
|
|
this.defaultPrevented;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* The event type.
|
||
|
|
* @type {string}
|
||
|
|
* @api
|
||
|
|
*/
|
||
|
|
this.type = type;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* The event target.
|
||
|
|
* @type {Object}
|
||
|
|
* @api
|
||
|
|
*/
|
||
|
|
this.target = null;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Prevent default. This means that no emulated `click`, `singleclick` or `doubleclick` events
|
||
|
|
* will be fired.
|
||
|
|
* @api
|
||
|
|
*/
|
||
|
|
preventDefault() {
|
||
|
|
this.defaultPrevented = true;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Stop event propagation.
|
||
|
|
* @api
|
||
|
|
*/
|
||
|
|
stopPropagation() {
|
||
|
|
this.propagationStopped = true;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @param {Event|import("./Event.js").default} evt Event
|
||
|
|
*/
|
||
|
|
export function stopPropagation(evt) {
|
||
|
|
evt.stopPropagation();
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @param {Event|import("./Event.js").default} evt Event
|
||
|
|
*/
|
||
|
|
export function preventDefault(evt) {
|
||
|
|
evt.preventDefault();
|
||
|
|
}
|
||
|
|
|
||
|
|
export default BaseEvent;
|