chore(controller): .disposed guard
This commit is contained in:
@@ -132,6 +132,7 @@ export class SimulatorMask extends EventTarget {
|
|||||||
|
|
||||||
#moveCursorToTarget() {
|
#moveCursorToTarget() {
|
||||||
if (this.#disposed) return
|
if (this.#disposed) return
|
||||||
|
|
||||||
const newX = this.#currentCursorX + (this.#targetCursorX - this.#currentCursorX) * 0.2
|
const newX = this.#currentCursorX + (this.#targetCursorX - this.#currentCursorX) * 0.2
|
||||||
const newY = this.#currentCursorY + (this.#targetCursorY - this.#currentCursorY) * 0.2
|
const newY = this.#currentCursorY + (this.#targetCursorY - this.#currentCursorY) * 0.2
|
||||||
|
|
||||||
@@ -159,11 +160,15 @@ export class SimulatorMask extends EventTarget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setCursorPosition(x: number, y: number) {
|
setCursorPosition(x: number, y: number) {
|
||||||
|
if (this.#disposed) return
|
||||||
|
|
||||||
this.#targetCursorX = x
|
this.#targetCursorX = x
|
||||||
this.#targetCursorY = y
|
this.#targetCursorY = y
|
||||||
}
|
}
|
||||||
|
|
||||||
triggerClickAnimation() {
|
triggerClickAnimation() {
|
||||||
|
if (this.#disposed) return
|
||||||
|
|
||||||
this.#cursor.classList.remove(cursorStyles.clicking)
|
this.#cursor.classList.remove(cursorStyles.clicking)
|
||||||
// Force reflow to restart animation
|
// Force reflow to restart animation
|
||||||
void this.#cursor.offsetHeight
|
void this.#cursor.offsetHeight
|
||||||
@@ -171,7 +176,7 @@ export class SimulatorMask extends EventTarget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
show() {
|
show() {
|
||||||
if (this.shown) return
|
if (this.shown || this.#disposed) return
|
||||||
|
|
||||||
this.shown = true
|
this.shown = true
|
||||||
this.motion?.start()
|
this.motion?.start()
|
||||||
@@ -189,7 +194,7 @@ export class SimulatorMask extends EventTarget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
hide() {
|
hide() {
|
||||||
if (!this.shown) return
|
if (!this.shown || this.#disposed) return
|
||||||
|
|
||||||
this.shown = false
|
this.shown = false
|
||||||
this.motion?.fadeOut()
|
this.motion?.fadeOut()
|
||||||
|
|||||||
Reference in New Issue
Block a user