如何使用 Action
selection action
是selection plugin
配套使用的,在使用selection plugin
的时候,所有shape
会被selection plugin
自动添加上selection action
。lmb-move action
使用后可以用鼠标来拖动 shape
示例
class 方式
ts
import { Shape, LmbMoveAction } from 'mark-img'
Shape.useAction(LmbMoveAction, {
// action options
})
实例方式
ts
import ImageMark, { ShapePlugin, LmbMoveAction, ImageMarkRect } from 'mark-img'
const imgMark = new ImageMark({
el: '#container',
src: './example.jpg',
})
imgMark.addPlugin(imageMarkInstance => {
const shapePluginInstance = new ShapePlugin(imageMarkInstance)
shapePluginInstance.addShape(ImageMarkRect, {
// shape options
afterRender(shapeInstance) {
shapeInstance.addAction(LmbMoveAction, {
// action options
})
},
})
})