Greasy Fork is available in English.

AutoScroll

AutoScroll - 双击切换自动滚屏

< Commentaires sur AutoScroll

Avis: OK - le script fonctionne, mais souffre de quelques problèmes

§
Posté le: 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);

Poster une réponse

Connectez-vous pour poster une réponse.