Skip to content

Instantly share code, notes, and snippets.

@rbk
Last active June 13, 2025 13:21
Show Gist options
  • Save rbk/5da264b737c00118239e7f201084b02b to your computer and use it in GitHub Desktop.
Save rbk/5da264b737c00118239e7f201084b02b to your computer and use it in GitHub Desktop.
turns the tab title into an animated marquee
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