javascript 带有自动溢出的jQuery可排序容器滚动div
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9857065/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
jQuery sortable container scroll div with overflow auto
提问by tribe84
I have been pulling my hair out trying to make this work.
我一直在努力完成这项工作。
I have two connected sortables, defined like so:
我有两个连接的 sortables,定义如下:
var sortlists = $("#List1, #List2").sortable(
{
appendTo: 'body',
tolerance: 'pointer',
connectWith: '#List1, #List2',
revert: 'invalid',
forceHelperSize: true,
helper: 'clone',
scroll: true
});
Here is a link to an example of jsfiddle
Because of the page setup, both sortables are being contained in div's with overflow: auto they are also wrapped in parent containers with overflow set to hidden. For arguments sake, lets say there is no way around that.
由于页面设置,两个 sortables 都包含在带有溢出的 div 中:auto 它们也包含在父容器中,溢出设置为隐藏。为了争论,让我们说没有办法解决这个问题。
Is there a way to make the container element scroll when the helper is being positioned towards the lower or upper edge of the container?
当助手被定位到容器的下边缘或上边缘时,有没有办法让容器元素滚动?
Any help would be appreciated!
任何帮助,将不胜感激!
采纳答案by Beetroot-Beetroot
With helper:'original'
, I get the scrolling behaviour you seek, (in Opera 11.61).
使用helper:'original'
,我可以得到您想要的滚动行为(在 Opera 11.61 中)。
Edit: Here's a version of the fiddle with "ganged-scrolling"
编辑:这是带有“组合滚动”的小提琴版本
回答by John Smith
I think this is what you want. Drag from div (with scrollable) to div (with scrollable) without the dragged item appearing behind the div.
我想这就是你想要的。从 div(可滚动)拖动到 div(可滚动),而拖动的项目不会出现在 div 后面。
.document.body.appendChild //required to add code with link...
The next best approach would be to actually drag a clone of the item...
下一个最好的方法是实际拖动项目的克隆......
回答by Cuse70
The forked fiddle with "ganged-scrolling" unfortunately exhibits the very nasty side effect of constraining (visually) the selected item to it's own div.
不幸的是,带有“组合滚动”的分叉小提琴表现出将(视觉上)所选项目限制到它自己的 div 的非常讨厌的副作用。