Skip to content

Commit

Permalink
KAD-4209 Init progress bars on query loop filter
Browse files Browse the repository at this point in the history
  • Loading branch information
oakesjosh committed Mar 3, 2025
1 parent 7d5e94a commit a98977c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion includes/assets/js/kb-progress-bars.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public function build_html( $attributes, $unique_id, $content, $block_instance )
! empty( $attributes['progressWidthMobile'] ) ? $attributes['progressWidthMobile'] : ( ! empty( $attributes['progressWidthTablet'] ) ? $attributes['progressWidthTablet'] : ( ! empty( $attributes['progressWidth'] ) ? $attributes['progressWidth'] : 2 ) ),
];

$content = '<div class="kb-progress-bar-container kb-progress-bar-container' . $unique_id . ' kb-progress-bar-type-' . $attributes['barType'] . ' ' . ( ! empty( $attributes['align'] ) ? 'align' . $attributes['align'] : '' ) . '">';
$content = '<div class="kb-progress-bar-container kb-progress-bar-container' . $unique_id . ' kb-progress-bar-init kb-progress-bar-type-' . $attributes['barType'] . ' ' . ( ! empty( $attributes['align'] ) ? 'align' . $attributes['align'] : '' ) . '">';

$content .= $this->get_label( $attributes, 'above' );

Expand Down
7 changes: 6 additions & 1 deletion src/assets/js/kb-progress-bars.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,12 @@
} else {
kadenceProgressBars.triggerAnimation(element, index, item);
}
// Remove the init class after initialization
element.classList.remove('kb-progress-bar-init');
},
initSingleBar(item) {
const barContainers = document.querySelectorAll('.kb-progress-bar-container' + item.unique_id);
// Only select containers that have the init class
const barContainers = document.querySelectorAll('.kb-progress-bar-container' + item.unique_id + '.kb-progress-bar-init');
if (!barContainers?.length) {
return;
}
Expand Down Expand Up @@ -190,5 +193,7 @@
// The DOM has already been loaded.
kadenceProgressBars.init();
}
// Add event listener for kb-query-loaded event
document.addEventListener('kb-query-loaded', kadenceProgressBars.init);
window.addEventListener('resize', kadenceProgressBars.windowResize, false);
})();

0 comments on commit a98977c

Please sign in to comment.