MCPcopy Create free account
hub / github.com/DeepNotesApp/DeepNotes / NoteDragging

Class NoteDragging

apps/client/src/code/pages/page/notes/dragging.ts:18–265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16}
17
18export class NoteDragging {
19 readonly page: Page;
20
21 react: UnwrapRef<IDraggingReact>;
22
23 initialRegionId?: string;
24 finalRegionId?: string;
25
26 initialPointerPos: Vec2 = new Vec2();
27 originalNotePositions: Record<string, Vec2> = {};
28
29 private _cancelPointerEvents?: () => void;
30
31 constructor(input: { page: Page }) {
32 this.page = input.page;
33
34 this.react = refProp<IDraggingReact>(this, 'react', {
35 active: false,
36 });
37 }
38
39 start(params: { note: PageNote; event: PointerEvent }) {
40 if (this.page.react.readOnly) {
41 return;
42 }
43
44 // Prevent dragging unmovable notes
45
46 if (
47 this.page.activeElem.react.value?.type === 'note' &&
48 !this.page.activeElem.react.value.react.collab.movable
49 ) {
50 if (params.event.pointerType !== 'mouse') {
51 this.page.panning.start(params.event);
52 }
53
54 return;
55 }
56
57 this.react = { active: false };
58
59 this.initialPointerPos = this.page.pos.eventToClient(params.event);
60
61 this._cancelPointerEvents = listenPointerEvents(params.event, {
62 dragStartDistance: 5,
63
64 dragStart: () => this._dragStart(params),
65 dragUpdate: this._dragUpdate,
66 dragEnd: this._dragFinish,
67 });
68 }
69
70 private _dragStart = async (params: {
71 note: PageNote;
72 event: PointerEvent;
73 }) => {
74 this.initialRegionId = this.page.activeRegion.react.value.id;
75 this.finalRegionId = this.page.id;

Callers

nothing calls this directly

Calls 10

_dragOutMethod · 0.95
isCtrlDownFunction · 0.90
roundTimeToMinutesFunction · 0.90
removeMethod · 0.80
eventToClientMethod · 0.80
screenToWorld2DMethod · 0.80
subMethod · 0.80
absMethod · 0.80
addMethod · 0.45
performMethod · 0.45

Tested by

no test coverage detected