I have a div that is inside a list group that I am trying to have slide in/out based on the state of a toggle switch. The problem is, when the animation occurs, it goes in front of the div that I would expect it to be going behind for the appearance to be correct.
This is for Angular and Bootstrap 4. I have followed a tutorial on how to get started with Angular Animations and also tried to add styling to both the list group and the div (as well as in the controller) to adjust the z-index based on a few google searches that I completed.
The div that is animated is below.
<div class="list-group" style="z-index: 9">
<div class="list-group-item">
<!-- toggle switch is right here --->
<div class="recurringSchedule border-top py-2" *ngIf="expense.recurring" [@slideInOut]>
...
</div>
</div>
</div>
The animation is defined within my controller like so.
@Component({
selector: 'app-create',
templateUrl: './create.component.html',
styleUrls: ['./create.component.css'],
animations: [
trigger('slideInOut', [
transition(':enter', [
style({transform: 'translateY(-100%)', zIndex: '-5'}),
animate('400ms ease-in', style({transform: 'translateY(0%)'}))
]),
transition(':leave', [
style({zIndex: '-5'}),
animate('400ms ease-in', style({transform: 'translateY(-100%)'}))
])
])
]
})
I expect the recurringSchedule
div to slide down and up based on the toggle switch state respectively behind the list group or list group item. But it slides up/down in front of the list group so you see the entire animation instead of part of it being hidden.
UPDATE
Per the request in the comments, I created a stackblitz that demonstrates the issue.