过渡动画在角度中不起作用
Transition animation does not work in Angular
您能否看一下代码片段,让我知道为什么动画不起作用,例如没有不透明度变化和背景颜色变化。请注意,代码完全取自一本书,所以我真的很困惑它如何无法工作。
请不要说css文件,angular-animate包含在html中
<link rel="stylesheet" href="css/simple.css"/>
<script src="lib/angular/angular-animate.js"></script>
html 的正文:
<body>
<div ng-init="isShown=true">
<input type="checkbox" ng-model="isShown" />Show
<div ng-class="my-animation-class" ng-if="isShown">
<h3>Enter/Leave Animation</h3>
</div>
</div>
</body>
CSS代码:
.my-animation-class.ng-enter {
-webkit-transition: 0.5s linear all;
-o-transition: 0.5s linear all;
-moz-transition: 0.5s linear all;
opacity: 0;
background: green;
}
.my-animation-class.ng-enter.ng-enter-active {
opacity: 1;
}
另请注意,ngAnimate 在应用程序中作为依赖项存在.js
请帮忙!事先谢谢你!如果有任何问题,请告诉我。
你的问题是你正在使用ng-class并将my-animation-class作为范围变量传递,要解决这个问题,你应该使用
<div ng-class="'my-animation-class'" ng-if="isShown">
甚至
<div class="my-animation-class" ng-if="isShown">
这样,您的div 将具有类并且动画将运行。
希望它能解决您的问题。
相关文章:
- JQuery动画延长容器不起作用
- 滚动动画代码不起作用
- -webkit转换在JavaScript旋转动画中不起作用(没有JQuery)
- firefox中的CSS动画不起作用
- jQuery切换方法的动画不起作用
- 悬停不起作用时对不透明度更改进行动画处理
- j查询动画重置后事件不起作用
- 对链接的 svg 进行动画处理不起作用;内联时工作正常
- 使用动画时Jquery后退按钮不起作用
- 动画代码没有'不起作用
- SVG元素的动态动画在IE中不起作用
- 传单.markrcluster:动画不起作用
- jquery UI添加带有动画的类;不起作用
- ng重复's动画;在同一元素上使用ngInclude时不起作用
- Iframe加载动画不起作用
- HTML5-逐帧动画不起作用
- Javascript图像动画在Firefox或Internet Explorer中不起作用
- 翻转动画在Firefox上不起作用
- 输入文本的动画在firefox中不起作用
- Javascript动画不起作用