htmlautoscroll
Advanced tools
Comparing version 1.0.1 to 1.0.4
var scrollDir = sessionStorage.getItem('direction') || 1 | ||
var scrollTimer; | ||
function scrollMore(speed, extremityWait) { | ||
function htmlautoscrollMore(speed, extremityWait, extremityCb) { | ||
window.scrollBy(0, scrollDir * speed) | ||
@@ -17,2 +17,5 @@ sessionStorage.setItem('scroll_position', window.pageYOffset) | ||
if (reachedTop || reachedBottom) { | ||
if (extremityCb) { | ||
extremityCb(reachedBottom); | ||
} | ||
var nextDir = scrollDir * -1; | ||
@@ -27,9 +30,13 @@ scrollDir = 0; | ||
function startScroll(speed, extremityWaitMs = 2000) { | ||
function htmlautoscrollStart(speed, extremityWaitMs = 2000, extremityCb) { | ||
htmlautoscrollStop(); | ||
if (speed > 0) { | ||
scrollTimer = setInterval(htmlautoscrollMore, speed > 1 ? 1 : 1 / speed, speed > 1 ? speed : 1, extremityWaitMs, extremityCb); | ||
} | ||
} | ||
function htmlautoscrollStop() { | ||
if (scrollTimer) { | ||
clearInterval(scrollTimer); | ||
} | ||
if (speed > 0) { | ||
scrollTimer = setInterval(scrollMore, speed > 1 ? 1 : 1 / speed, speed > 1 ? speed : 1, extremityWaitMs); | ||
} | ||
} |
{ | ||
"name": "htmlautoscroll", | ||
"version": "1.0.1", | ||
"version": "1.0.4", | ||
"description": "Automatically scroll HTML page indefinitely", | ||
@@ -5,0 +5,0 @@ "main": "htmlautoscroll.js", |
Sorry, the diff of this file is not supported yet
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
37508
6
34
1
35