0
我想讓頁面滾動時拖動元素頂部或底部的屏幕。當容器在屏幕內部時它工作正常,但當容器比屏幕大時不能滾動。爲了解決這個問題,我有寫:垂直滾動,拖動元素時無法正常工作
$('.dragable').draggable({
zIndex:100,
revert: "invalid",
helper: "clone",
scroll: true,
drag: function(e)
{
if(e.clientY <= distance)//top
{
isMoving = true;
clearInetervals();
intTopHandler= setInterval(function(){
$(document).scrollTop(e.clientY - step)
},timer);
}
if(e.clientY >= ($(window).height() - distance))//bottom
{
isMoving = true;
clearInetervals();
intBottomHandler= setInterval(function(){
$(document).scrollTop(e.clientY + step)
},timer);
}
}
});
釋放拖動元素屏幕後停留在相同的位置,除非我們再次移動拖動。我試過scrollBy而不是scrollTop方法,但它不適用於移動設備。請建議任何幫助。感謝