css3 - Transition from one animation to another -
so, simple question:
i have element, has animation in normal state - transform-animation (perspective
, rotatex
, rotatez
- rotatez
changes) runs constantly. on :hover
want change animation (remove rotatex
, perspective
transform, keep rotatez
animation) - that's no problem, want animation transition new animation , have no clue how accomplish that.
from:
@-webkit-keyframes rotatespace { 0% { transform:perspective(555px) rotatex(55deg) rotatey(0deg) rotatez(0deg) scale(1.25); } 100% { transform:perspective(555px) rotatex(55deg) rotatey(0deg) rotatez(360deg) scale(1.25); } }
to:
@-webkit-keyframes rotateflat { 0% { transform:perspective(0) rotatex(0deg) rotatey(0deg) rotatez(0deg) scale(1.25); } 100% { transform:perspective(0) rotatex(0deg) rotatey(0deg) rotatez(360deg) scale(1.25); } }
instead of applying transform styles 1 element use :before
pseudo element animated block , element "3d" effect (the rotatex
).
example:
.block { position: absolute; top:100px; left:100px; width: 100px; height:100px; transform-origin: center center 0px; overflow:visible; transform:perspective(555px) rotatex(55deg) scale(1.25); transition:transform .5s; } .block:before { content: ""; position: absolute; width: 100%; height: 100%; background: blue; animation-name: rotatespace; animation-duration: 15s; animation-iteration-count: infinite; animation-direction: reverse; animation-timing-function: linear; } .block:hover { transform:perspective(555px) rotatex(0deg) scale(1.25); } @keyframes rotatespace { 0% { transform:rotatez(0deg); } 100% { transform:rotatez(360deg); } }
<div class="block"></div>
Comments
Post a Comment