@neo4j-nvl/interaction-handlers 0.2.17 → 0.2.19
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.
|
@@ -52,6 +52,7 @@ export declare class PanInteraction extends BaseInteraction<PanInteractionCallba
|
|
|
52
52
|
updateTargets: (targets: Array<'node' | 'relationship'>, excludeNodeMargin: boolean) => void;
|
|
53
53
|
private handleMouseDown;
|
|
54
54
|
private handleMouseMove;
|
|
55
|
+
private handleMouseUp;
|
|
55
56
|
/**
|
|
56
57
|
* Removes the related event listeners from the canvas.
|
|
57
58
|
*/
|
|
@@ -100,12 +100,21 @@ export class PanInteraction extends BaseInteraction {
|
|
|
100
100
|
this.mousePosition = { x: evt.clientX, y: evt.clientY };
|
|
101
101
|
}
|
|
102
102
|
});
|
|
103
|
+
Object.defineProperty(this, "handleMouseUp", {
|
|
104
|
+
enumerable: true,
|
|
105
|
+
configurable: true,
|
|
106
|
+
writable: true,
|
|
107
|
+
value: () => {
|
|
108
|
+
this.shouldPan = false;
|
|
109
|
+
}
|
|
110
|
+
});
|
|
103
111
|
this.mousePosition = { x: 0, y: 0 };
|
|
104
112
|
this.targets = [];
|
|
105
113
|
this.excludeNodeMargin = false;
|
|
106
114
|
this.shouldPan = false;
|
|
107
115
|
this.addEventListener('mousedown', this.handleMouseDown, true);
|
|
108
116
|
this.addEventListener('mousemove', this.handleMouseMove, true);
|
|
117
|
+
this.addEventListener('mouseup', this.handleMouseUp, true);
|
|
109
118
|
}
|
|
110
119
|
/**
|
|
111
120
|
* Removes the related event listeners from the canvas.
|
|
@@ -113,5 +122,6 @@ export class PanInteraction extends BaseInteraction {
|
|
|
113
122
|
destroy() {
|
|
114
123
|
this.removeEventListener('mousedown', this.handleMouseDown, true);
|
|
115
124
|
this.removeEventListener('mousemove', this.handleMouseMove, true);
|
|
125
|
+
this.removeEventListener('mouseup', this.handleMouseUp, true);
|
|
116
126
|
}
|
|
117
127
|
}
|
|
@@ -26,8 +26,6 @@ export type ZoomInteractionCallbacks = {
|
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
28
|
export declare class ZoomInteraction extends BaseInteraction<ZoomInteractionCallbacks> {
|
|
29
|
-
private MinZoom;
|
|
30
|
-
private MaxZoom;
|
|
31
29
|
/**
|
|
32
30
|
* Creates a new instance of the zoom interaction handler.
|
|
33
31
|
* @param nvl - The NVL instance to attach the interaction handler to
|
|
@@ -21,18 +21,6 @@ export class ZoomInteraction extends BaseInteraction {
|
|
|
21
21
|
*/
|
|
22
22
|
constructor(nvl) {
|
|
23
23
|
super(nvl);
|
|
24
|
-
Object.defineProperty(this, "MinZoom", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
configurable: true,
|
|
27
|
-
writable: true,
|
|
28
|
-
value: void 0
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(this, "MaxZoom", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
configurable: true,
|
|
33
|
-
writable: true,
|
|
34
|
-
value: void 0
|
|
35
|
-
});
|
|
36
24
|
/**
|
|
37
25
|
* Throttled zoom function to avoid events happening too fast.
|
|
38
26
|
* @param event - The original mouse wheel event
|
|
@@ -53,9 +41,6 @@ export class ZoomInteraction extends BaseInteraction {
|
|
|
53
41
|
const { x, y } = this.nvlInstance.getPan();
|
|
54
42
|
const factor = event.deltaY / 500;
|
|
55
43
|
const newZoomTarget = zoom - factor * Math.min(1, zoom);
|
|
56
|
-
if (newZoomTarget < this.MinZoom || newZoomTarget > this.MaxZoom) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
44
|
const { offsetX, offsetY } = this.nvlInstance.getMouseElementCoordinates(event);
|
|
60
45
|
const newPanX = x + (offsetX / zoom - offsetX / newZoomTarget);
|
|
61
46
|
const newPanY = y + (offsetY / zoom - offsetY / newZoomTarget);
|
|
@@ -83,8 +68,6 @@ export class ZoomInteraction extends BaseInteraction {
|
|
|
83
68
|
this.removeEventListener('wheel', this.handleWheel);
|
|
84
69
|
}
|
|
85
70
|
});
|
|
86
|
-
this.MinZoom = 0.1;
|
|
87
|
-
this.MaxZoom = 5;
|
|
88
71
|
this.addEventListener('wheel', this.handleWheel);
|
|
89
72
|
}
|
|
90
73
|
}
|