3

I'm using jquery ui sortable. Without window scroll my sortable items works and stay in the containment. But if I scroll the window and I start sortable the items, my items move first to the same height of my window scroll and not stick anymore to my mouse pointer !!! What I did 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>

Thanks for your help...

Chris
  • 435
  • 1
  • 8
  • 21
  • Did you ever sus this out? I have exactly the same issue :( – David O'Sullivan Apr 19 '13 at 16:00
  • I have this problem too, no solution yet but I found this discussion on the jQuery boards with a few potential solutions that might work for someone: https://forum.jquery.com/topic/sortable-offset-when-element-is-dragged-and-page-scrolled-down-ff – igneosaur Dec 29 '15 at 03:56
  • Another question here: http://stackoverflow.com/questions/2451528/jquery-ui-sortable-scroll-helper-element-offset-firefox-issue – igneosaur Dec 29 '15 at 04:07

1 Answers1

2

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

Webmaster G
  • 502
  • 5
  • 12