[英]angularjs restart css animation
I am using angularjs and I am trying to trigger an animation each time a model property is changed. 我正在使用angularjs,我试图在每次更改模型属性时触发动画。 My controller:
我的控制器:
function myCtrl($scope) {
$scope.data.counter = 0;
$scope.addCount = function() {
$scope.data.counter ++;
};
}
My html: 我的HTML:
<div ng-controller="myCtrl">
<button ng-click="addCount()">add count</button>
<div class="bgimage"></div>
</div>
My css: 我的css:
.bgimage {
background-image: url('../images/a.png');
background-position: right;
background-size: 16px 14px;
width: 16px;
height: 14px;
}
.bgimage.pulse {
-webkit-animation: pulse 1s both;
-moz-animation: pulse 1s both;
-o-animation: pulse 1s both;
animation: pulse 1s both;
}
I want that each time 'count' changes, the 'bgimage' element will be 'pulsed'. 我希望每次'计数'改变时,'bgimage'元素将被'脉冲'。
Any idea? 任何的想法?
I did a little Plunker , using JS Animations and animating based on your counter variable. 我做了一个小的Plunker ,使用JS动画和基于你的计数器变量的动画。 You can extend that example as you wish.
您可以根据需要扩展该示例。 I guess you just wanted to pulsate once (as using 'both' in your animation).
我想你只是想要一次脉动(就像在你的动画中使用'both')。
You could also go for CSS keyframes animations, as described here 你也可以去CSS关键帧动画,描述在这里
从元素中删除并添加脉冲类,以便再次进行动画处理。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.