mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-03-12 11:07:40 +08:00
WIP
This commit is contained in:
@@ -29,7 +29,7 @@ export default class IMouseClickDrag extends IPointing {
|
||||
this.exitAnyButton = options?.exitAnyButton ?? true
|
||||
this.moveEverywhere = options?.moveEverywhere ?? false
|
||||
this.looseTarget = options?.looseTarget ?? false
|
||||
this.consumeClickEvent = options?.consumeClickEvent ?? true
|
||||
this.consumeEvent = options?.consumeEvent ?? true
|
||||
this.clickedPosition = [0, 0]
|
||||
|
||||
const movementListenedElement = this.moveEverywhere ? document.documentElement : this.movementSpace
|
||||
@@ -41,7 +41,7 @@ export default class IMouseClickDrag extends IPointing {
|
||||
case self.clickButton:
|
||||
// Either doesn't matter or consider the click only when clicking on the parent, not descandants
|
||||
if (self.looseTarget || e.target == e.currentTarget) {
|
||||
if (this.consumeClickEvent) {
|
||||
if (this.consumeEvent) {
|
||||
e.stopImmediatePropagation() // Captured, don't call anyone else
|
||||
}
|
||||
// Attach the listeners
|
||||
@@ -60,7 +60,7 @@ export default class IMouseClickDrag extends IPointing {
|
||||
}
|
||||
|
||||
this.#mouseStartedMovingHandler = e => {
|
||||
if (this.consumeClickEvent) {
|
||||
if (this.consumeEvent) {
|
||||
e.stopImmediatePropagation() // Captured, don't call anyone else
|
||||
}
|
||||
// Delegate from now on to self.#mouseMoveHandler
|
||||
@@ -75,7 +75,7 @@ export default class IMouseClickDrag extends IPointing {
|
||||
}
|
||||
|
||||
this.#mouseMoveHandler = e => {
|
||||
if (this.consumeClickEvent) {
|
||||
if (this.consumeEvent) {
|
||||
e.stopImmediatePropagation() // Captured, don't call anyone else
|
||||
}
|
||||
const location = self.locationFromEvent(e)
|
||||
@@ -88,7 +88,7 @@ export default class IMouseClickDrag extends IPointing {
|
||||
|
||||
this.#mouseUpHandler = e => {
|
||||
if (!self.exitAnyButton || e.button == self.clickButton) {
|
||||
if (this.consumeClickEvent) {
|
||||
if (this.consumeEvent) {
|
||||
e.stopImmediatePropagation() // Captured, don't call anyone else
|
||||
}
|
||||
// Remove the handlers of "mousemove" and "mouseup"
|
||||
|
||||
@@ -16,7 +16,7 @@ export default class IMouseWheel extends IPointing {
|
||||
* @param {Object} options
|
||||
*/
|
||||
constructor(target, blueprint, options) {
|
||||
options.wantsFocusCallback = true
|
||||
options.listenOnFocus = true
|
||||
super(target, blueprint, options)
|
||||
this.looseTarget = options?.looseTarget ?? true
|
||||
let self = this
|
||||
|
||||
@@ -17,7 +17,7 @@ export default class MouseTracking extends IPointing {
|
||||
#trackingMouseGaveBackHandler
|
||||
|
||||
constructor(target, blueprint, options = {}) {
|
||||
options.wantsFocusCallback = true
|
||||
options.listenOnFocus = true
|
||||
super(target, blueprint, options)
|
||||
|
||||
let self = this
|
||||
|
||||
@@ -4,22 +4,22 @@ import IContext from "../IContext"
|
||||
|
||||
export default class Unfocus extends IContext {
|
||||
|
||||
/** @type {(e: WheelEvent) => void} */
|
||||
/** @type {(e: MouseEvent) => void} */
|
||||
#clickHandler
|
||||
|
||||
constructor(target, blueprint, options = {}) {
|
||||
options.wantsFocusCallback = true
|
||||
options.listenOnFocus = true
|
||||
super(target, blueprint, options)
|
||||
|
||||
let self = this
|
||||
this.#clickHandler = e => self.clickedSomewhere(e.target)
|
||||
if (this.blueprint.focuse) {
|
||||
this.#clickHandler = e => self.clickedSomewhere(/** @type {HTMLElement} */(e.target))
|
||||
if (this.blueprint.focus) {
|
||||
document.addEventListener("click", this.#clickHandler)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {HTMLElement} e
|
||||
* @param {HTMLElement} target
|
||||
*/
|
||||
clickedSomewhere(target) {
|
||||
// If target is outside the blueprint grid
|
||||
|
||||
Reference in New Issue
Block a user