I have a sortable list of playing cards. In order to just show the tops of the cards, I have given each card a negative bottom margin. Once I do this, the jQuery sortable gets very flickery and difficult to use. How can I eliminate this filcker? On top of the flicker, how can I get the proper vertical alignment for dragging? It seems that I have to go WAY above or below the list to get it to move the placeholder to those sides of the list.
I have put my code at http://jsfiddle.net/otac0n/wDTwX/ so that you can get a feel for it, but here is the gist of it:
// HTML
<div class="deck" data-bind="sortable: { data: Cards, options: { placeholder: 'card', cursorAt: { left: 5, top: 5 }, tolerance: 'pointer' } }">
<div class="card" data-bind="text: Name, style: { background: Color }"></div>
</div>
// CSS
.deck
{
margin: 10px;
padding: 0 0 130px 0;
}
.card
{
width: 100px;
height: 150px;
border: 1px solid black;
border-radius: 8px;
background: White;
color: White;
margin: 0 0 -130px 0;
padding: 5px;
}
// JS
var vm = {
Cards: ko.observableArray([
{ Name: "Red", Color: "#f00" },
{ Name: "Green", Color: "#0f0" },
{ Name: "Blue", Color: "#00f" },
])
};
ko.applyBindings(vm);
First things first, you have a run away argument there.
The tolerance should be inside the options array, so its not being picked up :) ie.
About the flickering, it seems to me like its because the events are bubbling though the elements (which are overlapping). Try and come up with a way of ensuring they only get sorted if they are intended to be :)
Edit: this problem seems similar: Dealing with overlapping jQuery sortable lists