First check out this almost identical question: jQuery Sortable List - scrollbar is inserted when sorting
I have exactly the same problem, only I tried all the proposed solutions there with no luck
Here is the playback method
- create a sorted list
- scroll
- scroll down
- reorder items
- scroll position jumps up
Here is the code (see also JSFiddle )
Html
<ul id="panel" class="scroll"> <li class="content" style="background-color:red">item1</li> <li class="content" style="background-color:green">item2</li> <li class="content" style="background-color:blue">item3</li> <li class="content" style="background-color:gray">item4</li> <li class="content" style="background-color:yellow">item5</li> </ul>
Javascript
$(function() { $("#panel").sortable({ items: ".content", forcePlaceholderSize: true }).disableSelection(); $(".content").disableSelection(); });
CSS
.scroll{ overflow: scroll; border:1px solid red; height: 200px; width: 150px; } .content{ height: 50px; width: 100%; }
Here is the code (in JSFiddle ) after trying to use the concept of answer (no luck)
I can try to understand why this happens (the list gets “abbreviated" for a quick second), but all attempts to use placeholders or helpers to avoid this did not work either. I feel like I tried almost any permutation of “scrollable” options without any luck
The browsers I tried
IE9, Firefox 10.0.1, and Chrome 17
jQuery versions
core 1.7.1, UI v 1.8.17
Am I doing something wrong? Is there a solution? Maybe this is a mistake?
source share