From 74da6b38dd00947961f695e1f4f6fa61ea40e93f Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Mon, 20 Apr 2015 10:41:47 +0300 Subject: [PATCH] Transition (background-)color on theme change --- css/custom.css | 6 +++++- js/90-themes.js | 10 +++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/css/custom.css b/css/custom.css index 0188fd4..fa66f23 100644 --- a/css/custom.css +++ b/css/custom.css @@ -78,4 +78,8 @@ td.user, td.owner { #themes:before { content: " Themes: "; -} \ No newline at end of file +} + +.transition-color, .transition-color * { + transition: color 0.5s ease-in, background-color 0.5s ease-in; +} diff --git a/js/90-themes.js b/js/90-themes.js index 1ff13ae..aa2cdc9 100644 --- a/js/90-themes.js +++ b/js/90-themes.js @@ -1,4 +1,8 @@ -function set_style(name){ +function set_style(name, trans){ + if(trans){ + document.body.classList.add('transition-color'); + setTimeout(() => document.body.classList.remove('transition-color'), 1000); + } $('link[title]').each(e => e.disabled = true); $('link[title="' + name + '"]')[0].disabled = false; localStorage.setItem("theme", name); @@ -11,12 +15,12 @@ $(function() { '
  • White'; var sidebar = $('#sidebar')[0]; sidebar.insertBefore(m(theme_ul), sidebar.firstChild); - $('#themes a').on('click', e => set_style(e.target.dataset.theme)); + $('#themes a').on('click', e => set_style(e.target.dataset.theme, true)); }); let theme = localStorage.getItem("theme"); if(theme) { if(theme == "cerulean" || theme == "cosmo") theme = "readable"; - set_style(theme); + set_style(theme, false); } -- 2.39.2