Last active
December 14, 2015 02:19
-
-
Save nickjacob/5012662 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(){ | |
var body = window.document.body, | |
hh = body.scrollTop, | |
interval = null, | |
style_div = "font-family:helvetica;border-radius:5px;border:1px solid #222;border-bottom: 2px solid #111;padding:10px;position:fixed;top:20px;left:20px;background:#555", | |
style_link = "padding: 5px;background:#222;color:#eee;text-decoration:none;margin:5px;", | |
tpl = "<div id='stoppy' style='" + style_div + "'><a style='" + style_link + "' href='#' id='start-btn'>start</a> \ | |
<a style='" + style_link + "' href='#' id='stop-btn'>stop</a>"; | |
body.insertAdjacentHTML('beforeend', tpl); | |
var stoppy = document.getElementById('stoppy'); | |
stoppy.addEventListener('click', function (e) { | |
e.preventDefault(); e.stopPropagation(); | |
if (e.target.id === 'start-btn') start(); | |
else if (e.target.id === 'stop-btn') stop(); | |
}, false); | |
function start(){ | |
interval = setInterval(function(){ | |
body.scrollTop += 500; | |
}, 1400); | |
}; | |
function stop(){ | |
clearInterval(interval); | |
} | |
}(window)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment