mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-04 08:50:33 +08:00
* WIP * WIP * wip * WIP * Several fixes * Tests wip port to playwright * WIP * Fix more tests * Serialization tests fixed * Several fixes for tests * Input options types * Type adjustments * Fix object reference parser * Tests fixes * More tests fixes
64 lines
1.5 KiB
JavaScript
Executable File
64 lines
1.5 KiB
JavaScript
Executable File
import MouseMoveDraggable from "./MouseMoveDraggable.js"
|
|
|
|
/**
|
|
* @typedef {import("./MouseMoveDraggable.js").Options & {
|
|
* onClicked?: () => void,
|
|
* onStartDrag?: () => void,
|
|
* onDrag?: (location: Coordinates, movement: Coordinates) => void,
|
|
* onEndDrag?: () => void,
|
|
* }} Options
|
|
*/
|
|
|
|
export default class MouseClickDrag extends MouseMoveDraggable {
|
|
|
|
#onClicked
|
|
#onStartDrag
|
|
#onDrag
|
|
#onEndDrag
|
|
|
|
/**
|
|
* @param {HTMLElement} target
|
|
* @param {Blueprint} blueprint
|
|
* @param {Options} options
|
|
*/
|
|
constructor(target, blueprint, options = {}) {
|
|
super(target, blueprint, options)
|
|
if (options.onClicked) {
|
|
this.#onClicked = options.onClicked
|
|
}
|
|
if (options.onStartDrag) {
|
|
this.#onStartDrag = options.onStartDrag
|
|
}
|
|
if (options.onDrag) {
|
|
this.#onDrag = options.onDrag
|
|
}
|
|
if (options.onEndDrag) {
|
|
this.#onEndDrag = options.onEndDrag
|
|
}
|
|
}
|
|
|
|
/** @param {Coordinates} location */
|
|
clicked(location) {
|
|
super.clicked(location)
|
|
this.#onClicked?.()
|
|
}
|
|
|
|
startDrag() {
|
|
super.startDrag()
|
|
this.#onStartDrag?.()
|
|
}
|
|
|
|
/**
|
|
* @param {Coordinates} location
|
|
* @param {Coordinates} movement
|
|
*/
|
|
dragAction(location, movement) {
|
|
this.#onDrag?.(location, movement)
|
|
}
|
|
|
|
endDrag() {
|
|
super.endDrag()
|
|
this.#onEndDrag?.()
|
|
}
|
|
}
|