Scrolling jQuery UI Sort Window

I am using jquery ui sortable. Without scrolling the window, my sortable items work and remain in the protective shell. But if I scroll the window and I start sorting the elements, my objects first move to the same height of my window scroll and are no longer snapped to the mouse pointer !!! What have I done wrong?

    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>

Thank you for your help...

+3
source share
1 answer

add overflow: auto;to the parent / container of your list.

+1
source

All Articles