Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Component | Graph: Fixing pointer-events issues; Configurable link highlight on hover #14

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/ts/src/components/graph/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ export interface GraphConfigInterface<N extends GraphInputNode, L extends GraphI
* `1.5` - very curve.
* Default: `0` */
linkCurvature?: NumericAccessor<L>;
/** Highlight links on hover. Default: `true` */
linkHighlightOnHover?: boolean;
/** Set selected link by its unique id. Default: `undefined` */
selectedLinkId?: number | string;

Expand Down Expand Up @@ -316,6 +318,7 @@ export const GraphDefaultConfig: GraphConfigInterface<GraphInputNode, GraphInput
linkNeighborSpacing: 8,
linkDisabled: false,
linkCurvature: 0,
linkHighlightOnHover: true,
selectedLinkId: undefined,
nodeGaugeAnimDuration: 1500,

Expand Down
10 changes: 2 additions & 8 deletions packages/ts/src/components/graph/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export class Graph<
dimmedNode: nodeSelectors.greyedOutNode,
link: linkSelectors.gLink,
linkLine: linkSelectors.link,
linkLabel: linkSelectors.linkLabelGroup,
dimmedLink: linkSelectors.greyedOutLink,
panel: panelSelectors.gPanel,
panelRect: panelSelectors.panel,
Expand Down Expand Up @@ -295,13 +296,6 @@ export class Graph<
if (disableZoom) this.g.on('.zoom', null)
else this.g.call(this._zoomBehavior).on('dblclick.zoom', null)

// While the graph is animating we disable pointer events on the graph group
if (animDuration) { this._graphGroup.attr('pointer-events', 'none') }
smartTransition(this._graphGroup, animDuration)
.on('end interrupt', () => {
this._graphGroup.attr('pointer-events', null)
})

// We need to set up events and attributes again because the rendering might have been delayed by the layout
// calculation and they were not set up properly (see the render function of `ComponentCore`)
this._setUpComponentEventsThrottled()
Expand Down Expand Up @@ -643,7 +637,7 @@ export class Graph<
private _onLinkMouseOver (d: GraphLink<N, L>): void {
if (this._isDragging) return

d._state.hovered = true
if (this.config.linkHighlightOnHover) d._state.hovered = true
this._updateNodesLinksPartial()
}

Expand Down
2 changes: 0 additions & 2 deletions packages/ts/src/components/graph/modules/link/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export const linkSupport = css`

fill: none;
stroke-linecap: round;
pointer-events: stroke;
stroke-width: var(--vis-graph-link-support-stroke-width);
stroke-opacity: 0;
stroke: var(--vis-graph-link-stroke-color);
Expand Down Expand Up @@ -108,7 +107,6 @@ export const flowCircle = css`

export const linkLabelGroup = css`
label: label-group;
pointer-events: all;
`

export const linkLabelBackground = css`
Expand Down