@neo4j-nvl/interaction-handlers 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -1
- package/README.md +8 -0
- package/lib/constants.d.ts +1 -1
- package/lib/constants.js +4 -2
- package/lib/index.d.ts +10 -20
- package/lib/index.js +10 -10
- package/lib/interaction-handlers/base.d.ts +67 -67
- package/lib/interaction-handlers/base.js +98 -104
- package/lib/interaction-handlers/box-select-interaction.d.ts +44 -44
- package/lib/interaction-handlers/box-select-interaction.js +133 -127
- package/lib/interaction-handlers/click-interaction.d.ts +111 -111
- package/lib/interaction-handlers/click-interaction.js +116 -131
- package/lib/interaction-handlers/drag-node-interaction.d.ts +40 -40
- package/lib/interaction-handlers/drag-node-interaction.js +102 -111
- package/lib/interaction-handlers/draw-interaction.d.ts +37 -37
- package/lib/interaction-handlers/draw-interaction.js +245 -278
- package/lib/interaction-handlers/hover-interaction.d.ts +34 -30
- package/lib/interaction-handlers/hover-interaction.js +83 -89
- package/lib/interaction-handlers/keyboard-interaction.d.ts +149 -97
- package/lib/interaction-handlers/keyboard-interaction.js +255 -201
- package/lib/interaction-handlers/lasso-interaction.d.ts +45 -45
- package/lib/interaction-handlers/lasso-interaction.js +174 -196
- package/lib/interaction-handlers/pan-interaction.d.ts +62 -61
- package/lib/interaction-handlers/pan-interaction.js +111 -100
- package/lib/interaction-handlers/utils.d.ts +2 -2
- package/lib/interaction-handlers/utils.js +39 -38
- package/lib/interaction-handlers/zoom-interaction.d.ts +52 -48
- package/lib/interaction-handlers/zoom-interaction.js +73 -71
- package/lib/overlay-renderer/overlay-renderer.d.ts +13 -13
- package/lib/overlay-renderer/overlay-renderer.js +96 -111
- package/package.json +19 -6
- package/lib/__tests__/box-select-interaction.test.d.ts +0 -1
- package/lib/__tests__/box-select-interaction.test.js +0 -149
- package/lib/__tests__/click-interaction.test.d.ts +0 -1
- package/lib/__tests__/click-interaction.test.js +0 -505
- package/lib/__tests__/drag-node-interaction.test.d.ts +0 -1
- package/lib/__tests__/drag-node-interaction.test.js +0 -247
- package/lib/__tests__/hover-interaction.test.d.ts +0 -1
- package/lib/__tests__/hover-interaction.test.js +0 -374
- package/lib/__tests__/keyboard-interaction.test.d.ts +0 -1
- package/lib/__tests__/keyboard-interaction.test.js +0 -322
- package/lib/__tests__/lasso-interaction.test.d.ts +0 -1
- package/lib/__tests__/lasso-interaction.test.js +0 -219
- package/lib/__tests__/pan-interaction.test.d.ts +0 -1
- package/lib/__tests__/pan-interaction.test.js +0 -223
- package/lib/__tests__/utils.test.d.ts +0 -1
- package/lib/__tests__/utils.test.js +0 -19
- package/lib/__tests__/zoom-interaction.test.d.ts +0 -1
- package/lib/__tests__/zoom-interaction.test.js +0 -185
|
@@ -1,205 +1,183 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
1
|
+
import "../constants.js";
|
|
2
|
+
import { OverlayRenderer } from "../overlay-renderer/overlay-renderer.js";
|
|
3
|
+
import { BaseInteraction } from "./base.js";
|
|
4
|
+
import { getCanvasPosition, getWorldPosition, isDraggingMovement } from "./utils.js";
|
|
5
|
+
import concaveman from "concaveman";
|
|
6
|
+
// src/interaction-handlers/lasso-interaction.ts
|
|
6
7
|
const pointDist = 10;
|
|
7
8
|
const shapeShowTime = 500;
|
|
8
9
|
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const t1 = ((p1[1] - p3[1]) * (p4[0] - p3[0]) - (p1[0] - p3[0]) * (p4[1] - p3[1])) / denom;
|
|
20
|
-
const t2 = ((p3[0] - p1[0]) * (p2[1] - p1[1]) - (p3[1] - p1[1]) * (p2[0] - p1[0])) / denom;
|
|
21
|
-
return t1 > 0 && t1 < 1 && t2 > 0 && t2 < 1;
|
|
10
|
+
* Checks if two lines defined by p1->p2 and p3->p4 are crossing.
|
|
11
|
+
* @internal
|
|
12
|
+
* @hidden
|
|
13
|
+
*/
|
|
14
|
+
const checkLinesCrossing = (p1, p2, p3, p4) => {
|
|
15
|
+
const denom = (p4[1] - p3[1]) * (p2[0] - p1[0]) - (p4[0] - p3[0]) * (p2[1] - p1[1]);
|
|
16
|
+
if (denom === 0) return false;
|
|
17
|
+
const t1 = ((p1[1] - p3[1]) * (p4[0] - p3[0]) - (p1[0] - p3[0]) * (p4[1] - p3[1])) / denom;
|
|
18
|
+
const t2 = ((p3[0] - p1[0]) * (p2[1] - p1[1]) - (p3[1] - p1[1]) * (p2[0] - p1[0])) / denom;
|
|
19
|
+
return t1 > 0 && t1 < 1 && t2 > 0 && t2 < 1;
|
|
22
20
|
};
|
|
23
21
|
/**
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (checkLinesCrossing(line1p1, line1p2, line2p1, line2p2)) {
|
|
38
|
-
return true;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return false;
|
|
22
|
+
* Checks if any line segments in the polygon intersect.
|
|
23
|
+
* @internal
|
|
24
|
+
* @hidden
|
|
25
|
+
*/
|
|
26
|
+
const checkIntersection = (polygon) => {
|
|
27
|
+
for (let i = 0; i < polygon.length - 1; i++) for (let j = i + 2; j < polygon.length; j++) {
|
|
28
|
+
const line1p1 = polygon[i] ?? [0, 0];
|
|
29
|
+
const line1p2 = polygon[i + 1] ?? [0, 0];
|
|
30
|
+
const line2p1 = polygon[j] ?? [0, 0];
|
|
31
|
+
const line2p2 = polygon[j < polygon.length - 1 ? j + 1 : 0] ?? [0, 0];
|
|
32
|
+
if (checkLinesCrossing(line1p1, line1p2, line2p1, line2p2)) return true;
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
43
35
|
};
|
|
44
36
|
/**
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const { x: xj, y: yj } = vsJ;
|
|
61
|
-
const intersect = yi > y !== yj > y && x < ((xj - xi) * (y - yi)) / (yj - yi) + xi;
|
|
62
|
-
if (intersect) {
|
|
63
|
-
isInside = !isInside;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return isInside;
|
|
37
|
+
* Checks if the point (x, y) is inside the polygon defined by vs.
|
|
38
|
+
* @internal
|
|
39
|
+
* @hidden
|
|
40
|
+
*/
|
|
41
|
+
const checkPointInside = (x, y, vs) => {
|
|
42
|
+
let isInside = false;
|
|
43
|
+
for (let i = 0, j = vs.length - 1; i < vs.length; j = i, i += 1) {
|
|
44
|
+
const vsI = vs[i];
|
|
45
|
+
const vsJ = vs[j];
|
|
46
|
+
if (vsI === void 0 || vsJ === void 0) continue;
|
|
47
|
+
const { x: xi, y: yi } = vsI;
|
|
48
|
+
const { x: xj, y: yj } = vsJ;
|
|
49
|
+
if (yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi) isInside = !isInside;
|
|
50
|
+
}
|
|
51
|
+
return isInside;
|
|
67
52
|
};
|
|
68
53
|
/**
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
this.toggleGlobalTextSelection(true, this.endLasso);
|
|
200
|
-
this.removeEventListener('mousedown', this.handleMouseDown, true);
|
|
201
|
-
this.removeEventListener('mousemove', this.handleDrag, true);
|
|
202
|
-
this.removeEventListener('mouseup', this.handleMouseUp, true);
|
|
203
|
-
this.overlayRenderer.destroy();
|
|
204
|
-
}
|
|
205
|
-
}
|
|
54
|
+
* An interaction handler that lets you select nodes and relationships by drawing a lasso around them.
|
|
55
|
+
* When dragging, a line is drawn on the scene and all elements inside are selected.
|
|
56
|
+
*
|
|
57
|
+
* For examples, head to the {@link https://neo4j.com/docs/nvl/current/interaction-handlers/#_lassointeraction Lasso Interaction documentation page}.
|
|
58
|
+
*/
|
|
59
|
+
var LassoInteraction = class extends BaseInteraction {
|
|
60
|
+
active = false;
|
|
61
|
+
lassoPending = false;
|
|
62
|
+
startClientPosition = {
|
|
63
|
+
x: 0,
|
|
64
|
+
y: 0
|
|
65
|
+
};
|
|
66
|
+
pendingPointerCanvas = {
|
|
67
|
+
x: 0,
|
|
68
|
+
y: 0
|
|
69
|
+
};
|
|
70
|
+
points = [];
|
|
71
|
+
overlayRenderer;
|
|
72
|
+
/**
|
|
73
|
+
* Creates a new instance of the lasso interaction handler.
|
|
74
|
+
* @param nvl - The NVL instance to attach the interaction handler to.
|
|
75
|
+
* @param options - Options for the lasso interaction handler to customize its behavior.
|
|
76
|
+
*/
|
|
77
|
+
constructor(nvl, options = { selectOnRelease: false }) {
|
|
78
|
+
super(nvl, options);
|
|
79
|
+
this.overlayRenderer = new OverlayRenderer(this.containerInstance);
|
|
80
|
+
this.addEventListener("mousedown", this.handleMouseDown, true);
|
|
81
|
+
this.addEventListener("mousemove", this.handleDrag, true);
|
|
82
|
+
this.addEventListener("mouseup", this.handleMouseUp, true);
|
|
83
|
+
}
|
|
84
|
+
startLasso = (event) => {
|
|
85
|
+
if (this.nvlInstance.getHits(event, ["node"], { hitNodeMarginWidth: 10 }).nvlTargets.nodes.length > 0) {
|
|
86
|
+
this.active = false;
|
|
87
|
+
this.lassoPending = false;
|
|
88
|
+
} else {
|
|
89
|
+
this.lassoPending = true;
|
|
90
|
+
this.startClientPosition = {
|
|
91
|
+
x: event.clientX,
|
|
92
|
+
y: event.clientY
|
|
93
|
+
};
|
|
94
|
+
this.pendingPointerCanvas = getCanvasPosition(this.containerInstance, event);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
handleMouseDown = (event) => {
|
|
98
|
+
if (event.button === 0 && !this.active && !this.lassoPending) this.startLasso(event);
|
|
99
|
+
};
|
|
100
|
+
handleDrag = (event) => {
|
|
101
|
+
if (this.active) {
|
|
102
|
+
const lastPoint = this.points[this.points.length - 1];
|
|
103
|
+
if (lastPoint === void 0) return;
|
|
104
|
+
const pos = getCanvasPosition(this.containerInstance, event);
|
|
105
|
+
const dx = Math.abs(lastPoint.x - pos.x);
|
|
106
|
+
const dy = Math.abs(lastPoint.y - pos.y);
|
|
107
|
+
if (dx > pointDist || dy > pointDist) {
|
|
108
|
+
this.points.push(pos);
|
|
109
|
+
this.overlayRenderer.drawLasso(this.points, true, false);
|
|
110
|
+
}
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (this.lassoPending && event.buttons === 1) {
|
|
114
|
+
if (isDraggingMovement(event, this.startClientPosition)) this.activateLasso(event);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
activateLasso = (event) => {
|
|
118
|
+
this.lassoPending = false;
|
|
119
|
+
this.active = true;
|
|
120
|
+
const pos = getCanvasPosition(this.containerInstance, event);
|
|
121
|
+
this.points = [this.pendingPointerCanvas, pos];
|
|
122
|
+
this.toggleGlobalTextSelection(false, this.endLasso);
|
|
123
|
+
this.callCallbackIfRegistered("onLassoStarted", event);
|
|
124
|
+
if (this.currentOptions.selectOnRelease === true) this.nvlInstance.deselectAll();
|
|
125
|
+
this.overlayRenderer.drawLasso(this.points, true, false);
|
|
126
|
+
};
|
|
127
|
+
handleMouseUp = (event) => {
|
|
128
|
+
if (!this.active) {
|
|
129
|
+
this.lassoPending = false;
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
this.points.push(getCanvasPosition(this.containerInstance, event));
|
|
133
|
+
this.endLasso(event);
|
|
134
|
+
};
|
|
135
|
+
getLassoItems = (points) => {
|
|
136
|
+
const worldPoints = points.map((p) => getWorldPosition(this.nvlInstance, p));
|
|
137
|
+
const nodePositions = this.nvlInstance.getNodePositions();
|
|
138
|
+
const hitNodes = /* @__PURE__ */ new Set();
|
|
139
|
+
for (const pos of nodePositions) {
|
|
140
|
+
if (pos.x === void 0 || pos.y === void 0 || pos.id === void 0) continue;
|
|
141
|
+
if (checkPointInside(pos.x, pos.y, worldPoints)) hitNodes.add(pos.id);
|
|
142
|
+
}
|
|
143
|
+
const rels = this.nvlInstance.getRelationships();
|
|
144
|
+
const hitRels = [];
|
|
145
|
+
for (const rel of rels) if (hitNodes.has(rel.from) && hitNodes.has(rel.to)) hitRels.push(rel);
|
|
146
|
+
return {
|
|
147
|
+
nodes: Array.from(hitNodes).map((id) => this.nvlInstance.getNodeById(id)),
|
|
148
|
+
rels: hitRels
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
endLasso = (event) => {
|
|
152
|
+
if (!this.active) return;
|
|
153
|
+
this.active = false;
|
|
154
|
+
this.toggleGlobalTextSelection(true, this.endLasso);
|
|
155
|
+
const pointArrays = this.points.map((p) => [p.x, p.y]);
|
|
156
|
+
const hull = (checkIntersection(pointArrays) ? concaveman(pointArrays, 2) : pointArrays).map((p) => ({
|
|
157
|
+
x: p[0],
|
|
158
|
+
y: p[1]
|
|
159
|
+
})).filter((point) => point.x !== void 0 && point.y !== void 0);
|
|
160
|
+
this.overlayRenderer.drawLasso(hull, false, true);
|
|
161
|
+
setTimeout(() => this.overlayRenderer.clear(), shapeShowTime);
|
|
162
|
+
const hitItems = this.getLassoItems(hull);
|
|
163
|
+
if (this.currentOptions.selectOnRelease === true) this.nvlInstance.updateElementsInGraph(hitItems.nodes.map((node) => ({
|
|
164
|
+
id: node.id,
|
|
165
|
+
selected: true
|
|
166
|
+
})), hitItems.rels.map((rel) => ({
|
|
167
|
+
id: rel.id,
|
|
168
|
+
selected: true
|
|
169
|
+
})));
|
|
170
|
+
this.callCallbackIfRegistered("onLassoSelect", hitItems, event);
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* Removes all related event listeners and the overlay renderer for the box.
|
|
174
|
+
*/
|
|
175
|
+
destroy() {
|
|
176
|
+
this.toggleGlobalTextSelection(true, this.endLasso);
|
|
177
|
+
this.removeEventListener("mousedown", this.handleMouseDown, true);
|
|
178
|
+
this.removeEventListener("mousemove", this.handleDrag, true);
|
|
179
|
+
this.removeEventListener("mouseup", this.handleMouseUp, true);
|
|
180
|
+
this.overlayRenderer.destroy();
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
export { LassoInteraction, checkIntersection, checkLinesCrossing, checkPointInside };
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { BaseInteraction } from "./base.js";
|
|
2
|
+
import { NVL } from "@neo4j-nvl/base";
|
|
3
3
|
/**
|
|
4
4
|
* Options for the pan interaction handler to customize its behavior.
|
|
5
5
|
*/
|
|
6
6
|
export type PanInteractionOptions = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Whether to not pan when dragging within a certain margin of a node
|
|
9
|
+
* @defaultValue false
|
|
10
|
+
*/
|
|
11
|
+
excludeNodeMargin?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* If true, the interaction handler will not update the NVL instance directly.
|
|
14
|
+
* Instead, it will only call the onPan callback with the calculated values,
|
|
15
|
+
* allowing the parent application to control when and how to apply the pan update.
|
|
16
|
+
* @defaultValue false
|
|
17
|
+
*/
|
|
18
|
+
controlledPan?: boolean;
|
|
19
19
|
};
|
|
20
20
|
/**
|
|
21
21
|
* Callbacks for the pan interaction handler.
|
|
22
22
|
*/
|
|
23
23
|
export type PanInteractionCallbacks = {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Called when the canvas is panned.
|
|
26
|
+
* @param panning - The panning coordinates.
|
|
27
|
+
* @param event - The original mouse event.
|
|
28
|
+
*/
|
|
29
|
+
onPan?: ((panning: {
|
|
30
|
+
x: number;
|
|
31
|
+
y: number;
|
|
32
|
+
}, event: MouseEvent) => void) | boolean;
|
|
33
33
|
};
|
|
34
34
|
/**
|
|
35
35
|
* Interaction handler for panning the scene, which is achieved by clicking and moving the scene.
|
|
@@ -37,41 +37,42 @@ export type PanInteractionCallbacks = {
|
|
|
37
37
|
* For examples, head to the {@link https://neo4j.com/docs/nvl/current/interaction-handlers/#_paninteraction Pan Interaction documentation page}.
|
|
38
38
|
*/
|
|
39
39
|
export declare class PanInteraction extends BaseInteraction<PanInteractionOptions> {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
40
|
+
private initialMousePosition;
|
|
41
|
+
private initialPan;
|
|
42
|
+
private targets;
|
|
43
|
+
private shouldPan;
|
|
44
|
+
private isPanning;
|
|
45
|
+
/**
|
|
46
|
+
* Creates a new instance of the pan interaction handler.
|
|
47
|
+
* @param nvl - The NVL instance to attach the interaction handler to.
|
|
48
|
+
*/
|
|
49
|
+
constructor(nvl: NVL, options?: PanInteractionOptions);
|
|
50
|
+
/**
|
|
51
|
+
* Updates which type of graph elements should hinder panning.
|
|
52
|
+
* @param targets - The graph elements that should hinder panning.
|
|
53
|
+
* @param excludeNodeMargin - If true, the node margin will not hinder panning.
|
|
54
|
+
* By default, panning is hindered by nodes and relationships.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* import { NVL } from '@neo4j-nvl/base'
|
|
59
|
+
* import { PanInteraction } from '@neo4j-nvl/interaction-handlers'
|
|
60
|
+
*
|
|
61
|
+
* const nvl = new NVL(document.createElement('div'), [{ id: '0' }], [])
|
|
62
|
+
*
|
|
63
|
+
* const panInteraction = new PanInteraction(nvl)
|
|
64
|
+
*
|
|
65
|
+
* // Pan canvas even when dragging on nodes and relationships
|
|
66
|
+
* panInteraction.updateTargets([], true)
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
updateTargets: (targets: ("node" | "relationship")[], excludeNodeMargin: boolean) => void;
|
|
70
|
+
private handleMouseDown;
|
|
71
|
+
private handleMouseMove;
|
|
72
|
+
private handleMouseUp;
|
|
73
|
+
private resetPanState;
|
|
74
|
+
/**
|
|
75
|
+
* Removes the related event listeners from the canvas.
|
|
76
|
+
*/
|
|
77
|
+
destroy(): void;
|
|
78
|
+
}
|