I created a demo here .
Code:
// javascript
$(function() { $("#panel").sortable({ items: ".content", axis:"y", scroll:true, }).disableSelection(); });
// 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> <li class="content" style="background-color:green">item6</li> <li class="content" style="background-color:yellow">item7</li> <li class="content" style="background-color:red">item8</li> </ul>
// CSS
.scroll{ overflow:scroll; border:1px solid red; height: 200px; width: 150px; position:relative; } .content{ height: 50px; width: 100%; }
In this case, when I drag any box down, it scrolls for a very long time and leaves the other boxes. But when I drag any box up, it works correctly.
So, is there a way to prevent prolonged scrolling?
source share