<?php
/** scrolls to top on facet interaction
** except for load more pager
**/
add_action('facetwp_scripts', function () {
?>
<script>
(function($) {
$(document).on('facetwp-loaded', function() {
if (FWP.loaded && FWP.load_more_paged < 2) { // Run only after the initial page load
$('html, body').animate({
scrollTop: $('.facetwp-template').offset().top // Scroll to the top of the element with class "facetp-template"
}, 500);
}
});
})(jQuery);
</script>
<?php });