Created
July 10, 2017 15:40
-
-
Save peterschmiz/054beb069cd981e42389999a5b1e5de0 to your computer and use it in GitHub Desktop.
// source https://jsbin.com
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
(function() { | |
var light = document.querySelector('.f1-lights .light-strip:last-child'); | |
var wentOn = false; | |
var event = new MouseEvent('mousedown', { | |
'view': window, | |
'bubbles': true, | |
'cancelable': true | |
}); | |
function init() { | |
window.requestAnimationFrame(loop); | |
} | |
function loop() { | |
var isItOn = light.classList.contains('on'); | |
var doLoop = true; | |
if (isItOn && wentOn === false) { | |
wentOn = true; | |
} else if (isItOn === false && wentOn) { | |
doLoop = false; | |
document.body.dispatchEvent(event); | |
} | |
if (doLoop) { | |
window.requestAnimationFrame(loop); | |
} | |
} | |
init(); | |
}()); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">(function() { | |
var light = document.querySelector('.f1-lights .light-strip:last-child'); | |
var wentOn = false; | |
var event = new MouseEvent('mousedown', { | |
'view': window, | |
'bubbles': true, | |
'cancelable': true | |
}); | |
function init() { | |
window.requestAnimationFrame(loop); | |
} | |
function loop() { | |
var isItOn = light.classList.contains('on'); | |
var doLoop = true; | |
if (isItOn && wentOn === false) { | |
wentOn = true; | |
} else if (isItOn === false && wentOn) { | |
doLoop = false; | |
document.body.dispatchEvent(event); | |
} | |
if (doLoop) { | |
window.requestAnimationFrame(loop); | |
} | |
} | |
init(); | |
}()); | |
</script></body> | |
</html> |
This file contains 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
(function() { | |
var light = document.querySelector('.f1-lights .light-strip:last-child'); | |
var wentOn = false; | |
var event = new MouseEvent('mousedown', { | |
'view': window, | |
'bubbles': true, | |
'cancelable': true | |
}); | |
function init() { | |
window.requestAnimationFrame(loop); | |
} | |
function loop() { | |
var isItOn = light.classList.contains('on'); | |
var doLoop = true; | |
if (isItOn && wentOn === false) { | |
wentOn = true; | |
} else if (isItOn === false && wentOn) { | |
doLoop = false; | |
document.body.dispatchEvent(event); | |
} | |
if (doLoop) { | |
window.requestAnimationFrame(loop); | |
} | |
} | |
init(); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment