Skip to content

Commit

Permalink
feat: add drag canvas behavior (#5475)
Browse files Browse the repository at this point in the history
* 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
Aarebecca authored Feb 28, 2024
1 parent e802349 commit b98a164
Show file tree
Hide file tree
Showing 36 changed files with 3,303 additions and 286 deletions.
36 changes: 36 additions & 0 deletions packages/g6/__tests__/demo/case/behavior-drag-canvas.ts
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;
};
1 change: 1 addition & 0 deletions packages/g6/__tests__/demo/case/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './behavior-drag-canvas';
export * from './behavior-zoom-canvas';
Loading

0 comments on commit b98a164

Please sign in to comment.