Показать сообщение отдельно
  #42 (permalink)  
Старый 31.12.2011, 12:41
sinistral
Посмотреть профиль Найти все сообщения от melky
 
Регистрация: 28.03.2011
Сообщений: 5,418

css-animation support detecting
Сообщение от Nekromancer Посмотреть сообщение
В общем виде выглядит как то так:
if(window.AnimationEvent || 'onanimationend' in document.body || document.body.onanimationend === null){
//oh yeah..
}else if(window.VendorAnimationEvent){
// oh.. not so bad
}else {
//fuck, no..
}
"если это утка, то она ходит и крякает, как утка."

подход с другой стороны
"если это ходит и крякает, как утка, то это - утка"

var animation = false,  
    animationstring = 'animation',  
    keyframeprefix = '',  
    domPrefixes = 'Webkit Moz O ms Khtml'.split(' '),  
    pfx  = '';  
  
if( elm.style.animationName ) { animation = true; }      
  
if( animation === false ) {  
  for( var i = 0; i < domPrefixes.length; i++ ) {  
    if( elm.style[ domPrefixes[i] + 'AnimationName' ] !== undefined ) {  
      pfx = domPrefixes[ i ];  
      animationstring = pfx + 'Animation';  
      keyframeprefix = '-' + pfx.toLowerCase() + '-';  
      animation = true;  
      break;  
    }  
  }  
}


отсюда узнаем префикс (код с MDN), далее просто :

element[pfx.toLowerCase() + 'animationend'] = function(){...}
Ответить с цитированием