0
我想分配类来做基于变量的动画。如何在我的情况下在CSS中应用动画?
我有类似
//animationOn is default to false.
<div ng-click="animationOn = !animationOn">
<div ng-class="(animationOn ? 'moveRight' : 'moveLeft')">
contents..
</div>
</div>
CSS
.moveRight{
-webkit-animation: moveRightAni 1s;
animation:moveRightAni 1s;
}
@-webkit-keyframes moveRightAni{
from {width: 100px;}
to {width: 300px;}
}
.moveLeft{
-webkit-animation: moveLeftAni 1s;
animation:moveLeftAni 1s;
}
@-webkit-keyframes moveLeftAni{
from {width: 300px;}
to {width: 100px;}
}
我的问题是,当第一次加载页面时,我总是看到300px
元素规模100px
动画显示,因为animationOn
是默认假。当页面首次加载而不是看到它应用moveLeftAni
动画时,我需要将元素保留在100px
中。有没有办法做到这一点?非常感谢!