AutoScroll

AutoScroll - 双击切换自动滚屏

< 脚本AutoScroll的反馈

评价:一般 - 脚本能用,但还有一些问题

§
发表于:2016-09-22

Thanks for the headstart

I can see where you were going with this but it didn't quite work right, for me. With a little tweak, it did. I added a speed value to the variable definitions, a Y position value, and the ability to stop, scroll, and restart where you are.

(function(document) {
var enable = false,
handler = 0,
sSpeed = 1000,
sTop,
dbclick = function() {
enable = !enable;
clearTimeout(handler);
if (enable) {
aScroll();
}
else {
sTop = undefined;
}
};

document.body.removeEventListener('dblclick', dbclick);
document.body.addEventListener('dblclick', dbclick);

var aScroll = function() {
if (enable) {
if (sTop === undefined) sTop = window.scrollY;
sTop += 3;
window.scrollTo(0, sTop);
}
handler = setTimeout(aScroll, sSpeed);
};
})(document);

发表回复

登录(不可用)以发表回复。

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址