Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions public/css/module.less
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ always collapsed and we use the min-height to show a single chart.
min-height: 275px;
}

.perfdatagraphs-line-chart {
content-visibility: auto;
}

/*
These elements are used to retrive colors in the JavaScript part of the module
*/
Expand Down
23 changes: 23 additions & 0 deletions public/js/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,25 @@
}
});

// We register a IntersectionObserver so that we can
// do some lazy-loading.
this.intersectionObserver = new IntersectionObserver(entries => {
for (let elem of entries) {
const plot = this.plots.get(elem.target);
if (plot === undefined) {
continue;
}
// When the element not onscreen, we hide it and tell the resizeObserver to unobserve
if (elem.isIntersecting) {
elem.target.style.visibility = "visible";
this.resizeObserver.observe(elem.target);
} else {
elem.target.style.visibility = "hidden";
this.resizeObserver.unobserve(elem.target);
}
}
});

// TODO: The 'rendered' selectors might not yet be optimal.
this.on('rendered', '#main > .icinga-module, #main > .container', this.rendered, this);
}
Expand Down Expand Up @@ -245,6 +264,10 @@
// resize the chart when its container changes
this.resizeObserver.observe(elem);

// Add each element to the intersect observer so that we can
// load/unload elements
this.intersectionObserver.observe(elem);

// Reset the existing canvas elements for the new rendering
elem.replaceChildren();

Expand Down