fix: segments & vertices tool add onChanged callback (#1348)

Co-authored-by: yangling <yl260087@alibaba-inc.com>
This commit is contained in:
杨凌
2021-09-16 07:17:08 +08:00
committed by GitHub
parent 1042cf9ed1
commit a70a6c9a74
2 changed files with 7 additions and 0 deletions

View File

@ -325,6 +325,8 @@ export class Segments extends ToolsView.ToolItem<EdgeView, Segments.Options> {
edgeView.notifyMouseUp(normalizedEvent, coords.x, coords.y)
}
edgeView.checkMouseleave(normalizedEvent)
options.onChanged && options.onChanged({ edge: edgeView.cell, edgeView })
}
protected updateHandle(
@ -379,6 +381,7 @@ export namespace Segments {
) => Edge.TerminalCellData['anchor']
createHandle?: (options: Handle.Options) => Handle
processHandle?: (handle: Handle) => void
onChanged?: (options: { edge: Edge, edgeView: EdgeView }) => void
}
export interface EventData {

View File

@ -3,6 +3,7 @@ import { Point } from '../../geometry'
import { Graph } from '../../graph'
import { View } from '../../view/view'
import { EdgeView } from '../../view/edge'
import { Edge } from './../../model/edge'
import { ToolsView } from '../../view/tool'
import { Attr } from '../attr'
@ -206,6 +207,8 @@ export class Vertices extends ToolsView.ToolItem<EdgeView, Vertices.Options> {
}
edgeView.checkMouseleave(evt)
options.onChanged && options.onChanged({ edge: edgeView.cell, edgeView })
}
protected snapVertex(vertex: Point.PointLike, index: number) {
@ -284,6 +287,7 @@ export namespace Vertices {
attrs?: Attr.SimpleAttrs | ((handle: Handle) => Attr.SimpleAttrs)
createHandle?: (options: Handle.Options) => Handle
processHandle?: (handle: Handle) => void
onChanged?: (options: { edge: Edge, edgeView: EdgeView }) => void
}
}