forked from alibaba/lowcode-engine
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlocate-event.ts
More file actions
51 lines (40 loc) · 1.31 KB
/
locate-event.ts
File metadata and controls
51 lines (40 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { ILocateEvent } from '@felce/lowcode-designer';
import { locateEventSymbol } from '../symbols';
import { DragObject } from './drag-object';
import { IPublicModelLocateEvent, IPublicModelDragObject } from '@felce/lowcode-types';
export default class LocateEvent implements IPublicModelLocateEvent {
private readonly [locateEventSymbol]: ILocateEvent;
constructor(locateEvent: ILocateEvent) {
this[locateEventSymbol] = locateEvent;
}
static create(locateEvent: ILocateEvent): IPublicModelLocateEvent | null {
if (!locateEvent) {
return null;
}
return new LocateEvent(locateEvent);
}
get type(): string {
return this[locateEventSymbol].type;
}
get globalX(): number {
return this[locateEventSymbol].globalX;
}
get globalY(): number {
return this[locateEventSymbol].globalY;
}
get originalEvent(): MouseEvent | DragEvent {
return this[locateEventSymbol].originalEvent;
}
get target(): Element | null | undefined {
return this[locateEventSymbol].target;
}
get canvasX(): number | undefined {
return this[locateEventSymbol].canvasX;
}
get canvasY(): number | undefined {
return this[locateEventSymbol].canvasY;
}
get dragObject(): IPublicModelDragObject | null {
return DragObject.create(this[locateEventSymbol].dragObject);
}
}