I want to allow the user to sort objects from left to right with a scroll bar.
Objects are boxes with HTML in them, including some text, and not images, like many other examples.
The problem is that when the user drags one of the objects, all the others are moved down while dragging.
Here is what I have:
HTML:
<div id="parent" class="parent"> <div id="list" class="list"> <div class="item">A</div> <div class="item">B</div> <div class="item">C</div> </div> </div>
CSS
.parent { height:64px; width:280px; } .list { background-color:#d0d0d0; white-space:nowrap; overflow-x:scroll; overflow-y:hidden; } .item { background-color:#404040; height:40px; width:100px; margin:4px; cursor:pointer; display:inline-block; } .placeholder { height:40px; width:20px; display:inline-block; margin:4px; }
JavaScript:
$(function() { $('#list').disableSelection().sortable({ scroll: true, placeholder: 'placeholder',
I tried many different settings and left some of them in the comments.
The best way to see the problem is here: http://jsfiddle.net/francispotter/gtKtE/
source share