【发布时间】:2015-05-30 16:54:02
【问题描述】:
我正在为我的登录页面制作精灵动画。我有两个精灵动画。第一个动画将开始并播放一次,另一个动画将在第一个动画结束后无限循环。
我知道你会切换类来切换精灵动画,但是我怎样才能让 Angular 监听第一个精灵动画的最后一个关键帧呢?
var app = angular.module('app', ['ui.bootstrap']);
app.controller('animation-toggle', function($scope) {
$scope.class_status = 0;
//toggle class with boolean
$scope.toggleSingleClass = function() {
$scope.class_status = !$scope.class_status;
};
//remove class
$scope.removeSingleClass = function() {
$scope.class_status =0;
};
//add class
$scope.addSingleClass = function() {
$scope.class_status = 1;
};
});
/* FIRST ANIMATION */
.land-animation {
width: 700px;
height: 493px;
margin: 60px auto;
background: url('../images/font-animation.jpg') left center;
animation: play 4.0s steps(48);
}
@keyframes play {
100% { background-position: -33600px; }
}
/* SECOND ANIMATION */
.land-animation2 {
width: 700px;
height: 493px;
margin: 60px auto;
background: url('../images/font-animation2.jpg') left center;
animation: play 4.0s steps(48) infinite;
}
@keyframes play {
100% { background-position: -33600px; }
}
<!-- RUNNING ANGULAR 1.3.15 -->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
<!-- DIV ANIMATION -->
<div ng-controller="animation-toggle" ng-class="{'land-animation2': class_status }" class="hero-unit land-animation"></div>
【问题讨论】:
标签: css angularjs animation sprite