0

I'm trying to slide up/down a table row when toggling ng-show. I'm using AngularJS v1.3.0-rc.5 and have included ngAnimation module in my app but it always toggles, doesn't animate. Am I doing something wrong?

The HTML code is the following:

<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>

The JavaScript for the toggling is pretty basic and is the following:

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

The CSS animation code is the following:

.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;
}
Gaui
  • 8,723
  • 16
  • 64
  • 91

1 Answers1

1

try this:

<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>

Here's a working (example) plnkr

Nitsan Baleli
  • 5,393
  • 3
  • 30
  • 52
  • Thank you. It now animates, but the `colspan="5"` doesn't do anything because of the `display: block` so it doesn't display smooth. You can see this [plnkr](http://plnkr.co/edit/gBFEjd5ICiWYESzdG03G?p=preview) here. – Gaui Oct 12 '14 at 21:59
  • Thank you for the update, but can I be able to make only the rows appear, without moving the columns to the right? – Gaui Oct 13 '14 at 22:19
  • @Gaui still no luck, Im trying to figure it out. – Nitsan Baleli Oct 14 '14 at 07:11