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

拖放问题,鼠标放在Box的文本上拖动元素到Frame中无法触发DROP事件 #345

Open
Makero opened this issue Feb 7, 2025 · 1 comment

Comments

@Makero
Copy link

Makero commented Feb 7, 2025

环境:电脑 + window 11 + chrome 132 + leaferjs 1.4.0
复现:拖动矩形到容器里可以触发Frame的DropEvent.DROP事件,但是鼠标放在文本上再拖动到容器里就不触发DROP事件了

1574.mp4

代码:

import { App, Box, Frame, DropEvent, Group } from 'leafer-editor'

const app = new App({ view: window, editor: {} })
const appContainer = new Group()
app.tree.add(appContainer)

app.on(DropEvent.DROP, (e: DropEvent) => {
    console.log('drop app', e.list);
    e.list.forEach((leaf) => {
        leaf.dropTo(appContainer)
    })
})

const container = new Frame({ 
    width: 420, height: 600, overflow: 'show', fill: '#fff', stroke: '#000', 
    strokeWidth: 0, editable: true, around: 'center', shadow: {x: 0, y: 0, blur: 4, color: '#999999aa'}, 
    children: [
        { x: -10, y: -30, tag: 'Text', text: '容器', padding:  [10, 10], textAlign: 'left', fill: '#fff', verticalAlign:'top', event: {
            [DropEvent.DROP]: (e: DropEvent) => {
                e.stop()
            }
        } }
    ],
    event: {
        [DropEvent.DROP]: (e: DropEvent) => {
            console.log('drop container', e.list);
            e.list.forEach((leaf) => {
                leaf.dropTo(e.current)
            })
            e.stop()
        }
    }
})

const box = new Box({ width: 120, height: 80, overflow: 'show', around: 'center', 
    resizeChildren: true, textBox: true, fill: '#fff', stroke: '#000', strokeWidth: 2, editable: true,
    children: [
        { x: 0, y: 0, width: 120, height: 80, tag: 'Text', text: '文档', fill: 'black', padding:  [10, 10], textAlign: 'center', verticalAlign:'middle' }
    ]
})

appContainer.add(container)
appContainer.add(box)
@leaferjs
Copy link
Owner

leaferjs commented Feb 8, 2025

收到,谢谢反馈~

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