Greasy Fork is available in English.

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);

댓글 남기기

댓글을 남기려면 로그인하세요.