User Interactions
The user can interact with the graph in several ways, like zooming, dragging, pagging, hovering and clicking. Each individual action can be turned off, and some of the behaviour can also be customized.
Zooming
When the enableZoom
configuration is enabled, the user can zoom in and out of the graph using the mouse wheel.
If enablePan
is disabled, the zoom will be from the center of the graph, and not from the mouse cursor.
Panning
When the enablePan
configuration is enabled, the user can drag the graph around using the mouse.
Dragging
When the enableDrag
configuration is enabled, the user can drag nodes around the graph.
The dragged nodes will still be subject to the physics simulation, so they will eventually return to a stable position.
Hovering
When the enableHover
configuration is enabled, the user can hover over nodes to apply their hovered styles.
Clicking
When the enableClick
configuration is enabled, the user can click on nodes to follow the link to the node’s page.
This settings has four options:
auto
: The default option, require a double click for the link to be followed on mobile devices, and a single click on desktop.disable
: The link is never followed.click
: The link is followed on a single click.dblclick
: The link is followed on a double click.
Link Following
The followLink
configuration determines what happens when a node with a valid link is clicked.
same
: The link is opened in the same tab.new-tab
: The link is opened in a new tab.graph
: The clicked node is set as the current node in the graph.
By default, a link is opened in the same tab. External links will always be opened in a new tab (regardless of this setting).
Page Prefetching
The prefetchPages
configuration determines whether a page should be prefetched when it is hovered over.
Behind the scenes, this is calling Astro:prefetch
’s prefetch
method.