jQuery UI 可排序窗口滚动

标签 jquery jquery-ui-sortable

我正在使用jquery ui 可排序。如果没有窗口滚动,我的可排序项目可以工作并保留在容器中。 但是,如果我滚动窗口并开始对项目进行排序,我的项目首先移动到窗口滚动的相同高度,并且不再粘在我的鼠标指针上! 我做错了什么?

    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>

感谢您的帮助...

最佳答案

overflow: auto; 添加到列表的父级/容器。

关于jQuery UI 可排序窗口滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10161959/

相关文章:

javascript - 拖动时 jQuery mouseleave 未正确触发

javascript - 使用 jQuery 拖放防止点击事件

jquery-ui - jQuery UI : Sortable: Placeholder clone of item being sorted

jquery - 我是否应该担心附加大量不需要的事件处理程序/监听器?

javascript - 悬停时启动轮播

javascript - jQuery sortable 获得 2 个被交换的元素

jquery - 使用 jQuery UI Sortable 对固定占位符目标进行排序

php - ajax,以 json 形式检索多维 php 数组

jquery 访问器 id 与类?

php - fileinput上传和预览,保护文件