-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(behaviors): fix drag element, drag canvas conflict (#6125)
Co-authored-by: antv <antv@antfin.com>
- Loading branch information
Showing
5 changed files
with
75 additions
and
5 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
packages/g6/__tests__/bugs/behaviors-multiple-conflict.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { createGraph, dispatchCanvasEvent } from '@@/utils'; | ||
import { CommonEvent, NodeEvent } from '@antv/g6'; | ||
|
||
describe('bugs:multiple-conflict', () => { | ||
it('drag element, drag canvas', async () => { | ||
const graph = createGraph({ | ||
data: { | ||
nodes: [{ id: 'node-1', style: { x: 50, y: 50, size: 20 } }], | ||
}, | ||
behaviors: ['drag-element', 'drag-canvas'], | ||
}); | ||
|
||
await graph.render(); | ||
|
||
await expect(graph).toMatchSnapshot(__filename); | ||
|
||
// drag canvas | ||
dispatchCanvasEvent(graph, CommonEvent.DRAG_START, { targetType: 'canvas' }); | ||
dispatchCanvasEvent(graph, CommonEvent.DRAG, { movement: { x: 10, y: 10 }, targetType: 'canvas' }); | ||
dispatchCanvasEvent(graph, CommonEvent.DRAG_END); | ||
await expect(graph).toMatchSnapshot(__filename, 'drag-canvas'); | ||
|
||
// drag element | ||
graph.emit(NodeEvent.DRAG_START, { target: { id: 'node-1' }, targetType: 'node' }); | ||
graph.emit(NodeEvent.DRAG, { dx: 10, dy: 10 }); | ||
graph.emit(NodeEvent.DRAG_END); | ||
await expect(graph).toMatchSnapshot(__filename, 'drag-element'); | ||
}); | ||
}); |
14 changes: 14 additions & 0 deletions
14
packages/g6/__tests__/snapshots/bugs/behaviors-multiple-conflict/default.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions
14
packages/g6/__tests__/snapshots/bugs/behaviors-multiple-conflict/drag-canvas.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions
14
packages/g6/__tests__/snapshots/bugs/behaviors-multiple-conflict/drag-element.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters