Jquery UI draggable not scrolling the sortable container

为君一笑 提交于 2019-12-01 06:34:01
sdespont

I am not sure that it is a bug, but it is not in a classic scenario.

I spent a lot of time to find a workaround some months ago and here is my solution : http://jsfiddle.net/8KDJK/23/

It is working for months now without problem.

The idea is to append the element clone to the scrollable container durring the helper construction callback, then append the helper to the body using a setTimeout function after 1ms to be able to drag all around the web page.

  $("#draggable li").draggable({
      cursor: "move",
      revert: "invalid",
      revertDuration: 500,
      connectToSortable: "#sortable",

      //Here is the workaround 
      //**********************

      containment: 'body',
      helper: function(){ 
        //Hack to append the element to the body (visible above others divs), 
        //but still bellonging to the scrollable container  
        $('#sortable').append('<div id="clone" class="ui-state-default big">' + $(this).html() + '</div>');   
        $("#clone").hide();
        setTimeout(function(){
            $('#clone').appendTo('body'); 
            $("#clone").show();
        },1);
        return $("#clone");
    }
  });

Link to my previous question : JqueryUI, drag elements into cells of a scrolling dropable div containing large table

Solution:

Don't use overflow:auto;

But

overflow: visible;

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!