antvis/G6

gForce布局下拖动节点后想通过其他事件固定节点,节点会偏移 #4461

MorningStarHu posted onGitHub

Describe the bug

官网的demo 在gForce布局下拖动节点后固定没有问题,但是想通过其他事件固定节点,节点会产生偏移,我在想使用的鼠标右键点击固定,

Your Example Website or App

https://codesandbox.io/s/649wns?file=/index.js

Steps to Reproduce the Bug or Issue

1、使用官方demo https://g6.antv.antgroup.com/zh/examples/net/forceDirected#gForceFix 2、原先的refreshDragedNodePosition函数改为 refreshDragedNodePosition(e) { const model = e.item.get('model'); model.x = e.x; model.y = e.y; } 为了方便查看 我把nodeStrength改为了800,nodesize:40 2、在原有的代码上添加右键点击固定的逻辑 graph.on('node:contextmenu', function (e) { const model = e.item.get('model'); model.fx = e.x; model.fy = e.y; graph.layout() });

Expected behavior

右键点击后节点固定不偏移

Screenshots or Videos

No response

Platform

  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]
  • Version: [e.g. 91.1]

Additional context

No response


Fund this Issue

$0.00
Funded

Pull requests