2022-02-16 11:20:17 +08:00

57 lines
1.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import {
Dragon as InnerDragon,
DragNodeDataObject,
} from '@alilc/lowcode-designer';
import { dragonSymbol } from './symbols';
export default class Dragon {
private readonly [dragonSymbol]: InnerDragon;
constructor(dragon: InnerDragon) {
this[dragonSymbol] = dragon;
}
static create(dragon: InnerDragon | null) {
if (!dragon) return null;
return new Dragon(dragon);
}
/**
* 绑定 dragstart 事件
* @param func
* @returns
*/
onDragstart(func: (/* e: LocateEvent */) => any) {
// TODO: 补充必要参数
return this[dragonSymbol].onDragstart(() => func());
}
/**
* 绑定 drag 事件
* @param func
* @returns
*/
onDrag(func: (/* e: LocateEvent */) => any) {
// TODO: 补充必要参数
return this[dragonSymbol].onDrag(() => func());
}
/**
* 绑定 dragend 事件
* @param func
* @returns
*/
onDragend(func: (/* e: LocateEvent */) => any) {
// TODO: 补充必要参数
return this[dragonSymbol].onDragend(() => func());
}
/**
* 设置拖拽监听的区域 shell以及自定义拖拽转换函数 boost
* @param shell 拖拽监听的区域
* @param boost 拖拽转换函数
*/
from(shell: Element, boost: (e: MouseEvent) => DragNodeDataObject | null) {
return this[dragonSymbol].from(shell, boost);
}
}