也许他们的本地代码中有答案,但我找不到。
所以我添加了一个插件。在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";
当我创建draggable时,我设置了自己的自定义选项
mouseOffset: true