I'm rendering a list of objects using ng-repeat
with an orderBy
filter like this:
<li class="list-item" ng-repeat="item in items | orderBy:predicate:reverse">
My attempts to ng-animate a change in sorting of the list have proven frustrating and aren't worth sharing. I have seen the Yearofmoo example app here.
Unfortunately this demonstration is not quite what I'm trying to achieve. I need to animate the X position of a given list item when it is placed in a new order after the orderBy
definition changes. I have tried to accomplish this with css transitions and absolute positioning, but ng-repeat
seems to recreate the list items on orderBy
making animation a real challenge.
- Is this possible with
ng-repeat | orderBy
(with or withoutng-animate
)? - Can you suggest an approach or provide an example?
So, even if @Alex Osborn has shown a way to do what you want in the comments, here is my attempt:
So, AngularJS doesn't order the items, but it changes the CSS attribute
top
(ng-style="{top: ...}"
). AngularJS doesn't recreate the list and we get a nice animation. :)I've expanded upon AndreM96's answer to allow displaying the list as a grid.
JSBin Demo