-
Notifications
You must be signed in to change notification settings - Fork 4
/
nineties-marquee.html
34 lines (29 loc) · 861 Bytes
/
nineties-marquee.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<style>
nineties-marquee {
display: block;
white-space: nowrap;
overflow: hidden;
}
</style>
<script>
(function () {
var Marquee = Object.create(HTMLElement.prototype);
Marquee.createdCallback = function () {
var s = document.createElement('span'),
div = document.createElement('div'),
l;
s.innerHTML = this.innerHTML;
document.querySelector('body').appendChild(div);
div.appendChild(s);
l = s.offsetWidth;
document.querySelector('body').removeChild(div);
requestAnimationFrame(move.bind(this));
function move() {
var val = this.style.textIndent.replace(/[^-\d\.]/g, '');
this.style.textIndent = (-val<=l?val-1:this.offsetWidth)+"px";
requestAnimationFrame(move.bind(this));
}
}
document.registerElement('nineties-marquee', {prototype: Marquee});
})();
</script>