mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-05-13 06:57:28 +08:00
Window introduced
This commit is contained in:
47
js/template/IDraggableTemplate.js
Executable file
47
js/template/IDraggableTemplate.js
Executable file
@@ -0,0 +1,47 @@
|
||||
import ITemplate from "./ITemplate"
|
||||
import MouseMoveDraggable from "../input/mouse/MouseMoveDraggable"
|
||||
|
||||
/**
|
||||
* @typedef {import("../element/IDraggableElement").default} IDraggableElement
|
||||
*/
|
||||
|
||||
/**
|
||||
* @template {ISelectableDraggableElement} T
|
||||
* @extends {ITemplate<T>}
|
||||
*/
|
||||
export default class IDraggableTemplate extends ITemplate {
|
||||
|
||||
/** @param {T} element */
|
||||
getDraggableElement(element) {
|
||||
return element
|
||||
}
|
||||
|
||||
createDraggableObject(element) {
|
||||
return new MouseMoveDraggable(element, element.blueprint, {
|
||||
draggableElement: this.getDraggableElement(element),
|
||||
looseTarget: true,
|
||||
})
|
||||
}
|
||||
|
||||
/** @param {T} element */
|
||||
createInputObjects(element) {
|
||||
return [
|
||||
...super.createInputObjects(element),
|
||||
this.createDraggableObject(element),
|
||||
]
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {T} element
|
||||
* @param {Map} changedProperties
|
||||
*/
|
||||
update(element, changedProperties) {
|
||||
super.update(element, changedProperties)
|
||||
if (changedProperties.has("locationX")) {
|
||||
element.style.setProperty("--ueb-position-x", `${element.locationX}`)
|
||||
}
|
||||
if (changedProperties.has("locationY")) {
|
||||
element.style.setProperty("--ueb-position-y", `${element.locationY}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user