I'm using jQuery to create a set of horizontally sortable elements that are also resizable with a right-side (east) handle. The problem is that after resizing an element, when I move its horizontal position, during the move the element jumps to the top of the page.
HTML
<div id="spacer"></div>
<div id="box">
<div id="list">
<div class="resize">ONE</div>
<div class="resize">TWO</div>
<div class="resize">THREE</div>
</div>
</div>
JAVASCRIPT
$(function() {
$('#list').disableSelection().sortable({
scroll: true,
placeholder: 'placeholder',
containment:'parent',
axis: 'x'
});
$('.resize').resizable({
handles: 'e'
});
});
CSS
#spacer {height: 100px}
#box {
height: 40px;
width: 500px;
float: left;
}
#list {
background-color:blue;
white-space:nowrap;
overflow-x:scroll;
overflow-y:hidden;
}
.resize {
background-color:darkgray;
height:40px;
width:100px;
cursor:move;
display:inline-block;
}
.placeholder {
display:inline-block;
height: 1px !important;
}
.ui-resizable-handle {
height:15px;
width: 20px;
background-color:red;
cursor: pointer;
}
What am I doing wrong? jsFiddle is here.
remove "axis:x" from your code
change your jquery part as follows..
$(function () {
$('#list').sortable({
scroll: true,
placeholder: 'placeholder',
containment: 'parent',
//axis: 'x'
});
$('#list').disableSelection();
$('.resize').resizable({
handles: 'e'
});
});