Skip to content

Commit

Permalink
release(mask-editor): v0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
surunzi committed Feb 23, 2024
1 parent 25620bc commit 117693a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/mask-editor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export default class MaskEditor extends Component<IOptions> {
'canvasRender',
debounce(() => {
this.renderMask()
this.emit('change')
this.emit('change', this.canvas)
}, 20)
)

Expand Down
2 changes: 1 addition & 1 deletion src/mask-editor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mask-editor",
"version": "0.1.0",
"version": "0.2.0",
"description": "Image mask editing",
"luna": {
"dependencies": [
Expand Down
5 changes: 5 additions & 0 deletions src/mask-editor/react.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useNonInitialEffect } from '../share/hooks'

interface IMaskEditorProps extends IOptions {
style?: CSSProperties
onChange?: (canvas: HTMLCanvasElement) => void
onCreate?: (maskEditor: MaskEditor) => void
}

Expand All @@ -18,6 +19,10 @@ const LunaMaskEditor: FC<IMaskEditorProps> = (props) => {
})
props.onCreate && props.onCreate(maskEditor.current)

if (props.onChange) {
maskEditor.current.on('change', props.onChange)
}

return () => maskEditor.current?.destroy()
}, [])

Expand Down
7 changes: 7 additions & 0 deletions src/mask-editor/story.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ const def = story(

onCreate(maskEditor, maskContainer)

maskEditor.on('change', () => {
console.log('mask change')
})

return maskEditor
},
{
Expand All @@ -59,6 +63,9 @@ const def = story(
onCreate(maskEditor, maskContainer.current)
}
}}
onChange={() => {
console.log('mask change')
}}
/>
<div
style={{
Expand Down

0 comments on commit 117693a

Please sign in to comment.