There is a draft of such feature as CSS.registerProperty
. In fact, it allows to define types for CSS variables so that browser will be able to extend its abilities about them including animating values.
For me it seems strange that the feature that can be used for CSS-only purposes (example) has only JavaScript representation and can't be used from pure CSS.
Is there any reason to include it in JavaScript but not propose same thing for CSS?
The things that I can't do from CSS now:
syntax
) - without it CSS animation wouldn't work (the same example)inherits: false
It's actually been discussed already, and if things go right, we should be able to use an @property
rule.
Current discussions would convert your js to
@property --alpha {
syntax: "<number>";
initialValue: 1;
inherits: true;
})