To address this issue, I devised a solution that involves manually checking the top position of an element's bounding box in the `ngAfterViewInit` lifecycle hook. The approach entails removing elements iteratively until the top values of both the first and last elements are aligned.
ngAfterViewInit() {
this.hidden = 0;
let children: Element[] = this.elementRef.nativeElement.getElementsByClassName('wrapper')[0].children;
let topOfFirst = children[0].getBoundingClientRect().top;
let topOfLast;
for (let i = children.length - 2; i > 0; i--) {
topOfLast = children[children.length - 1].getBoundingClientRect().top;
if (topOfLast > topOfFirst) {
children[i].remove();
this.hidden++;
}
}
// Remove counter if hidden count is 0
if (this.hidden === 0) {
topOfLast = children[children.length - 1].remove();
}
}
https://i.sstatic.net/MIbpx.png