Compare commits

...

2 Commits

Author SHA1 Message Date
c9494e7f79 chore(release): 🚀 publish 2022-10-25 10:52:36 +08:00
1e7f132bed fix: 🐛 fix the error in selected nodes position when snapline enabled (#2797) 2022-10-24 21:39:08 +08:00
4 changed files with 9 additions and 3 deletions

View File

@ -3,6 +3,7 @@ import { Graph, Node, Cell } from '@antv/x6'
import { Path } from '@antv/x6-geometry'
import { register } from '@antv/x6-react-shape'
import { Selection } from '@antv/x6-plugin-selection'
import { Snapline } from '@antv/x6-plugin-snapline'
import '../index.less'
import './index.less'
interface NodeStatus {
@ -381,6 +382,7 @@ export default class Example extends React.Component {
rubberband: true,
})
graph.use(selection)
graph.use(new Snapline({ enabled: true }))
graph.on('edge:connected', ({ edge }) => {
edge.attr({

View File

@ -1,5 +1,5 @@
{
"version": "2.0.6-beta.21",
"version": "2.0.6-beta.22",
"npmClient": "yarn",
"useWorkspaces": true,
"command": {

View File

@ -1,6 +1,6 @@
{
"name": "@antv/x6-plugin-selection",
"version": "2.0.6-beta.20",
"version": "2.0.6-beta.22",
"description": "selection plugin for X6.",
"main": "lib/index.js",
"module": "es/index.js",

View File

@ -119,7 +119,8 @@ export class SelectionImpl extends View<SelectionImpl.EventArgs> {
options,
}: Collection.EventArgs['node:change:position']) {
const { showNodeSelectionBox, pointerEvents } = this.options
const { ui, selection, translateBy } = options
const { ui, selection, translateBy, snapped } = options
let allowTranslating = !this.translating
/* Scenarios where this method is not called:
@ -135,6 +136,9 @@ export class SelectionImpl extends View<SelectionImpl.EventArgs> {
allowTranslating =
allowTranslating && translateBy && node.id === translateBy
// enabled when snapline snapped
allowTranslating = allowTranslating || snapped
if (allowTranslating) {
this.translating = true
const current = node.position()