Improove naming input options

This commit is contained in:
barsdeveloper
2022-10-14 19:52:00 +02:00
parent da73cf98b5
commit 0b19d89416
17 changed files with 64 additions and 60 deletions

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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)

View File

@@ -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 = {}) {

View File

@@ -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