fix(scripts): avoid redundant visibility settings in loop

Refactored section visibility handling to prevent unnecessary CSS updates by ensuring that only sections after the first matched section are hidden. This improves performance and prevents potential flickering issues.
This commit is contained in:
Kumi 2024-09-23 09:22:41 +02:00
parent 0b5c85273d
commit 1abae9bd7a
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -213,10 +213,15 @@
}); });
var sections = $('.section'); var sections = $('.section');
var found = false;
sections.each(function (index) { sections.each(function (index) {
if ($(this).find('script[data-activity-id]').length > 0) { if (!found && $(this).find('script[data-activity-id]').length > 0) {
// Hide all .section elements after this one // Set found to true when the first matching section is found
sections.slice(index + 1).css('visibility', 'hidden'); found = true;
} else if (found) {
// Hide all .section elements after the found one
$(this).css('visibility', 'hidden');
} }
}); });
}) })