webkit的transition结束事件叫做webkitTransitionEnd,Firefox是transitionEnd,opera是oTransitionEnd。在纯 JS 中处理所有这些问题的好方法是什么?我应该做浏览器嗅探吗?还是分别实施每一项?其他一些我没有想到的方式?
IE:
//doing browser sniffing
var transitionend = (isSafari) ? "webkitTransitionEnd" : (isFirefox) ? "transitionEnd" : (isOpera) ? "oTransitionEnd";
element.addEventListener(transitionend, function(){
//do whatever
},false);
或者
// Assigning an event listener per browser
element.addEventListener("webkitTransitionEnd", fn);
element.addEventListener("oTransitionEnd", fn);
element.addEventListener("transitionEnd", fn);
function fn() {
//do whatever
}