mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-13 01:21:58 +00:00
polyfill dragengine
This commit is contained in:
parent
36e4b564b1
commit
8e3e3b589a
47
packages/vision-polyfill/src/drag-engine.ts
Normal file
47
packages/vision-polyfill/src/drag-engine.ts
Normal file
@ -0,0 +1,47 @@
|
||||
import { designer } from './editor';
|
||||
import { DragObjectType, isNode } from '@ali/lowcode-designer';
|
||||
|
||||
const dragon = designer.dragon;
|
||||
const DragEngine = {
|
||||
from(shell: Element, boost: (e: MouseEvent) => any): any {
|
||||
dragon.from(shell, (e) => {
|
||||
const r = boost(e);
|
||||
if (!r) {
|
||||
return null;
|
||||
}
|
||||
if (isNode(r)) {
|
||||
return {
|
||||
type: DragObjectType.Node,
|
||||
nodes: [r],
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
type: DragObjectType.NodeData,
|
||||
data: r,
|
||||
};
|
||||
}
|
||||
});
|
||||
},
|
||||
onDragstart(func: (e: any, dragment: any) => any) {
|
||||
return dragon.onDragstart((evt) => {
|
||||
func(evt.originalEvent, evt.dragObject.nodes[0]);
|
||||
});
|
||||
},
|
||||
onDrag(func: (e: any, dragment: any, location: any) => any) {
|
||||
return dragon.onDrag((evt) => {
|
||||
const loc = designer.currentDocument?.dropLocation;
|
||||
func(evt.originalEvent, evt.dragObject.nodes[0], loc);
|
||||
});
|
||||
},
|
||||
onDragend(func: (dragment: any, location: any, copy: any) => any) {
|
||||
return dragon.onDragend(({ dragObject, copy }) => {
|
||||
const loc = designer.currentDocument?.dropLocation;
|
||||
func(dragObject.nodes[0], loc, copy);
|
||||
});
|
||||
},
|
||||
inDragging() {
|
||||
return dragon.dragging;
|
||||
},
|
||||
};
|
||||
|
||||
export default DragEngine;
|
||||
@ -1,34 +0,0 @@
|
||||
import { editor, designer } from './editor';
|
||||
|
||||
const dragon = designer.dragon;
|
||||
|
||||
const dragengine = {
|
||||
from (shell: Element, boost: (e: MouseEvent) => any): any {
|
||||
|
||||
},
|
||||
onDragstart(func: (e: any, dragment: any) => any) {
|
||||
return dragon.onDragstart((evt) => {
|
||||
func(evt.originalEvent, evt.dragObject.nodes[0]);
|
||||
});
|
||||
},
|
||||
onDrag (func: (e: any, dragment: any, location: Location) => any) {
|
||||
return dragon.onDrag((evt) => {
|
||||
const loc = designer.currentDocument?.dropLocation;
|
||||
func(evt.originalEvent, evt.dragObject.nodes[0]);
|
||||
});
|
||||
},
|
||||
onDragend (func: (dragment: any, location: Location, copy: any) => any) {
|
||||
|
||||
},
|
||||
addSensor (sensor: any) {
|
||||
|
||||
},
|
||||
removeSensor (sensor: any) {
|
||||
|
||||
},
|
||||
inDragging () {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
export default dragengine;
|
||||
@ -22,6 +22,7 @@ import Field from './field';
|
||||
import Prop from './prop';
|
||||
import Env from './env';
|
||||
import './vision.less';
|
||||
import DragEngine from './drag-engine';
|
||||
|
||||
function init(container?: Element) {
|
||||
if (!container) {
|
||||
@ -94,6 +95,7 @@ const VisualEngine = {
|
||||
Prototype,
|
||||
Bundle,
|
||||
Pages,
|
||||
DragEngine,
|
||||
};
|
||||
|
||||
export default VisualEngine;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user