Skip to content

如何使用 Action

示例

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
			})
		},
	})
})