禁用 JQuery 可拖动对象(UI 1.7.2)右侧和底部的 snapTolerance 的最佳方法是什么?
我想做的是禁用 JQuery 可拖动对象的右侧和底部的 snapTolerance。当我将 snapMode 设置为“inner”时,以下代码似乎控制可拖动对象的 snapTolerance。
我最初的想法是以某种方式覆盖这部分代码,但是我不知道如何进行覆盖。或者,也许有更好的方法?
TIA
>$.ui.plugin.add("draggable", "snap", {
> ...
> drag: function(event, ui) {
> ...
> if(o.snapMode != 'outer') {
> var ts = Math.abs(t - y1)
> var bs = Math.abs(b - y2)
> var ls = Math.abs(l - x1)
> var rs = Math.abs(r - x2)
> if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
> if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
> if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left;
> if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left;
> }
> ...
> }
>...
>});
What I would like to do is disable the snapTolerance the right and bottom sides of a JQuery draggable object. The following code seems to control the snapTolerance of draggable objects when I set snapMode to 'inner'.
My initial thought is to override this portion of the code somehow but, I don't know how to do the override. Or, perhaps, there's a better approach?
TIA
>$.ui.plugin.add("draggable", "snap", {
> ...
> drag: function(event, ui) {
> ...
> if(o.snapMode != 'outer') {
> var ts = Math.abs(t - y1)
> var bs = Math.abs(b - y2)
> var ls = Math.abs(l - x1)
> var rs = Math.abs(r - x2)
> if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
> if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
> if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left;
> if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left;
> }
> ...
> }
>...
>});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论