You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I enjoy using anime.set() because it allows to set multiple properties at once and makes it possible to set numbers instead of strings like myValue + "px". But I feel there are some inconsistencies.
According to MDN, displayis not animatable. However, this works fine:
anime.set(myDiv, { display: "none" });
According to MDN, heightis animatable. However, this does not work:
anime.set(myDiv, { height: 200 });
anime.set(myDiv, { height: "auto" }); // doesn't work, height is still "200px"
I know that auto itself is not animatable. But I don't even need to animate it, I only need to set it.
I've also tried another way to make the element's height go back to its initial value of auto:
anime.set(myDiv, { height: 200 });
anime.set(myDiv, { height: null }); // doesn't work, height is still "200px"
But on the other hand, setting display to nullworks fine:
anime.set(myDiv, { display: "none" });
anime.set(myDiv, { display: null }); // works, falls back to "block"
Even weirder, after height is set without anime.set(), it can't seem to be overwritten by anime.set():
myDiv.style.height = "auto";
anime.set(myDiv, { height: 200 }); // doesn't work, height is still "auto"
Expected behavior
The behavior of set() should be consistent (from a consumers perspective).
The docs should be clear about which CSS properties are set()-able and which are not (because it seems that anime does not reflect MDN).
The docs should explain how specific properties can be unset (to make the element go back to its initial value).
Questions
What is the correct way to set height to auto (using anime.set() instead of myDiv.style.height = "auto")?
Is there another way to "unset" a property that I've missed?
Version
3.1.0
Thanks
I appreciate your fantastic work!!!
The text was updated successfully, but these errors were encountered:
The behavior of set() should be consistent (from a consumers perspective).
I agree, originally set() has been created only to work with numerical values.
The doc about anime.set() says that:
Any CSS properties can be animated
However, this is not really true according to the list of MDN Animatable CSS properties, right?
True, I might change this to
Any CSS numerical properties can be animated
anime.set(myDiv, { display: "none" });
anime.set(myDiv, { display: null }); // works, falls back to "block"
This works but set() wasn't really intended to be used with non-numerical values.
It has been designed to work as a sidekick to anime() to be able to update the animation values without having to create duration: 0 animations, but not to be a fully functional CSS styling function.
I think there is room for improvement regarding 'auto' values types and will see if I can better handle null values too in future releases.
juliangarnier
changed the title
Inconsistent behavior and documentation of set()?
[FEATURE] Inconsistent behavior and documentation of set()?
Apr 25, 2025
Uh oh!
There was an error while loading. Please reload this page.
Current behavior
I enjoy using
anime.set()
because it allows to set multiple properties at once and makes it possible to set numbers instead of strings likemyValue + "px"
. But I feel there are some inconsistencies.The doc about
anime.set()
says that:However, this is not really true according to the list of MDN Animatable CSS properties, right?
According to MDN,
display
is not animatable. However, this works fine:According to MDN,
height
is animatable. However, this does not work:I know that
auto
itself is not animatable. But I don't even need to animate it, I only need to set it.I've also tried another way to make the element's
height
go back to its initial value of auto:But on the other hand, setting
display
tonull
works fine:Even weirder, after
height
is set withoutanime.set()
, it can't seem to be overwritten byanime.set()
:Expected behavior
set()
should be consistent (from a consumers perspective).set()
-able and which are not (because it seems that anime does not reflect MDN).Questions
height
toauto
(usinganime.set()
instead ofmyDiv.style.height = "auto"
)?Version
3.1.0
Thanks
I appreciate your fantastic work!!!
The text was updated successfully, but these errors were encountered: