Open kraftwer1 opened 3 years ago
Thanks for taking the time to do all these tests.
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.
IMHO, anime.set()
should become the replacement for using element.style = …
because:
element.style = …
numerous times)14 + "px"
…and therefore it‘d be great if…
undefined
to set()
set()
allows all values
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'sheight
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!!!