Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dropto方法 #319

Open
amourlemon opened this issue Jan 7, 2025 · 2 comments
Open

dropto方法 #319

amourlemon opened this issue Jan 7, 2025 · 2 comments

Comments

@amourlemon
Copy link

https://cloudstudio.net/a/23701538151493632?channel=share&sharetype=URL

绿色块进组后,再单独移动绿色块,
image
然后再同时选中,两个块,移动,出现了bug
image

@amourlemon
Copy link
Author

`import { Leafer, Group, Rect, DropEvent, DragEvent, App } from 'leafer-ui'
import '@leafer-in/editor' // 导入图形编辑器插件
const app = new App({
view: window,
editor: {} // 会自动创建 editor实例、tree层、sky层
})

const leafer = app.tree

const group = new Group({ x: 300, y: 300, editable: true })
const rect = new Rect({ fill: 'blue', editable: true })

leafer.add(new Rect({ fill: 'green', draggable: true, editable: true }))
leafer.add(group)
group.add(rect)

group.on(DragEvent.ENTER, function () {
console.log('enter')
DragEvent.setData({ data: 'drop data' })
rect.set({ stroke: 'black', strokeWidth: 2 })
})

group.on(DragEvent.LEAVE, function () {
rect.set({ stroke: '' })
})

group.on(DropEvent.DROP, function (e: DropEvent) {
console.log(e.data)
e.list.forEach((leaf) => {
console.log(leaf, 'ddddd')
leaf.dropTo(group) // 放置元素到group中

})

})`

@leaferjs
Copy link
Owner

leaferjs commented Jan 7, 2025

Group需将 hitChildren 设为 false,只能通过双击进组编辑子元素

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants