Skip to content
Snippets Groups Projects
Commit 2b8f6b56 authored by Maximilian Giller's avatar Maximilian Giller
Browse files

Added backgroundClick event to tools

parent 0b44275e
No related branches found
No related tags found
No related merge requests found
......@@ -33,6 +33,13 @@ function downloadJson() {
window.location = link;
}
function extractPositions(event) {
return {
graph: { x: event.layerX, y: event.layerY },
window: { x: event.clientX, y: event.clientY },
};
}
function load() {
const graphContainer = document.getElementById("2d-graph");
const width = graphContainer.offsetWidth;
......@@ -50,6 +57,7 @@ function load() {
.linkDirectionalParticleWidth((link) =>
state.linkDirectionalParticleWidth(link)
)
.onBackgroundClick((event) => state.onBackgroundClick(event, extractPositions(event)))
.nodeCanvasObjectMode((node) => state.nodeCanvasObjectMode(node))
.nodeCanvasObject((node, ctx) => state.nodeCanvasObject(node, ctx))
.onLinkClick((link) => state.onLinkClick(link));
......
......@@ -183,6 +183,11 @@ class State extends Tool {
return this.isLinkHighlighted(link) ? LINK_PARTICLE_COUNT : 0;
}
onBackgroundClick(event, positions) {
console.log(event);
this.tool.onBackgroundClick(event, positions);
}
redraw() {
this.display.setSelectedTool(this.tool);
this.display.setSelectedItem(this.selectedItem);
......
......@@ -74,4 +74,12 @@ class Tool {
);
}
}
onBackgroundClick(event, positions) {
if (this.warnings) {
console.warn(
'Method "onBackgroundClick" not implemented.'
);
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment