监听 CSS 动画执行状态

1
2
3
4
5
6
7
8
9
10
11
12
13
14
function prefixedEventListener (element, type, callback) {
if(element && type && callback){
var pfx = ["webkit", "moz", "MS", "o", ""];

for (var p = 0; p < pfx.length; p++) {
if (!pfx[p]) type = type.toLowerCase();
element.addEventListener(pfx[p]+type, callback, false);
}
}
}

prefixedEventListener($template[0], "animationend",function(e){
// todo
});