Skip to content

Instantly share code, notes, and snippets.

@MarvinJWendt
Created September 7, 2017 03:15
Show Gist options
  • Save MarvinJWendt/1f08ba9c63e8c6a91c76fbfdef0f52f8 to your computer and use it in GitHub Desktop.
Save MarvinJWendt/1f08ba9c63e8c6a91c76fbfdef0f52f8 to your computer and use it in GitHub Desktop.
Fade android url-bar color with javascript and jquery.
var colors = ['#000000', '#080808', '#0F0F0F', '#171717', '#1F1F1F', '#262626 ', '#2E2E2E'];
var colors_length = colors.filter(function () { return true; }).length -1;
var currentColor = 0;
var forwards = true;
setInterval(function() {
if(forwards)
{
$("meta[name='theme-color']").attr("content", colors[currentColor]);
currentColor++;
if(currentColor >= colors_length)
{
forwards = false;
}
}
else
{
$("meta[name='theme-color']").attr("content", colors[currentColor]);
currentColor--;
if(currentColor <= 0)
{
forwards = true;
}
}
}, 100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment