我的问题就像标题所说的一样。我的工作是在JSP中进行的,但为了清晰起见,我已经尽可能在HTML中重新创建了这个问题。基本上,在主页面(非简化版本)中,我正在使用sortable使元素可以通过拖放方法(移动列表项)重新排列。当我在页面底部时,页面只允许滚动(碰撞式滚动),这只是简单地扩展了包含div的底部并添加了滚动条。我需要的是当上下存在元素时(我已经设置为sortable的元素),我需要页面/包含元素允许我上下滚动。
以下代码是一个非常基本的重现,这段代码允许我在不在元素顶部时向上滚动,但在任何情况下都不会允许我在元素的任何位置向下滚动。
这里是重现:
以下代码是一个非常基本的重现,这段代码允许我在不在元素顶部时向上滚动,但在任何情况下都不会允许我在元素的任何位置向下滚动。
这里是重现:
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script>
$(function() {
$("#sortable").sortable({placeholder:"placeHolder", scroll: true, axis: "y", opacity: 0.5});
$("#sortable").disableSelection();
});
</script>
<style>
#sortable{
list-style:none;
}
.formatlist{
border: 2px solid red;
padding: 40px;
margin: 5px;
width: 50%;
text-align: center;
}
.placeHolder{
border: 2px solid #ff8833;
padding: 40px;
margin: 5px;
width: 50%;
text-align: center;
background-color: #ffee88;
}
</style>
</head>
<body>
<div>
<ul id="sortable">
<li class="formatSort"><div class="formatlist">NUMERO ONE This is a test on a list that drags LalLalala......</div></li>
<li class="formatSort"><div class="formatlist">NUMERO TWO This is a test on a list that drags LalLalala......</div></li>
<li class="formatSort"><div class="formatlist">NUMERO THREE This is a test on a list that drags LalLalala....</div></li>
<li class="formatSort"><div class="formatlist">NUMERO FOUR This is a test on a list that drags LalLalala.....</div></li>
<li class="formatSort"><div class="formatlist">NUMERO FIVE This is a test on a list that drags LalLalala.....</div></li>
<li class="formatSort"><div class="formatlist">NUMERO SIX This is a test on a list that drags LalLalala......</div></li>
<li class="formatSort"><div class="formatlist">NUMERO SEVEN This is a test on a list that drags LalLalala....</div></li>
<li class="formatSort"><div class="formatlist">NUMERO EIGHT This is a test on a list that drags LalLalala....</div></li>
<li class="formatSort"><div class="formatlist">NUMERO NINE This is a test on a list that drags LalLalala.....</div></li>
</ul>
</div>