Skip to content

Commit

Permalink
fix: retrieve element type directly from pointerleave event (#6383)
Browse files Browse the repository at this point in the history
* fix: retrieve element type directly from pointerleave event

* fix: update
  • Loading branch information
yvonneyx authored Oct 9, 2024
1 parent f35530d commit e020c32
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class HoverElement extends HoverActivate {
protected getActiveIds(event: IPointerEvent<Element>) {
const { model, graph } = this.context;
const elementId = event.target.id;
const elementType = graph.getElementType(elementId);
const { targetType: elementType } = event;

const ids = [elementId];
if (elementType === 'edge') {
Expand Down
5 changes: 2 additions & 3 deletions packages/g6/src/behaviors/hover-activate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { isFunction } from '@antv/util';
import { CommonEvent } from '../constants';
import { ELEMENT_TYPES } from '../constants/element';
import type { RuntimeContext } from '../runtime/types';
import type { EdgeDirection, Element, ID, IDragEvent, IPointerEvent, State } from '../types';
import type { EdgeDirection, Element, ElementType, ID, IDragEvent, IPointerEvent, State } from '../types';
import { isToBeDestroyed } from '../utils/element';
import { idsOf } from '../utils/id';
import { getElementNthDegreeIds } from '../utils/relation';
Expand Down Expand Up @@ -138,12 +138,11 @@ export class HoverActivate extends BaseBehavior<HoverActivateOptions> {
const { graph } = this.context;
const { degree, direction } = this.options;
const elementId = event.target.id;
const elementType = graph.getElementType(elementId);

return degree
? getElementNthDegreeIds(
graph,
elementType,
event.targetType as ElementType,
elementId,
typeof degree === 'function' ? degree(event) : degree,
direction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ const COLOR_MAP = {
class HoverElement extends HoverActivate {
getActiveIds(event) {
const { model, graph } = this.context;
const targetId = event.target.id;
const targetType = graph.getElementType(targetId);
const { targetType, target } = event;
const targetId = target.id;

const ids = [targetId];
if (targetType === 'edge') {
Expand Down

0 comments on commit e020c32

Please sign in to comment.