I move some elements on the page using ng-repeat and CSS transitions. If I modify the data array using unshift , the list goes well. (In my application, I change the position as well as the opacity.)
However, if I use shift to update the array, the DOM is updated immediately without a jump.
Here's a demonstration of one approach where everything works as expected, except for transitions. Compare the behavior when using two buttons.
$scope.items.push( $scope.items.shift() );
Here is another demonstration of an alternative approach where transitions work, but the array loses an element each time the function runs.
$scope.items.shift( $scope.items.push() );
The idea is that the user can cycle through the elements in the array infinitely cyclically, and CSS transitions occur in both directions. The problem seems to be that AngularJS updates the DOM in one case, but not in the other, although I could not demonstrate this in my testing.
Also, based on some reading, I tried to use track by item.id avail. Many thanks.
javascript arrays angularjs css-transitions angularjs-ng-repeat ng-repeat
isherwood
source share