@visactor/vrender-core
Version:
## Description
104 lines (99 loc) • 3.24 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.FederatedEvent = void 0;
const vutils_1 = require("@visactor/vutils");
class FederatedEvent {
get layerX() {
return this.layer.x;
}
get layerY() {
return this.layer.y;
}
get pageX() {
return this.page.x;
}
get pageY() {
return this.page.y;
}
get x() {
return this.canvas.x;
}
get y() {
return this.canvas.y;
}
get canvasX() {
return this.canvas.x;
}
get canvasY() {
return this.canvas.y;
}
get viewX() {
return this.viewport.x;
}
get viewY() {
return this.viewport.y;
}
constructor(manager) {
this.bubbles = !0, this.cancelBubble = !0, this.cancelable = !1, this.composed = !1,
this.defaultPrevented = !1, this.eventPhase = FederatedEvent.prototype.NONE, this.propagationStopped = !1,
this.propagationImmediatelyStopped = !1, this.layer = {
x: 0,
y: 0
}, this.page = {
x: 0,
y: 0
}, this.canvas = {
x: 0,
y: 0
}, this.viewport = {
x: 0,
y: 0
}, this.NONE = 0, this.CAPTURING_PHASE = 1, this.AT_TARGET = 2, this.BUBBLING_PHASE = 3,
this.manager = manager;
}
composedPath() {
return !this.manager || this.path && this.path[this.path.length - 1] === this.target || (this.path = this.target ? this.manager.propagationPath(this.target) : []),
this.composedDetailPath(), this.path;
}
composedDetailPath() {
return this.pickParams && this.pickParams.graphic ? (this.detailPath = this.path.slice(),
this._composedDetailPath(this.pickParams)) : this.detailPath = this.path.slice(),
this.detailPath;
}
_composedDetailPath(params) {
if (params && params.graphic) {
const g = this.pickParams.graphic;
if (g.stage) {
const path = g.stage.eventSystem.manager.propagationPath(g);
this.detailPath.push(path), this._composedDetailPath(params.params);
}
}
}
preventDefault() {
try {
this.nativeEvent instanceof Event && this.nativeEvent.cancelable && this.nativeEvent.preventDefault();
} catch (err) {
this.nativeEvent.preventDefault && (0, vutils_1.isFunction)(this.nativeEvent.preventDefault) && this.nativeEvent.preventDefault();
}
this.defaultPrevented = !0;
}
stopImmediatePropagation() {
this.propagationImmediatelyStopped = !0;
}
stopPropagation() {
try {
this.nativeEvent instanceof Event && this.nativeEvent.cancelable && this.nativeEvent.stopPropagation();
} catch (err) {
this.nativeEvent.stopPropagation && (0, vutils_1.isFunction)(this.nativeEvent.stopPropagation) && this.nativeEvent.stopPropagation();
}
this.propagationStopped = !0;
}
initEvent() {}
initUIEvent() {}
clone() {
throw new Error("Method not implemented.");
}
}
exports.FederatedEvent = FederatedEvent;
//# sourceMappingURL=base-event.js.map