AngularJS ngRepeat 中的动画 ng-move 动画是错误的项目 [英] Animating ng-move in AngularJS ngRepeat is animating the wrong items
问题描述
在 ng-repeat 中为 ng-move 设置动画时,我有点不知所措.例如,如果我将一个数组项从 3 移到 7,则项 4-7 会向上移动并生成动画.然而,我从 3 移动并放置在位置 7 的实际项目没有.这是一个 plunkr 演示我的问题.
I'm a little flummoxed when it comes to animating ng-move in an ng-repeat. If I move an array item from 3 to 7 for instance, items 4-7 get shifted up and they animate. However the actual item I moved from 3 and placed in position 7, does not. Here's a plunkr demonstrating my issue.
http://plnkr.co/edit/4yRkLWbsU57YxrYOrWUQ?p=preview
然而,将第 7 项移动到第 3 项的效果如我所料,为单个移动的项目设置动画,而不是为被推下的项目设置动画.
Moving item 7 to 3, however, works as I expect, animating the single moved item, and not the items that have been pushed down.
这对于向用户展示移动的内容不是很有用.应该如何正确地为 ng-move 设置动画?
This is not very useful for showing a user what moved. How should someone properly animate an ng-move?
推荐答案
@tasseKat 有一个很好的答案,它解释了您观察到的行为:https://stackoverflow.com/a/27616435/1652643
@tasseKat has an excellent answer, which explains the behavior you observed: https://stackoverflow.com/a/27616435/1652643
然而,他的解决方案并不像您希望的那么简单......但到目前为止我还没有找到更好的方法.
However, his solution is not as simple as you would wish... but so far I haven't found anything better.
这篇关于AngularJS ngRepeat 中的动画 ng-move 动画是错误的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!