当用户将鼠标移到屏幕/图表上时,自动滚动将暂停.如果鼠标移动停止,自动滚动将再次恢复
auto-scrolling will pause when user moves mouse over screen / graphs. And auto-scrolling will resume again if mouse movement is stopped
您好,我有用于自动滚动页面的工作代码。我需要对此进行一些修改。当用户在页面上移动鼠标时需要暂停自动滚动,并且当没有鼠标移动时,自动滚动将恢复。
<script>
$("html, body").animate({ scrollTop: $(document).height() }, 400000);
setTimeout(function() {
$('html, body').animate({scrollTop:0}, 400000);
},400000);
setInterval(function(){
// it will take 40 secound in total from the top of the page to the bottom
$("html, body").animate({ scrollTop: $(document).height() }, 400000);
setTimeout(function() {
$('html, body').animate({scrollTop:0}, 400000);
},400000);
},8000);
</script>
希望这就是你要找的
var x = 10,
y = true,
z = 1,
maxscroll = 40,
mixscroll = 10;
setInterval(function() {
$('html, body').mousemove(function() {
z = 0;
});
if (z === 0) {
setTimeout(function() {
z = x;
}, 1000);
} else {
z = x;
if (y) {
$('html, body').animate({ scrollTop: ($(window).scrollTop() + z) + 'px' }, 300);
x++;
} else {
$('html, body').animate({ scrollTop: ($(window).scrollTop() + -(z)) + 'px' }, 300);
x--;
}
}
if (maxscroll < x && y) {
y = false;
} else if (x < mixscroll) {
y = true;
}
}, 500);
https://jsfiddle.net/donS/9xdz86yu/
你可以在jQuery中使用.stop()
函数,比如..
$("html, body").mouseover(function(){
$(this).stop();
});
试试这个小提琴
相关文章:
- JQuery UI可拖动潜水与滚动棒到鼠标
- 如何查明鼠标按下事件是否发生在滚动条上或元素中的其他任何位置
- fullpage.js和物化.js;使用实体侧导航禁用鼠标滚动
- 如何避免鼠标水平滚动选项卡面板溢出
- 如何在鼠标滚轮滚动上设置剪切遮罩的动画
- 如何使用鼠标滚动控制fullPage.js垂直滑块
- 使用鼠标滚轮水平滚动页面
- 网站跟随鼠标滚动
- 用鼠标逐个滚动页面
- 当用户将鼠标移到屏幕/图表上时,自动滚动将暂停.如果鼠标移动停止,自动滚动将再次恢复
- jQuery UI 对话框和滚动块竞争鼠标
- JQuery 自动滚动到底部(但在鼠标滚动时禁用)
- 我想要一个类似于网站 https://onlycoin.com/ 的jQuery鼠标滚动动画效果
- 禁用预测滚动 - 鼠标滚轮 (OnScroll) 事件触发过于频繁(触摸板)
- 在动态创建的 svg 元素上滚动鼠标时放大/缩小
- 垂直滚动鼠标时图像移动
- 停止滚动鼠标
- carouFredSel滚动鼠标按下
- 气泡滚动/鼠标滚轮事件
- 如何获取 CKEDITOR 文本区域的滚动/鼠标/光标的 X Y 位置