开发者

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 m开发者_如何学运维e. 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

//  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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜