Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use transition on flexbox order

Is there any way to have a transition on the order of flex-box items?

In other words, can I have this (details in this fiddle)

#container {     display: flex; } #container:hover div:last-child {     order: -1; } 

animated (the element getting the new position assumes it's position over time), please?

like image 697
Thorben Croisé Avatar asked Sep 17 '13 09:09

Thorben Croisé


People also ask

Can you animate flex order?

Sadly no: the order attribute is animatable, but only as integers.

Can you transition flex-direction?

The answer is no. flex-direction is not an animatable property in CSS.

What Flexbox property changes the order of the Flex items?

The order property and accessibility Use of the order property has exactly the same implications for accessibility as changing the direction with flex-direction . Using order changes the order in which items are painted, and the order in which they appear visually.


1 Answers

Sadly no: the order attribute is animatable, but only as integers. That means that for each step/frame of the animation it will interpolate the value by flooring to the neareast integer. So items will only ever show up in the slot that the computed integer value results in, never in-between in any smooth sort of motion way.

It's technically still an animation: the calculated integer position should still follow the timing function and keyframe rules of the animation, it's just that the items "jump" from position to position as they change.

See https://developer.mozilla.org/en-US/docs/Web/CSS/integer#Interpolation

like image 79
Emil Avatar answered Sep 17 '22 17:09

Emil