mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-03 23:55:04 +08:00
Improove naming input options
This commit is contained in:
@@ -18,7 +18,7 @@ export default class IMouseClick extends IPointing {
|
||||
options.clickButton ??= 0
|
||||
options.consumeEvent ??= true
|
||||
options.exitAnyButton ??= true
|
||||
options.looseTarget ??= false
|
||||
options.strictTarget ??= false
|
||||
super(target, blueprint, options)
|
||||
this.clickedPosition = [0, 0]
|
||||
let self = this
|
||||
@@ -28,7 +28,7 @@ export default class IMouseClick extends IPointing {
|
||||
switch (e.button) {
|
||||
case self.options.clickButton:
|
||||
// Either doesn't matter or consider the click only when clicking on the target, not descandants
|
||||
if (self.options.looseTarget || e.target == e.currentTarget) {
|
||||
if (!self.options.strictTarget || e.target == e.currentTarget) {
|
||||
if (self.options.consumeEvent) {
|
||||
e.stopImmediatePropagation() // Captured, don't call anyone else
|
||||
}
|
||||
|
||||
@@ -46,10 +46,10 @@ export default class IMouseClickDrag extends IPointing {
|
||||
options.consumeEvent ??= true
|
||||
options.draggableElement ??= target
|
||||
options.exitAnyButton ??= true
|
||||
options.looseTarget ??= false
|
||||
options.moveEverywhere ??= false
|
||||
options.movementSpace ??= blueprint?.getGridDOMElement()
|
||||
options.repositionClickOffset ??= false
|
||||
options.repositionOnClick ??= false
|
||||
options.strictTarget ??= false
|
||||
super(target, blueprint, options)
|
||||
this.stepSize = parseInt(options?.stepSize ?? Configuration.gridSize)
|
||||
|
||||
@@ -62,7 +62,7 @@ export default class IMouseClickDrag extends IPointing {
|
||||
switch (e.button) {
|
||||
case self.options.clickButton:
|
||||
// Either doesn't matter or consider the click only when clicking on the parent, not descandants
|
||||
if (self.options.looseTarget || e.target == e.currentTarget) {
|
||||
if (!self.options.strictTarget || e.target == e.currentTarget) {
|
||||
if (self.options.consumeEvent) {
|
||||
e.stopImmediatePropagation() // Captured, don't call anyone else
|
||||
}
|
||||
|
||||
@@ -14,12 +14,13 @@ export default class IMouseWheel extends IPointing {
|
||||
* @param {import("../../Blueprint").default} blueprint
|
||||
* @param {Object} options
|
||||
*/
|
||||
constructor(target, blueprint, options) {
|
||||
constructor(target, blueprint, options = {}) {
|
||||
options.listenOnFocus = true
|
||||
options.strictTarget ??= false
|
||||
super(target, blueprint, options)
|
||||
this.looseTarget = options?.looseTarget ?? true
|
||||
let self = this
|
||||
this.strictTarget = options.strictTarget
|
||||
|
||||
const self = this
|
||||
this.#mouseWheelHandler = e => {
|
||||
e.preventDefault()
|
||||
const location = self.locationFromEvent(e)
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
import IMouseClickDrag from "./IMouseClickDrag"
|
||||
|
||||
/** @typedef {import("../../element/PinElement").default} PinElement */
|
||||
/**
|
||||
* @typedef {import("../../element/IDraggableElement").default} IDraggableElement
|
||||
*/
|
||||
|
||||
/** @extends IMouseClickDrag<PinElement> */
|
||||
/**
|
||||
* @template {IDraggableElement} T
|
||||
* @extends {IMouseClickDrag<T>}
|
||||
*/
|
||||
export default class MouseIgnore extends IMouseClickDrag {
|
||||
|
||||
constructor(target, blueprint, options = {}) {
|
||||
|
||||
@@ -13,7 +13,7 @@ import Utility from "../../Utility"
|
||||
export default class MouseMoveDraggable extends IMouseClickDrag {
|
||||
|
||||
clicked(location) {
|
||||
if (this.options.repositionClickOffset) {
|
||||
if (this.options.repositionOnClick) {
|
||||
this.target.setLocation(this.stepSize > 1
|
||||
? Utility.snapToGrid(location, this.stepSize)
|
||||
: location
|
||||
|
||||
Reference in New Issue
Block a user