Animate background-position with steps() timing to reduce cpu use

This commit is contained in:
MrOtherGuy 2019-06-24 15:46:13 +03:00
parent 0239329ef8
commit 54b7aededa

View file

@ -3,21 +3,24 @@
/* Constant animation WILL increase CPU usage */ /* Constant animation WILL increase CPU usage */
/*
Thanks to /u/skenera on reddit for suggesting animating background position and using steps() function to reduce cpu load
*/
@keyframes rotate-gradient{ @keyframes rotate-gradient{
from{filter: hue-rotate(0deg)} from{background-position: 0 0;}
to{filter: hue-rotate(360deg)} to{background-position: 200vw 0;}
} }
#TabsToolbar::before{ #TabsToolbar::before{
content: ""; content: "";
display: -moz-box; display: -moz-box;
position: absolute; position: absolute;
width: 100vw; width: 200vw;
height: calc(var(--tab-min-height) + 2px); height: calc(var(--tab-min-height) + 2px);
background-image: linear-gradient(to right, magenta, yellow, cyan); background-image: linear-gradient(to right, magenta, red, yellow, green, cyan, blue, magenta);
animation: rotate-gradient 5s linear infinite; animation: rotate-gradient 10s steps(60) infinite;
/*animation-timing-function: linear; */ /* smoother animation, but greatly increased cpu use */
pointer-events: none; pointer-events: none;
will-change: filter;
z-index: -1; z-index: -1;
} }
@ -41,7 +44,9 @@
opacity: 1 !important; opacity: 1 !important;
} }
.tabbrowser-tab{ padding: 2px 2px 0 2px !important; min-height: calc(var(--tab-min-height) - 2px);} .tabbrowser-tab{ padding: 2px 2px 0 2px !important; }
.tabbrowser-tab:not([selected]){ min-height: calc(var(--tab-min-height) - 2px) !important; }
.tabbrowser-tab[selected]{ .tabbrowser-tab[selected]{
padding: 0px !important; padding: 0px !important;