Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support mousewheel zooming and keyboard shortcuts
- Loading branch information
Showing
21 changed files
with
577 additions
and
257 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,63 @@ | ||
import React from 'react' | ||
import { Graph } from '@antv/x6' | ||
import '../index.less' | ||
|
||
export default class Example extends React.Component { | ||
private container: HTMLDivElement | ||
|
||
componentDidMount() { | ||
const graph = new Graph({ | ||
container: this.container, | ||
width: 800, | ||
height: 600, | ||
grid: true, | ||
keyboard: { | ||
enabled: true, | ||
global: false, | ||
}, | ||
}) | ||
|
||
graph.keyboard.on('command+shift+k', () => { | ||
console.log(123) | ||
}) | ||
|
||
graph.addNode({ | ||
type: 'rect', | ||
x: 50, | ||
y: 50, | ||
width: 100, | ||
height: 40, | ||
attrs: { label: { text: 'A' } }, | ||
}) | ||
|
||
graph.addNode({ | ||
type: 'rect', | ||
x: 250, | ||
y: 50, | ||
width: 100, | ||
height: 40, | ||
attrs: { label: { text: 'B' } }, | ||
}) | ||
|
||
graph.addNode({ | ||
type: 'rect', | ||
x: 350, | ||
y: 150, | ||
width: 100, | ||
height: 40, | ||
attrs: { label: { text: 'C' } }, | ||
}) | ||
} | ||
|
||
refContainer = (container: HTMLDivElement) => { | ||
this.container = container | ||
} | ||
|
||
render() { | ||
return ( | ||
<div className="x6-graph-wrap"> | ||
<div ref={this.refContainer} className="x6-graph" /> | ||
</div> | ||
) | ||
} | ||
} |
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.