mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-04 08:50:33 +08:00
31 lines
953 B
JavaScript
31 lines
953 B
JavaScript
import IInput from "../IInput"
|
|
import Utility from "../../Utility"
|
|
|
|
/**
|
|
* @template {HTMLElement} T
|
|
* @extends {IInput<T>}
|
|
*/
|
|
export default class IPointing extends IInput {
|
|
|
|
constructor(target, blueprint, options = {}) {
|
|
options.ignoreTranslateCompensate ??= false
|
|
options.ignoreScale ??= false
|
|
options.movementSpace ??= blueprint.getGridDOMElement() ?? document.documentElement
|
|
super(target, blueprint, options)
|
|
/** @type {HTMLElement} */
|
|
this.movementSpace = options.movementSpace
|
|
}
|
|
|
|
/** @param {MouseEvent} mouseEvent */
|
|
locationFromEvent(mouseEvent) {
|
|
const location = Utility.convertLocation(
|
|
[mouseEvent.clientX, mouseEvent.clientY],
|
|
this.movementSpace,
|
|
this.options.ignoreScale
|
|
)
|
|
return this.options.ignoreTranslateCompensate
|
|
? location
|
|
: this.blueprint.compensateTranslation(location)
|
|
}
|
|
}
|