facetwp conditional scroll to top only on pager

djrmom

{{gist file=”custom-hooks.php” lang=”php”}}
<?php

/** scoll on loaded only if pager is the change in facet **/
add_action( ‘wp_head’, function() { ?>

<script>
(function($) {
$(document).on(‘facetwp-refresh’, function() {
if ( FWP.soft_refresh == true ) {
FWP.enable_scroll = true;
} else {
FWP.enable_scroll = false;
}
});
$(document).on(‘facetwp-loaded’, function() {
if ( FWP.enable_scroll == true ) {
$(‘html, body’).animate({ scrollTop: 0 }, 500);
}
});
})(jQuery);
</script>

<?php } );
{{/gist}}