gpt4 book ai didi

javascript - 在表格行上动画 ng-show

转载 作者:太空宇宙 更新时间:2023-11-04 12:48:31 24 4
gpt4 key购买 nike

当切换 ng-show 时,我试图向上/向下滑动表格行。我正在使用 AngularJS v1.3.0-rc.5 并在我的应用程序中包含 ngAnimation 模块,但它总是切换,没有动画。我做错了什么吗?

HTML代码如下:

<tbody>
<tr data-ng-repeat-start="employee in stafflist" ng-init="isToggled[$index]">
<td><a href="#" data-ng-click="toggleEmployee($index)">{{employee.FULLNAME}}</a></td>
<td>{{employee.WORKPHONE}}</td>
<td>{{employee.OFFICE}}</td>
<td>{{employee.DEPARTMENT}}</td>
<td>{{employee.COUNTRY}}</td>
</tr>
<tr data-ng-repeat-end data-ng-show="isToggled[$index]" class="animate-show">
<td colspan="5">
<div class="employeeInfo">
<img ng-src="EmployeeImage.aspx?p={{employee.PHOTOURL}}" />
Employee info
</div>
</td>
</tr>
</tbody>

用于切换的 JavaScript 非常基本,如下所示:

$scope.isToggled = [];
$scope.toggleEmployee = function (id) {
$scope.isToggled[id] = !$scope.isToggled[id];
};

CSS动画代码如下:

.animate-show {
line-height:40px;
list-style:none;
box-sizing:border-box;
}

.animate-show.ng-move,
.animate-show.ng-enter,
.animate-show.ng-leave {
-webkit-transition:all linear 0.5s;
transition:all linear 0.5s;
}

.animate-show.ng-leave.ng-leave-active,
.animate-show.ng-move,
.animate-show.ng-enter {
opacity:0;
max-height:0;
}

.animate-show.ng-leave,
.animate-show.ng-move.ng-move-active,
.animate-show.ng-enter.ng-enter-active {
opacity:1;
max-height:40px;
}

最佳答案

试试这个:

<tr data-ng-repeat-end ng-animate-children>
<td colspan="5" data-ng-show="isToggled[$index]" class="animate-show">
<div class="employeeInfo">
<img ng-src="EmployeeImage.aspx?p={{employee.PHOTOURL}}" />
Employee info
</div>
</td>
</tr>

这是一个有效的(示例) plnkr

关于javascript - 在表格行上动画 ng-show,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26314528/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com