From 166d7711e81daef6831fe361d6dae90489b1c232 Mon Sep 17 00:00:00 2001 From: Lea Verou Date: Wed, 16 Sep 2020 01:34:06 +0300 Subject: [PATCH] Create 21-transitions-animations.js WIP. Rel #21. --- js/21-transitions-animations.js | 47 +++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 js/21-transitions-animations.js diff --git a/js/21-transitions-animations.js b/js/21-transitions-animations.js new file mode 100644 index 0000000..d18d6c3 --- /dev/null +++ b/js/21-transitions-animations.js @@ -0,0 +1,47 @@ +export default function compute() { + +let ret = { + properties: [], + timingFunctions: new Set(), + animationNames: new Set() +}; + +walkDeclarations(ast, ({property, value}) => { + if (["inherit", "initial", "unset", "revert"].includes(value)) { + return; + } + + if (property === "transition-property") { + ret.properties.add(value); + } + else if (property === "transition-timing-functon") { + let name = value.match(/^[a-z-]+)/)[0]; + ret.timingFunctions + } + else if (property === "transition") { + // Extract property name and timing function + let keywords = (value.match(/(^|\s)(d|r|[cr]?x|[cr]?y|[a-z-]{3,})(?=\s|$)/) || []); + let properties = [], easings = []; + + for (let keyword of keywords) { + + } + // Drop timing functions and global values + .filter(p => !/^(?:ease(-in|-out)?|)$/.test(p)); + ret.properties.push(...properties); + } +}, { + properties: /^(transition|animation)(?=$|-)/g +}) + +// Animation names +walkRules(ast, rule => { + ret.animationNames.add(rule.name); +}, {type: "keyframes"}); + +ret.properties = [...new Set(ret.properties)]; +ret.animationNames = [...ret.animationNames]; + +return ret; + +}