jQuery UI 可排序窗口滚动

3

我正在使用jQuery UI Sortable。在没有窗口滚动的情况下,我的可排序项目可以正常工作并保持在容器中。 但是,如果我滚动窗口并开始排序项目,我的项目首先移动到与窗口滚动相同的高度,不再粘着鼠标指针! 我做错了什么?

    var purchased = [];
$("#listitems").sortable({
    revert: true,
    containment: '#drop',
    stop: function(event, ui) { 
        purchased = [];
        $("#listitems li").each(function () {
            var elem = $(this);
            var st = elem.attr('id');
            if (jQuery.inArray(st, purchased) == -1) {
                purchased.push(st);
            }
        });
        console.log(purchased);
    }
});

    <div id="drop" class="clearfix" style="position:relative;margin:0 auto;min-height:160px;height:auto!important;height:160px;;margin-bottom:20px; border-top:1px solid #D4D4D4;border-bottom:1px solid #DADADA">
        <div style="position:absolute;top:-31px;left:10px; z-index:0"><h1 id="depose" style="font-size:2.6em; line-height:1em; color:#EBEBEB; font-weight:700; z-index:0">DRAG HERE</h1></div>
        <ul id="listitems" style="position:relative;z-index:11" class="alt_content galerie-thumbs">
<li>image 1</li>
<li>image 2</li>
...
        </ul>
    </div>

感谢您的帮助...

你解决过这个问题吗?我也遇到了完全相同的问题 :( - David O'Sullivan
我也有这个问题,目前还没有解决方案,但我在jQuery论坛上找到了这个讨论,其中提供了一些可能适用于某些人的潜在解决方案:https://forum.jquery.com/topic/sortable-offset-when-element-is-dragged-and-page-scrolled-down-ff - igneosaur
另一个问题在这里:https://dev59.com/4HE95IYBdhLWcg3wHqIV - igneosaur
1个回答

2
overflow: auto;添加到您列表的父容器/容器中。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接