Skip to content

Commit e64d56e

Browse files
committed
Revert "fix: lazy loading not working without mouse action"
This reverts commit 050d1f5.
1 parent 3ae4d5e commit e64d56e

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

js/render-facade.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -129,21 +129,19 @@ window['vizClipboard2'] = window['vizClipboard2'] || null;
129129
}
130130

131131
function displayChartsOnFrontEnd() {
132-
function renderVisibleLazyCharts( checkViewport ) {
132+
function renderVisibleLazyCharts() {
133133
$('div.visualizer-front:not(.viz-facade-loaded):not(.visualizer-lazy):not(.visualizer-cw-error):empty').each(function(index, element){
134134
// Do not render charts that are intentionally hidden.
135135
const style = window.getComputedStyle(element);
136136
if (style.display === 'none' || style.visibility === 'hidden') {
137137
return;
138138
}
139139

140-
// On scroll, only render charts that are currently within the viewport.
141-
if ( checkViewport ) {
142-
const rect = element.getBoundingClientRect();
143-
const inViewport = rect.bottom >= 0 && rect.top <= (window.innerHeight || document.documentElement.clientHeight);
144-
if (!inViewport) {
145-
return;
146-
}
140+
// Only render charts that are currently within the viewport.
141+
const rect = element.getBoundingClientRect();
142+
const inViewport = rect.bottom >= 0 && rect.top <= (window.innerHeight || document.documentElement.clientHeight);
143+
if (!inViewport) {
144+
return;
147145
}
148146

149147
const id = $(element).addClass('viz-facade-loaded').attr('id');
@@ -154,12 +152,10 @@ window['vizClipboard2'] = window['vizClipboard2'] || null;
154152
});
155153
}
156154

157-
$(window).on('scroll', function() { renderVisibleLazyCharts( true ); });
155+
$(window).on('scroll', renderVisibleLazyCharts);
158156

159-
// Run once on page load to render all non-lazy charts regardless of viewport position.
160-
// Skipping the viewport check here avoids missing charts when the browser window is
161-
// not in focus (e.g. mouse outside the window) and layout may not be fully computed.
162-
renderVisibleLazyCharts( false );
157+
// Run once on page load to render any lazy charts already in the viewport.
158+
renderVisibleLazyCharts();
163159

164160
$('div.visualizer-front-container:not(.visualizer-lazy-render)').each(function(index, element){
165161
// Do not render charts that are intentionally hidden.

0 commit comments

Comments
 (0)