I would like to be able to read the value of a CSS property in the middle of a transition before it is fully executed. Is that possible? So if during a transition from 0% to 100%, I were to check halfway through, could I see it at 50%?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
Yes, it's possible. The corresponding property on the object returned by
getComputedStyle
will change gradually over the course of a transition, as shown in this demo:This behaviour is required by spec. https://www.w3.org/TR/css-transitions-1/#transitions- states:
(Hat tip to https://stackoverflow.com/users/27862/user123444555621 for their comment pointing out the relevant spec passage.)
Yes
So far I've only tested firefox & chrome, but it appears that you can get the current CSS height via JS.
I can't think of a reason why the browser wouldn't report the change in styles to the DOM during a CSS transition.