@neo4j-nvl/interaction-handlers 0.2.27 → 0.2.28
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,18 +52,18 @@ export class HoverInteraction extends BaseInteraction {
|
|
|
52
52
|
value: (event) => {
|
|
53
53
|
const { nvlTargets } = this.nvlInstance.getHits(event);
|
|
54
54
|
const { nodes = [], relationships = [] } = nvlTargets;
|
|
55
|
-
const mainTarget = nodes[0]
|
|
55
|
+
const mainTarget = nodes[0] !== undefined ? nodes[0] : relationships[0];
|
|
56
56
|
const hoveredElement = mainTarget === null || mainTarget === void 0 ? void 0 : mainTarget.data;
|
|
57
57
|
if (this.currentElementNeedsUnHover(hoveredElement === null || hoveredElement === void 0 ? void 0 : hoveredElement.id)) {
|
|
58
58
|
this.unHoverCurrentElement();
|
|
59
59
|
}
|
|
60
|
-
const currentHoveredElementIsNode = hoveredElement && nodes[0] !== undefined;
|
|
60
|
+
const currentHoveredElementIsNode = hoveredElement !== undefined && nodes[0] !== undefined;
|
|
61
61
|
if (currentHoveredElementIsNode) {
|
|
62
62
|
this.updates.nodes.push({ id: hoveredElement.id, hovered: true });
|
|
63
63
|
this.currentHoveredElement = hoveredElement;
|
|
64
64
|
this.currentHoveredElementIsNode = true;
|
|
65
65
|
}
|
|
66
|
-
else if (mainTarget) {
|
|
66
|
+
else if (mainTarget !== undefined) {
|
|
67
67
|
const { id, from, to } = hoveredElement;
|
|
68
68
|
this.updates.relationships.push({ id, from, to, hovered: true });
|
|
69
69
|
this.currentHoveredElement = hoveredElement;
|
|
@@ -75,9 +75,12 @@ export class HoverInteraction extends BaseInteraction {
|
|
|
75
75
|
}
|
|
76
76
|
this.callCallbackIfRegistered('onHover', this.currentHoveredElement, nvlTargets, event);
|
|
77
77
|
// Use pure update API to avoid the previous removed node to be re-added to the scene.
|
|
78
|
-
this.options.drawShadowOnHover
|
|
79
|
-
this.nvlInstance.
|
|
80
|
-
|
|
78
|
+
if (this.options.drawShadowOnHover) {
|
|
79
|
+
const currentNodes = this.nvlInstance.getNodes();
|
|
80
|
+
if (currentNodes.length > 0) {
|
|
81
|
+
this.nvlInstance.updateElementsInGraph(this.updates.nodes, this.updates.relationships);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
81
84
|
this.clearUpdates();
|
|
82
85
|
}
|
|
83
86
|
});
|