Skip to content

Commit

Permalink
更新元素拖拽回滚
Browse files Browse the repository at this point in the history
  • Loading branch information
more-strive committed Jun 26, 2024
1 parent ceb1a20 commit e8dcd66
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
14 changes: 9 additions & 5 deletions src/logic/Canvas/useCanvas.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

import { watch } from 'vue'
import { storeToRefs } from 'pinia'
import { Leafer, App, Rect, Frame, Text, ChildEvent, UI, PropertyEvent } from 'leafer-ui'
import { Leafer, App, Rect, Frame, Text, ChildEvent, UI, PropertyEvent, LeafList, LayoutEvent, DragEvent } from 'leafer-ui';
import { useElementBounding } from '@vueuse/core'
import { useTemplatesStore, useLeaferStore } from '@/store'
import { Editor } from '@leafer-in/editor'
import { Editor, EditorMoveEvent, EditorEvent } from '@leafer-in/editor'
import { CanvasTypes } from '@/enums'
import '@leafer-in/view'
import '@leafer-in/editor'
Expand Down Expand Up @@ -68,11 +68,15 @@ const initEvent = () => {
const workspace = app.tree.findOne(`#${CanvasTypes.WorkSpaceDrawType}`)
if (!workspace) return
workspace.on(ChildEvent.ADD, function (e: ChildEvent) {
console.log('add:', e) // changed list
console.log('ChildEvent.ADD:', e) // changed list
templatesStore.modifedElement()
})
workspace.on(PropertyEvent.CHANGE, (e: PropertyEvent) => {
console.log('change:', e) // changed list
workspace.on(ChildEvent.REMOVE, function (e: ChildEvent) {
console.log('ChildEvent.REMOVE:', e) // changed list
templatesStore.modifedElement()
})
app.tree.on(DragEvent.END, (e: DragEvent) => {
console.log('DragEvent.END', e)
templatesStore.modifedElement()
})
}
Expand Down
5 changes: 1 addition & 4 deletions src/store/modules/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ export const useTemplatesStore = defineStore('Templates', {
},

currentTemplateElement(state) {
const currentTemplate = state.templates[state.templateIndex]
const [ canvas ] = useCanvas()
const activeObject = canvas.getActiveObject() as CanvasElement
return currentTemplate.objects.filter(ele => ele.id === activeObject.id)[0]

}
},

Expand Down

0 comments on commit e8dcd66

Please sign in to comment.