ant-design-vue/components/_util/isCssAnimationSupported.js

25 lines
599 B
JavaScript
Raw Normal View History

2019-01-12 11:33:27 +08:00
let animation;
2017-12-07 18:33:33 +08:00
2019-01-12 11:33:27 +08:00
function isCssAnimationSupported() {
2017-12-07 18:33:33 +08:00
if (animation !== undefined) {
2019-01-12 11:33:27 +08:00
return animation;
2017-12-07 18:33:33 +08:00
}
2019-01-12 11:33:27 +08:00
const domPrefixes = 'Webkit Moz O ms Khtml'.split(' ');
const elm = document.createElement('div');
2017-12-07 18:33:33 +08:00
if (elm.style.animationName !== undefined) {
2019-01-12 11:33:27 +08:00
animation = true;
2017-12-07 18:33:33 +08:00
}
if (animation !== undefined) {
for (let i = 0; i < domPrefixes.length; i++) {
if (elm.style[`${domPrefixes[i]}AnimationName`] !== undefined) {
2019-01-12 11:33:27 +08:00
animation = true;
break;
2017-12-07 18:33:33 +08:00
}
}
}
2019-01-12 11:33:27 +08:00
animation = animation || false;
return animation;
2017-12-07 18:33:33 +08:00
}
2019-01-12 11:33:27 +08:00
export default isCssAnimationSupported;