Created
March 23, 2017 23:32
-
-
Save esprehn/afec30fbc655bba6bb8f3f67c28beef4 to your computer and use it in GitHub Desktop.
Blinking caret that sleeps the main thread for 500ms
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> | |
<style> | |
#caret { | |
height: 16px; | |
width: 1px; | |
background: black; | |
will-change: opacity; | |
opacity: 1; | |
transition: opacity; | |
transition-duration: 500ms; | |
} | |
</style> | |
<div id="caret"></div> | |
<script> | |
var caret = document.getElementById("caret"); | |
function blink() { | |
var opacity = caret.style.opacity; | |
caret.style.opacity = (opacity == "1") ? "0" : "1"; | |
setTimeout(blink, 1000); | |
} | |
blink(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment