我的html页面包含"Nestable“拖放菜单。我的问题是,当我拖拽一些东西并落在页面的末尾时,它需要向下滚动页面,反之亦然。如何使用jQuery或JavaScript?
发布于 2014-07-22 07:30:55
试试这段代码这里
可以在拖放时调用此函数,也可以尝试使用高度来确定页面何时向上/向下滚动,目前它位于屏幕中央的某个位置。
$(document).mousemove(function(e) {
$("html, body").scrollTop(function(i, v) {
var h = $(window).height();
var y = e.clientY - h / 2; //determins the y location where your scrolling starts
return v + y * 0.1; //0.1 determines the speed
});
});编辑: 这里是一个更平滑的过渡,稍微复杂一点,但是你仍然可以理解发生了什么。
https://stackoverflow.com/questions/24881161
复制相似问题