Trying to bring some transitions to the page with smoothstate.js alive , and I'm at a dead end.
Here's jsfiddle, but it throws a console error that I don't get during development. However, you can still see the css issue I'm talking about: http://jsfiddle.net/3f5wp9xL/6/
Here's another demo that doesn't have a console error: http://davidwesleymartin.com/animtest/index.html
All animations are set in CSS (via @keyframe, animation properties).
Animations work with page loading, but they behave strangely when I try to change them after clicking a link. I try to cancel them by resetting the 'animation-direction' property when the completion class ('is-exiting') is added to the main container after clicking the link.
The only way I can get this to work is to set the NEW value to the "animated name", if it is the same value as before, it does not work.
Relevant HTML:
<div id='main'> <aside class='main-side'> <div class='anim_element anim_element--fadeIn'> <h2>sidebar</h2> <ul> <li> <a href='index.html'>Link 1</a> </li> <li> <a href='index.html'>Link 2</a> </li> <li> <a href='index.html'>Link 3</a> </li> </ul> </div> </aside> <div class='main-content'> <div class='anim_element anim_element--fadeInLeft'> <h1>Main Content</h1> <p>Lorem...</p> </div> </div> </div>
Corresponding CSS ( note : everything is correctly prefixed on the demo, this is not a problem):
@keyframes fadeIn{ 0% { opacity:0; transform:scale(0.8); } 100% {opacity:1;} } @keyframes fadeInLeft{ 0% { opacity:0; transform: translate3d(-100%, 0, 0); } 100% { opacity:1; } } #main .anim_element{ animation-duration: .25s; transition-timing-function: ease-in; animation-fill-mode: both; } #main .anim_element--fadeIn{ animation-name: fadeIn; } #main .anim_element--fadeInLeft{ animation-name: fadeInLeft; } #main.is-exiting .anim_element{ animation-name: fadeIn; animation-direction: alternate-reverse; }
source share