简体   繁体   English

Scriptaculous Drag:如何抵消拖动元素?

[英]Scriptaculous Drag: How do I offset the dragging element?

This is an age old problem - but now I'm using scriptaculous its come back to haunt me. 这是一个古老的问题-但现在我使用的是脚本语言,它回来困扰我。 When dragging a tree node over other tree nodes I want mouseover to fire for each node I drag over. 当将树节点拖到其他树节点上时,我希望为我拖过的每个节点触发鼠标悬停。 So I want to position the dragging thing so that its top-left is slightly below and to the right of the mousepointer 所以我想将拖动的东西放置在适当的位置,以使其左上角位于鼠标指针的下方和右侧

can anyone help? 有人可以帮忙吗? - thanks - 谢谢

Maybe there is an answer in their native code but I couldn't find it. 也许他们的本机代码中有一个答案,但我找不到。

So I fixed it by adding a plugin. 因此,我通过添加插件对其进行了修复。 Changed these lines in Draggable.prototype.draw 在Draggable.prototype.draw中更改了这些行

//  if((!this.options.constraint) || (this.options.constraint=='horizontal'))
//      style.left = p[0] + "px";
//  if((!this.options.constraint) || (this.options.constraint=='vertical'))
//      style.top = p[1] + "px";  

if((!this.options.constraint) || (this.options.constraint=='horizontal'))
    style.left = ((this.options.mouseOffset && point[0]) || p[0]) + "px";
if((!this.options.constraint) || (this.options.constraint=='vertical'))
    style.top = ((this.options.mouseOffset && point[1]) || p[1]) + "px"; 

and when I create the draggable I set my own custom option 当我创建可拖动对象时,我设置了自己的自定义选项

mouseOffset: true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM