Use the directive
<ul class="list">
<li class="list-item inactive"
inViewport
[inViewportOptions]="{ threshold: [0] }"
(inViewportAction)="onIntersection($event)"
*ngFor="let item of items;">
<span>{{item}}</span>
</li>
</ul>ul.list {
margin: 0;
padding: 24px;
display: block;
list-style: none;
> li.list-item {
width: 100%;
height: 25vh;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
transition: background-color .25s ease-in-out, color .25s ease-in-out;
&:not(:first-child) {
margin-top: 12px;
}
&.inactive {
background-color: #CCCCCC;
color: rgba(#000000, .85);
}
&.active {
background-color: #00C853;
color: rgba(#FFFFFF, .85);
}
> span {
font-weight: 700;
}
}
}Last updated