使用 React-dnd 删除组件时未触发 Mouseup 事件
我正在开发一个项目,需要使用 React-dnd 包实现拖放功能。这是我能够实现的。但问题是,目标组件(可拖动项目将被放置在其中)包含 mouseup 事件,该事件在每个场景中都会被触发,除非我将任何组件放置在其中。即使在掉落的情况下也需要触发它,但它不会被触发。我也尝试了手动触发,它触发了,但偏移等值并不符合预期。
我共享示例代码沙箱,其中 Dustbin.tsx 包含 mouseup 事件,当任何可拖动组件放入其中时,该事件不会被触发。谢谢。
沙盒链接:https://codesandbox.io/s/黎明-snowflake-ej08d0?file=/src/Dustbin.tsx
I am working on a project where I need to implement drag and drop functionality using React-dnd package. Which is I am able achieve. But the issues is, the target component (where draggable items will be dropped) contains mouseup event which is getting triggered in every scenarios except when I drop any component in it. It needs to be triggered even in the case of drop as well but its not getting triggered. I tried manual triggered as well and it triggered but the values like offsets are not as per expected.
I have share sample code sandbox where Dustbin.tsx contains that mouseup event which is not getting triggered when any draggable component is dropped into it. Thanks.
Sandbox link: https://codesandbox.io/s/dawn-snowflake-ej08d0?file=/src/Dustbin.tsx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么使用
onmouseup
?如果您想检测容器内是否有东西掉落,请使用
ondrop
Why using
onmouseup
?If you want to detect if something is dropped inside that container then please use
ondrop