This commit is contained in:
Taric Xin
2022-03-23 11:06:24 +08:00
parent d2c350f6d1
commit 8d31f21547
3 changed files with 47 additions and 30 deletions

View File

@ -0,0 +1,40 @@
import { AfterViewInit, Component, OnInit } from '@angular/core';
import { fromEvent } from 'rxjs';
import { debounceTime } from 'rxjs/operators';
@Component({
template: ''
})
export class BasicTableComponent implements AfterViewInit {
scrollY = '400px';
constructor() {}
ngAfterViewInit(): void {
setTimeout(() => {
this.getScrollY();
}, 100);
fromEvent(window, 'resize')
.pipe(debounceTime(100))
.subscribe(event => {
this.getScrollY();
});
}
getScrollY() {
const windowHeight = window.innerHeight || Math.max(document.documentElement.clientHeight, document.body.clientHeight);
const header = document.getElementsByTagName('layout-pro-header')?.[0];
if (windowHeight && header) {
let scrollY = windowHeight - header.clientHeight - 35 - 49;
const headerWrapper = document.getElementsByTagName('page-header-wrapper')?.[0];
if (headerWrapper) {
scrollY -= headerWrapper.clientHeight;
}
const tabset = document.getElementsByTagName('nz-tabset')?.[0];
if (tabset) {
scrollY -= tabset.clientHeight;
}
this.scrollY = scrollY + 'px';
}
}
}