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

feat: add hover-element behavior #5579

Merged
merged 8 commits into from Mar 25, 2024
Merged

feat: add hover-element behavior #5579

merged 8 commits into from Mar 25, 2024

Conversation

yvonneyx
Copy link
Contributor

@yvonneyx yvonneyx commented Mar 22, 2024

hover-element Behavior

引入新命名交互 hover-element,结合实现旧版 hover-activateactivate-relations 功能

配置项如下:

interface HoverElementOptions extends BaseBehaviorOptions {
  /**
   * <zh/> 是否启用动画
   *
   * <en/> Whether to enable animation
   */
  animation?: boolean;
  /**
   * <zh/> 是否启用悬浮元素的功能
   *
   * <en/> Whether to enable hover element function
   */
  enable?: boolean | ((event: BehaviorEvent<FederatedMouseEvent>) => boolean);
  /**
   * <zh/> 激活悬停元素的n度关系,默认为0,表示只激活当前节点,1表示激活当前节点及其直接相邻的节点和边,以此类推
   *
   * <en/> N-degree relationship of the hovered element, default to 0, which means only the current node is activated, 1 means the current node and its directly adjacent nodes and edges are activated, etc
   */
  degree?: number;
  /**
   * <zh/> 激活元素的状态,默认为 active
   *
   * <en/> Active element state, default to active
   */
  activeState?: State;
  /**
   * <zh/> 非激活元素的状态,默认为 undefined
   *
   * <en/> Inactive element state, default to default
   */
  inactiveState?: State;
  /**
   * <zh/> 当元素被悬停时的回调
   *
   * <en/> Callback when the element is hovered
   */
  onHover?: (event: BehaviorEvent<FederatedMouseEvent>) => void;
  /**
   * <zh/> 当悬停结束时的回调
   *
   * <en/> Callback when the hover ends
   */
  onHoverEnd?: (event: BehaviorEvent<FederatedMouseEvent>) => void;
}

@Aarebecca
Copy link
Contributor

Aarebecca commented Mar 22, 2024

  • 这里可能不用提供动画配置项,默认走元素动画配置吧
  • enableElements 用单数(enableElement)但是复数更好呢 @hustcc
  • idleState 感觉有点怪怪的
  • onfinish 和 onhover 不是很配对的样子

@hustcc
Copy link
Member

hustcc commented Mar 22, 2024

要不直接 enable 中回调自己处理,不加 enableElement配置?

context menu 也有类似的配置,保持统一即可。

@hustcc
Copy link
Member

hustcc commented Mar 25, 2024

onhover 这类回调函数,我们使用驼峰吧!

packages/g6/src/behaviors/hover-element.ts Outdated Show resolved Hide resolved
packages/g6/src/constants/element.ts Outdated Show resolved Hide resolved
packages/g6/src/behaviors/hover-element.ts Outdated Show resolved Hide resolved
@yvonneyx yvonneyx merged commit 5566f74 into v5 Mar 25, 2024
5 checks passed
@yvonneyx yvonneyx deleted the feat/hover-element branch March 25, 2024 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate ActivateRelations Migrate HoverActivate Behavior
3 participants