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

25 lines
599 B
TypeScript
Raw Normal View History

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