UNPKG

motion

Version:

The Motion library for the web

28 lines (26 loc) 867 B
const testAnimation = (keyframes) => document.createElement("div").animate(keyframes, { duration: 0.001 }); const featureTests = { cssRegisterProperty: () => typeof CSS !== "undefined" && Object.hasOwnProperty.call(CSS, "registerProperty"), waapi: () => Object.hasOwnProperty.call(Element.prototype, "animate"), partialKeyframes: () => { try { testAnimation({ opacity: [1] }); } catch (e) { return false; } return true; }, finished: () => Boolean(testAnimation({ opacity: [0, 1] }).finished), }; const results = {}; const supports = Object.keys(featureTests).reduce((acc, key) => { acc[key] = () => { if (results[key] === undefined) results[key] = featureTests[key](); return results[key]; }; return acc; }, {}); export { supports };