mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-03-07 08:07:29 +08:00
Refactoring
This commit is contained in:
62
js/input/Context.js
Normal file → Executable file
62
js/input/Context.js
Normal file → Executable file
@@ -1,31 +1,31 @@
|
||||
export default class Context {
|
||||
|
||||
constructor(target, blueprint, options) {
|
||||
/** @type {HTMLElement} */
|
||||
this.target = target
|
||||
/** @type {import("../Blueprint").default}" */
|
||||
this.blueprint = blueprint
|
||||
this.options = options
|
||||
if (options?.wantsFocusCallback ?? false) {
|
||||
let self = this
|
||||
this.blueprintfocusHandler = _ => self.blueprintFocused()
|
||||
this.blueprintunfocusHandler = _ => self.blueprintUnfocused()
|
||||
this.blueprint.addEventListener("blueprintfocus", this.blueprintfocusHandler)
|
||||
this.blueprint.addEventListener("blueprintunfocus", this.blueprintunfocusHandler)
|
||||
}
|
||||
}
|
||||
|
||||
unlistenDOMElement() {
|
||||
this.blueprintUnfocused()
|
||||
this.blueprint.removeEventListener("blueprintfocus", this.blueprintfocusHandler)
|
||||
this.blueprint.removeEventListener("blueprintunfocus", this.blueprintunfocusHandler)
|
||||
}
|
||||
|
||||
|
||||
/* Subclasses will probabily override the following methods */
|
||||
blueprintFocused() {
|
||||
}
|
||||
|
||||
blueprintUnfocused() {
|
||||
}
|
||||
}
|
||||
export default class Context {
|
||||
|
||||
constructor(target, blueprint, options) {
|
||||
/** @type {HTMLElement} */
|
||||
this.target = target
|
||||
/** @type {import("../Blueprint").default}" */
|
||||
this.blueprint = blueprint
|
||||
this.options = options
|
||||
let self = this
|
||||
this.blueprintFocusHandler = _ => self.blueprintFocused()
|
||||
this.blueprintUnfocusHandler = _ => self.blueprintUnfocused()
|
||||
if (options?.wantsFocusCallback ?? false) {
|
||||
this.blueprint.addEventListener("blueprint-focus", this.blueprintFocusHandler)
|
||||
this.blueprint.addEventListener("blueprint-unfocus", this.blueprintUnfocusHandler)
|
||||
}
|
||||
}
|
||||
|
||||
unlistenDOMElement() {
|
||||
this.blueprintUnfocused()
|
||||
this.blueprint.removeEventListener("blueprint-focus", this.blueprintFocusHandler)
|
||||
this.blueprint.removeEventListener("blueprint-unfocus", this.blueprintUnfocusHandler)
|
||||
}
|
||||
|
||||
|
||||
/* Subclasses will probabily override the following methods */
|
||||
blueprintFocused() {
|
||||
}
|
||||
|
||||
blueprintUnfocused() {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user