Dojo dnd:头像定位
是否可以使用dojo工具包的dnd api更改头像的位置? 此时,拖动时,被拖动项目的头像出现在鼠标光标的右侧和下方。 我希望它与鼠标光标位于同一位置。 我对我的应用程序进行了一些可用性测试,大多数人似乎尝试尝试将头像拖到放置区域中,而不是将光标移动到放置区域上。 任何输入都会很好。 谢谢!
Is it possible to change the positioning of the avatar with dojo toolkit's dnd api? At the moment, when dragging, the avatar of the dragged item appears to the right and below the mouse cursor. I want it to be in the same position as the mouse cursor. I ran some usability tests on my application, and most people seem to attempt to try and drag the avatar into the drop area, as opposed to moving the cursor over the drop area. Any input would be nice. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
抱歉,由于技术原因不可能。
更新:根据流行的要求,这些是技术原因:
但我知道其他人也能做到! 应该是可以的! 是的,这是可能的……原则上:
为什么Dojo不这样做? 由于多种技术原因(我们终于做到了!):
我怎么知道呢? 因为 Dojo 在早期版本中曾经有过这种拖放操作,所以我们遇到了我上面描述的令人厌烦的问题。 任何改进都是一场艰苦的战斗,这会增加代码大小。 最后,我们决定不重新发明和复制浏览器中已经内置的机制。 浏览器实际上执行相同的工作:计算节点的几何形状,查找底层节点,并适当地调度鼠标移动事件。
当前的实现不使用鼠标移动事件,也不计算几何图形。 相反,它依赖于开始拖动后目标检测到的鼠标悬停/移出事件。 它工作可靠并且可扩展性良好。
这个故事中的另一个问题是:Dojo 将目标视为容器——这是一个非常常见的用例(购物车、重新排列项目、编辑层次结构)。 目前已实现线性容器和通用树,也可以自定义容器。 拖放时,您可以看到拖动的项目并将其放置在目标容器内的适当位置,例如,将它们插入现有项目之间。 使用几何计算和检查来实现此功能将非常昂贵。
Sorry, not possible for technical reasons.
UPDATE: by popular demands these are technical reasons:
But I know that other people can do it! It should be possible! Yes, it is possible … in principle:
Why Dojo doesn't do that? For a number of technical reasons (finally we got there!):
How do I know that? Because Dojo used to have this kind of drag'n'drop in earlier versions, and we got sick and tired fighting problems I described above. Any improvement was an uphill battle, which increased the code size. Finally we decided against reinventing and replicating mechanisms already built in a browser. A browser does virtually the same work: calculates geometry of nodes, finds the underlying node, and dispatches a mouse move event appropriately.
The current implementation doesn't use mouse move events and do not calculate the geometry. Instead it relies on mouse over/out events detected by targets after a drag was started. It works reliably and scales well.
Another wrinkle in this story: Dojo treats targets as containers — a very common use case (shopping carts, rearranging items, editing hierarchies). Linear containers and generic trees are implemented at the moment, custom containers are possible. When dragging and dropping you can see and drop dragged items in a proper position within a target container, e.g., inserting them between existing items. Implementing this feature using geometric calculations and checks would be prohibitively expensive.