简体   繁体   中英

jquery-ui sortable connected lists with hidden overflow

I have two fixed hight divs each containing a sortable list which are connected to each other. Is there a way to hide the overflow while still having the lists connected? Eg if the overflow is set to hidden then the li doesn't show when it is dragged outside of the div.

I know a possible solution would be to calculate the maximum number of li that the div can contain and dynamically add/remove elements based on the number of visible elements, but I was wondering if there was a better solution?

You should be able to fix this by using the appendTo option , which will tell it where to attach the helper object to in the DOM. The default is to use parent which means the helper that's being dragged is inside your overflow: hidden div. Changing it to, for example, body should fix it for you. Ie:

$( ".selector" ).sortable({ appendTo: 'body' });

Have a look at containment . It defines a bounding box that the sortable items are constrained to while dragging.

http://api.jqueryui.com/sortable/#option-containment

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM