mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-13 08:34:46 +08:00
33 lines
760 B
JavaScript
33 lines
760 B
JavaScript
// @ts-check
|
|
|
|
import IContext from "../IContext"
|
|
import Utility from "../../Utility"
|
|
|
|
/**
|
|
* @typedef {import("../../Blueprint").default} Blueprint
|
|
*/
|
|
|
|
/**
|
|
* @template {HTMLElement} T
|
|
* @extends {IContext<T>}
|
|
*/
|
|
export default class IPointing extends IContext {
|
|
|
|
constructor(target, blueprint, options) {
|
|
super(target, blueprint, options)
|
|
this.movementSpace = this.blueprint?.getGridDOMElement() ?? document.documentElement
|
|
}
|
|
|
|
/**
|
|
* @param {MouseEvent} mouseEvent
|
|
*/
|
|
locationFromEvent(mouseEvent) {
|
|
return this.blueprint.compensateTranslation(
|
|
Utility.convertLocation(
|
|
[mouseEvent.clientX, mouseEvent.clientY],
|
|
this.movementSpace
|
|
)
|
|
)
|
|
}
|
|
}
|