FocusElement
Reading needs 2 minutes
When an element is clicked, the element is focused to the center of the view.
createGraph({data: {nodes: [{ id: 'node-1', style: { x: 200, y: 100 } },{ id: 'node-2', style: { x: 360, y: 100 } },{ id: 'node-3', style: { x: 280, y: 220 } },],edges: [{ source: 'node-1', target: 'node-2' },{ source: 'node-1', target: 'node-3' },{ source: 'node-2', target: 'node-3' },],},node: { style: { fill: '#7e3feb' } },edge: { style: { stroke: '#8b9baf' } },behaviors: [{type: 'focus-element',key: 'focus-element',},],plugins: [{ type: 'grid-line', size: 30 }],animation: true,},{ width: 600, height: 300 },(gui, graph) => {const options = {key: 'focus-element',type: 'focus-element',animation: true,enable: true,};const optionFolder = gui.addFolder('ZoomCanvas Options');optionFolder.add(options, 'type').disable(true);optionFolder.add(options, 'animation');optionFolder.add(options, 'enable');optionFolder.onChange(({ property, value }) => {graph.updateBehavior({key: 'focus-element',[property]: value,});graph.render();});},);
string
Behavior key, that is, the unique identifier
Used to identify the behavior for further operations
// Update behavior optionsgraph.updateBehavior({key: 'key', ...});
string
Behavior type
Whether to enable animation
boolean | ((event: IElementEvent) => boolean) Default:
true
Whether to enable the function of focusing on the element
destroy(): void;