画布区域没有向下滚动
您好,
我无法向下滚动画布以放弃拖动的值。实际上我完成了 我的代码可拖动如下。但是在我的页面中,我有两个滚动条。如何滚动我的画布下降。看我的屏幕截图
$( “DND-预览可拖动应答”)。可拖动({
还原:“无效”,
容忍度:“指针”,
appendTo:“body”,
滚动:“true”,
cursorAt:{top:0,left:0},
});
答案 0 :(得分:0)
您可以使用传统方式,您的代码将如下所示:
$(".draggable").draggable({
revert: "invalid",
tolerance: "pointer",
appendTo: $(".inner-content-that-will-be-scrolled"),
scroll : "true",
cursorAt: { top: 0, left: 0 },
drag: function( event, ui ) {
var draggableY = parseInt($('.draggable').css('top'));
var scrolled = $('.inner-content-that-will-be-scrolled').innerHeight();
if (draggableY + 50 >= y2) {
//Start scrolling
$('.page').animate({
scrollTop: scrolled},
{duration: 5000,
step: function() {
var x = parseInt($('.draggable').css('left'));
var y = parseInt($('.draggable').css('top'));
//detect stop scrolling
if ((y + 20 < y2) || y > y2 + 20 || x > x2 || x < x1) {
//cancel animation
$(this).stop();
}
}
});
}
}
});
});