Last active
June 18, 2016 12:00
-
-
Save LeaVerou/dda915b008971eb6808b to your computer and use it in GitHub Desktop.
Static interpolation via paused animations
This file contains 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
/** | |
* Static interpolation via paused animations | |
* This technique becomes more useful if you need to interpolate more than 1 properties, and/or if you need multiple values in the spectrum | |
* Currently works in every modern browser except Safari | |
*/ | |
@keyframes foo { | |
from { background: red } | |
to { background: yellowgreen } | |
} | |
div { | |
display: inline-block; | |
width: 100px; height: 100px; | |
animation: foo 1s both linear; | |
animation-play-state: paused; | |
} | |
div:nth-of-type(2) { animation-delay: -.2s; } | |
div:nth-of-type(3) { animation-delay: -.4s; } | |
div:nth-of-type(4) { animation-delay: -.6s; } | |
div:nth-of-type(5) { animation-delay: -.8s; } | |
div:nth-of-type(6) { animation-delay: -1s; } |
This file contains 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
<div></div> | |
<div></div> | |
<div></div> | |
<div></div> | |
<div></div> | |
<div></div> |
This file contains 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
// alert('Hello world!'); |
This file contains 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
{"view":"split","fontsize":"100","seethrough":"","prefixfree":"1","page":"css"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This won't actually work in Safari, IE or Edge in any version.
Negative
animation-delay
is handled by the specification – ifanimation-delay
is to be applied for animations withanimation-play-state: paused;
is not, so I would not bet on Safari or Edge changing their interpretation anytime soon.You can do this WebAnimations, so I wrote a library to give you this technique in a cross-browser compatible way: https://github.com/marionebl/jogwheel