In my design, I have a page where scroll bars are not allowed, meaning all content must be visible at once. The image below shows the basic layout of the screen to give you an idea.
The layout consists of two blocks - Block 1 and Block 2. Block 1 is expandable and may not always exist based on the content. It has a max-height of 500px and is only supported on iPads and computers, not mobile devices. Block 2, however, remains on the screen at all times.
My question is: How can I dynamically resize Block 2 based on the offsetTop?
I have attempted to use @ViewChild()
, but it does not consistently detect changes, causing the content to extend beyond the viewable area.
This is the method I have tried:
@ViewChild('block2') set offset(content: ElementRef) {
content.nativeElement.style.maxHeight = `calc(100vh - ${this.offsetTop + 20}px)`;
}
Regrettably, I am unable to share the source code, but any suggestions would be greatly appreciated.
Block 2 needs to constantly monitor changes in offsetTop and adjust its size to fill the remaining space on the page.