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

拖动dataTransfer #113

Open
xinglie opened this issue Dec 21, 2023 · 0 comments
Open

拖动dataTransfer #113

xinglie opened this issue Dec 21, 2023 · 0 comments

Comments

@xinglie
Copy link
Owner

xinglie commented Dec 21, 2023

我们仅讨论拖动普通元素时的dataTransfer对象

effectAllowed

该属性需要在dragstart中设置,不过需要注意的是,如果不设置该属性,它并不总是为alluninitialized

如果可以,请始终设置且不要设置成all,设置成具体的如copyMove兼容性会更好

dropEffect

该属性仅可设置effectAllowed指定的值,该属性会影响鼠标样式的展现

如果设置该属性不生效,请检查effectAllowed是不是不包含你设置的值或effectAllowed已经是none

另外需要注意的是,在拖动过程中某些键盘按键会导致effectAllowed变化,比如mac下的metaKey会影响effectAllowed

我们可以这样解决

a. 在dragover中检测effectAllowed的变化
b. 如果effectAllowed有变化,我们在当前节点派发dragleave再派发dragenter事件
c. 在drop事件中检测dropEffect来决定对本次拖动是否生效

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

No branches or pull requests

1 participant