This question is not about horizontal scrolling. It is about using the jQuery UI sortable functionality when it is in a horizontally scrolled area.
I have created a fiddle as a demonstration: http://jsfiddle.net/shhQuiet/t2vnfmh4/4/embedded/result/
I have tried something like this, to no avail:
$('#scroller').scroll(function() {
$('.items').sortable("refreshPositions");
});
Here are the deets:
markup
<div id="scroller">
<div class="items">
<div class="item">One</div>
<div class="item">Two</div>
<div class="item">Three</div>
<div class="item">Four</div>
<div class="item">Five</div>
<div class="item">Six</div>
</div>
<div class="items">
<div class="item">One</div>
<div class="item">Two</div>
<div class="item">Three</div>
<div class="item">Four</div>
<div class="item">Five</div>
<div class="item">Six</div>
</div>
... removed some repetitions for brevity ...
</div>
</p>
JS
$('.items').sortable({
axis: 'y',
containment: 'parent'
});
CSS
.item {
border: 1px #aaa solid;
width: 2in;
}
.items {
height: 100%;
display: inline-block;
overflow-y: auto;
overflow-x: hidden;
}
#scroller {
overflow-x: scroll;
overflow-y: hidden;
white-space: nowrap;
}
Too late now since you've already accepted an answer, but I solved the very same problem by adding this to the sortable config:
start: function (event, ui) {
ui.helper.css('left', ui.originalPosition.left);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With