You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
808 B
34 lines
808 B
'use strict';
|
|
|
|
(async ( ) => {
|
|
|
|
const TOP_MARGIN = 0; // set to top margin you want for the page scroller
|
|
const SCROLL_SPEED = 2; // number of pixels to scroll per frame
|
|
const START_DELAY_MS = 0; // set startup delay in milliseconds
|
|
const HEIGHT = 200000; // set to max distance you want to scroll
|
|
|
|
let y = TOP_MARGIN;
|
|
let paused = false;
|
|
|
|
function update ( ) {
|
|
try {
|
|
if (!paused) {
|
|
window.scrollTo(0, y);
|
|
y += SCROLL_SPEED;
|
|
}
|
|
if (y < HEIGHT) {
|
|
window.requestAnimationFrame(update);
|
|
}
|
|
} catch (error) {
|
|
console.log('update has failed', error);
|
|
}
|
|
}
|
|
|
|
try {
|
|
window.scrollTo(0, y);
|
|
window.setTimeout(update, START_DELAY_MS);
|
|
} catch (error) {
|
|
console.log('scroller has failed', error);
|
|
}
|
|
|
|
})();
|
|
|