Jquery 在嵌套列表中拖放 - 如何最小化/消除闪烁
基于 http://jqueryui.com/demos/sortable/#placeholder 我正在研究允许用户重新组织嵌套列表的拖放界面。正如您从链接中看到的,这在简单列表上效果很好。
然而,当我尝试使用嵌套列表时,我得到了非常严重的闪烁。亲自尝试一下:
http://jsfiddle.net/unklefolk/G5xPE/
移动一些内部内容后对于外部列表的项目,反之亦然,您会发现有相当多的闪烁/抖动发生,特别是在外部列表和内部列表相交的点周围。
我可以采取什么措施来最大程度地减少这种闪烁?我可以对 jQuery 或 CSS 进行任何更改来减少这个问题吗?
Based on http://jqueryui.com/demos/sortable/#placeholder I am working on a drag and drop interface that allows the user to reorganise nested lists. As you can see from the link this works great on simple lists.
However, when I try it with nested lists, I get quite bad flickering. Try it for yourself at:
http://jsfiddle.net/unklefolk/G5xPE/
After moving some inner items to the outer list and visa-versa you will see that there is quite a bit of flickering / dithering happening, particularly around the point where an outer list meets and inner list.
What can I do to minimise this flickering? Are there any change to the jQuery or CSS that I can make that would reduce this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
看看这个嵌套的可排序插件。它是列表项驱动的,但它可能是您问题的答案。
nestedSortable jQuery 插件
Take a look at this nested sortable plugin. It is list item driven, but it may be the answer to your issue.
nestedSortable jQuery Plugin
通常我使用
helper: 'clone'
这对这个问题有一些影响(从来不明白为什么)。我不知道它是否有效,在我的 firefox 8 上看起来更好http://jsfiddle.net/nicolapeluchetti/G5xPE/17/
Usually i use
helper: 'clone'
wich has some impact on this problem (never understood why).i don't know if it works, on my firefox 8 looks betterhttp://jsfiddle.net/nicolapeluchetti/G5xPE/17/
我以前也遇到过类似的问题,我没有时间去适应它,但这是我的解决方案。
使用js回调:
你可以在这里在jsfiddle.net看到它
I had a similar problem once before, I don't have time to adapt it but here's my solution.
Use a js callback:
You can see it here in jsfiddle.net
在这里。只是想发布我最终做了什么来解决这个问题。基于 http://bugs.jqueryui.com/ticket/4741?cversion =0&cnum_hist=8 我取消注释 jquery-ui-1.8.6.js 中的以下行:
我仍然使用
connectWith
属性。我现在可以在层次结构中的级别之间拖放,而不会出现闪烁。希望这对其他 SO 用户有所帮助。
OP here. Just wanted to post what I finally did to fix this. Based on http://bugs.jqueryui.com/ticket/4741?cversion=0&cnum_hist=8 I uncommented the following line in jquery-ui-1.8.6.js:
I still use the
connectWith
attribute.I can now drag and drop between levels in the hierarchy with no flicker. Hope this helps other SO users.