-
-
Save ClaudiuCeia/39d73505afc3e87d69fa6bc1e1c757ab to your computer and use it in GitHub Desktop.
You need a marquee. And a blink.
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
/** | |
* This marquee stuff is deliberately low-tech. Use at your own risk. Licensed under whatever license you need. | |
* | |
* Usage: `marquee();` | |
*/ | |
function marquee(behavior, direction) { | |
var behaviors = { | |
scroll: 'scroll', | |
slide: 'slide', | |
alternate: 'alternate' | |
}; | |
var directions = { | |
left: 'left', | |
right: 'right', | |
up: 'up', | |
down: 'down' | |
}; | |
var marquee = document.createElement('marquee'); | |
if (behavior && behaviors.hasOwnProperty(behavior)) { | |
marquee.behavior = behavior; | |
} | |
if (direction && directions.hasOwnProperty(direction)) { | |
marquee.direction = direction; | |
} | |
marquee.innerHTML = document.body.innerHTML; | |
document.body.innerHTML = ''; | |
document.body.appendChild(marquee); | |
console && console.log('Enjoy.'); | |
} | |
function blink() { | |
var html = document.body.innerHTML; | |
var is_blink = false; | |
setInterval(function() { | |
if (!is_blink) { | |
document.body.innerHTML = ''; | |
is_blink = true; | |
} else { | |
document.body.innerHTML = html; | |
is_blink = false; | |
} | |
}, 500) | |
console && console.log('Enjoy.'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very clever implementation of
<blink />
, but what is it doing inmarquee.js
‽ ;)