Skip to content

Selection

通过鼠标选中Shape的 Action, 当使用 selection 插件的时候,这个 action 会在 selection 插件里被插件在每个Shape上边添加上。当然也可以自己在Shape实例上边添加此 action 来替换掉之前的 selection action,用于添加 initDrawFunc 来自定义 selection action 样式

Options

ts
export type SelectionDrawFunc = (selection: SelectionAction) => void

export type SelectionActionAttr = {
	stroke?: StrokeData
	fill?: string
	padding?: number
	whileSelectedEditShape?: boolean // 选中时是否将当前`Shape`切换为编辑状态
}

export type SelectionActionOptions = {
	initDrawFunc?: SelectionDrawFunc
	setAttr?: (action: SelectionAction) => SelectionActionAttr //自定义 selection action 的属性
}

静态属性

actionName

selection

实例属性

selected

是否选中了当前Shape

实例方法

getSelectionActionOptions

ts
// 获取 selectionAction 配置
getSelectionActionOptions(): SelectionActionOptions

getSelectionShape

ts
// 获取当前选中的`Shape`的 selection 的`Svg.js`的 shape 实例
getSelectionShape(): Shape | undefined

getSelectionId

ts
// 获取当前选中的`Shape`的 selection 的 `id`
getSelectionId(): string

disableSelection

ts
// 禁用当前`Selection`插件
disableSelection(): void

enableSelection

ts
// 启用当前`Selection`插件
enableSelection(): void

destroy

ts
// ImageMark 销毁时或者 unuseAction 时候调用
destroy(): void