web: fix ModalForm loading data even when not in viewport

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer
2021-06-05 20:45:20 +02:00
parent ba3e0a0586
commit d38f944435
2 changed files with 23 additions and 6 deletions

View File

@ -45,6 +45,11 @@ export class Form<T> extends LitElement {
`];
}
get isInViewport(): boolean {
const rect = this.getBoundingClientRect();
return !(rect.x + rect.y + rect.width + rect.height === 0);
}
getSuccessMessage(): string {
return this.successMessage;
}
@ -214,8 +219,7 @@ export class Form<T> extends LitElement {
}
render(): TemplateResult {
const rect = this.getBoundingClientRect();
if (rect.x + rect.y + rect.width + rect.height === 0) {
if (!this.isInViewport) {
return html``;
}
return this.renderVisible();