mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-03-05 06:57:29 +08:00
JsDoc types fixed and typecheck activated
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
// @ts-check
|
||||
|
||||
/**
|
||||
* @typedef {import("../Blueprint").default} Blueprint
|
||||
*/
|
||||
export default class IContext {
|
||||
|
||||
/** @type {HTMLElement} */
|
||||
target
|
||||
|
||||
/** @type {import("../Blueprint").default}" */
|
||||
/** @type {Blueprint} */
|
||||
blueprint
|
||||
|
||||
/** @type {Object} */
|
||||
|
||||
@@ -40,7 +40,7 @@ export default class Paste extends IContext {
|
||||
if (nodes.length > 0) {
|
||||
this.blueprint.unselectAll()
|
||||
}
|
||||
let mousePosition = this.blueprint.entity.mousePosition
|
||||
let mousePosition = this.blueprint.mousePosition
|
||||
this.blueprint.addGraphElement(...nodes)
|
||||
nodes.forEach(node => {
|
||||
const locationOffset = [
|
||||
|
||||
@@ -4,6 +4,7 @@ import Configuration from "../../Configuration"
|
||||
import IContext from "../IContext"
|
||||
import ISerializer from "../../serialization/ISerializer"
|
||||
import KeyBindingEntity from "../../entity/KeyBindingEntity"
|
||||
|
||||
export default class IKeyboardShortcut extends IContext {
|
||||
|
||||
/** @type {KeyBindingEntity} */
|
||||
@@ -61,7 +62,6 @@ export default class IKeyboardShortcut extends IContext {
|
||||
|| keyEntry.bAlt && e.key == "Alt"
|
||||
|| keyEntry.bCmd && e.key == "Meta" // Unsure about this, what key is that?
|
||||
|| Configuration.Keys[keyEntry.Key] == e.code
|
||||
|
||||
)) {
|
||||
self.unfire()
|
||||
document.removeEventListener("keyup", this.keyUpHandler)
|
||||
|
||||
@@ -83,7 +83,7 @@ export default class IMouseClickDrag extends IPointing {
|
||||
const movement = [e.movementX, e.movementY]
|
||||
self.dragTo(location, movement)
|
||||
if (self.#trackingMouse) {
|
||||
self.blueprint.entity.mousePosition = self.locationFromEvent(e)
|
||||
self.blueprint.mousePosition = self.locationFromEvent(e)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ export default class IMouseWheel extends IPointing {
|
||||
let self = this
|
||||
|
||||
this.#mouseWheelHandler = e => {
|
||||
e.preventDefault()
|
||||
const location = self.locationFromEvent(e)
|
||||
self.wheel(Math.sign(e.deltaY), location)
|
||||
}
|
||||
|
||||
@@ -24,11 +24,13 @@ export default class MouseTracking extends IPointing {
|
||||
let self = this
|
||||
|
||||
this.#mousemoveHandler = e => {
|
||||
self.blueprint.entity.mousePosition = self.locationFromEvent(e)
|
||||
e.preventDefault()
|
||||
self.blueprint.mousePosition = self.locationFromEvent(e)
|
||||
}
|
||||
|
||||
this.#trackingMouseStolenHandler = e => {
|
||||
if (!self.#mouseTracker) {
|
||||
e.preventDefault()
|
||||
this.#mouseTracker = e.detail.tracker
|
||||
self.unlistenMouseMove()
|
||||
}
|
||||
@@ -36,6 +38,7 @@ export default class MouseTracking extends IPointing {
|
||||
|
||||
this.#trackingMouseGaveBackHandler = e => {
|
||||
if (self.#mouseTracker == e.detail.tracker) {
|
||||
e.preventDefault()
|
||||
self.#mouseTracker = null
|
||||
self.listenMouseMove()
|
||||
}
|
||||
@@ -52,13 +55,22 @@ export default class MouseTracking extends IPointing {
|
||||
|
||||
listenEvents() {
|
||||
this.listenMouseMove()
|
||||
this.blueprint.addEventListener(Configuration.trackingMouseEventName.begin, this.#trackingMouseStolenHandler)
|
||||
this.blueprint.addEventListener(Configuration.trackingMouseEventName.end, this.#trackingMouseGaveBackHandler)
|
||||
this.blueprint.addEventListener(
|
||||
Configuration.trackingMouseEventName.begin,
|
||||
/** @type {(e: Event) => any} */(this.#trackingMouseStolenHandler))
|
||||
this.blueprint.addEventListener(
|
||||
Configuration.trackingMouseEventName.end,
|
||||
/** @type {(e: Event) => any} */(this.#trackingMouseGaveBackHandler))
|
||||
}
|
||||
|
||||
unlistenEvents() {
|
||||
this.unlistenMouseMove()
|
||||
this.blueprint.removeEventListener(Configuration.trackingMouseEventName.begin, this.#trackingMouseStolenHandler)
|
||||
this.blueprint.removeEventListener(Configuration.trackingMouseEventName.end, this.#trackingMouseGaveBackHandler)
|
||||
this.blueprint.removeEventListener(
|
||||
Configuration.trackingMouseEventName.begin,
|
||||
/** @type {(e: Event) => any} */(this.#trackingMouseStolenHandler))
|
||||
this.blueprint.removeEventListener(
|
||||
Configuration.trackingMouseEventName.end,
|
||||
/** @type {(e: Event) => any} */(this.#trackingMouseGaveBackHandler)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user