Last active
June 13, 2025 13:21
-
-
Save rbk/5da264b737c00118239e7f201084b02b to your computer and use it in GitHub Desktop.
turns the tab title into an animated marquee
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
const titleChanger = () => { | |
const state = { | |
title: '___Hi there!___' | |
}; | |
const swap = () => { | |
const parts = state.title.split(""); | |
const lastItem = parts.pop(); | |
const firstItem = parts.shift(); | |
state.title = [ | |
...parts, | |
lastItem, | |
firstItem | |
].join("") | |
document.title = state.title | |
return state.title; | |
} | |
return () => { | |
return { | |
getState: () => { | |
return state; | |
}, | |
autoSwap: () => { | |
setInterval(function() { | |
swap() | |
}, 200) | |
}, | |
swap: swap | |
} | |
} | |
} | |
const t = titleChanger()(); | |
t.autoSwap() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment