-
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.
feat: add drag canvas behavior (#5475)
* refactor(types): rename loose to loosen * feat(utils): add Shortcut util * refactor(behaviors): refactor zoom canvas with shortcuts * chore(test): update toBeCloseTo message style * feat(behaviors): add drag-canvas behavior * refactor(utils): abstract out module from behavior and widget * feat(runtime): add widget controller * refactor: fix cr issues
- Loading branch information
Showing
36 changed files
with
3,303 additions
and
286 deletions.
There are no files selected for viewing
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,36 @@ | ||
import { Graph } from '@/src'; | ||
import data from '@@/dataset/cluster.json'; | ||
import type { STDTestCase } from '../types'; | ||
|
||
export const behaviorDragCanvas: STDTestCase = async (context) => { | ||
const { canvas, animation } = context; | ||
const graph = new Graph({ | ||
animation, | ||
container: canvas, | ||
data, | ||
layout: { | ||
type: 'd3force', | ||
}, | ||
node: { | ||
style: { | ||
size: 20, | ||
}, | ||
}, | ||
behaviors: [ | ||
'drag-canvas', | ||
{ | ||
type: 'drag-canvas', | ||
trigger: { | ||
up: ['ArrowUp'], | ||
down: ['ArrowDown'], | ||
right: ['ArrowRight'], | ||
left: ['ArrowLeft'], | ||
}, | ||
}, | ||
], | ||
}); | ||
|
||
await graph.render(); | ||
|
||
return graph; | ||
}; |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './behavior-drag-canvas'; | ||
export * from './behavior-zoom-canvas'; |
Oops, something went wrong.