Skip to content

Commit

Permalink
Create 21-transitions-animations.js
Browse files Browse the repository at this point in the history
WIP. Rel #21.
  • Loading branch information
LeaVerou committed Sep 15, 2020
1 parent 3b042e9 commit 166d771
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions js/21-transitions-animations.js
Original file line number Diff line number Diff line change
@@ -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;

}

0 comments on commit 166d771

Please sign in to comment.