facetwp fade out/in with pre-load

djrmom

{{gist file=”custom-hooks.php” lang=”php”}}
<?php
/**
** update of https://facetwp.com/fade-template-content-during-refresh/ to only fade in on pre-load
**/

add_action( ‘wp_footer’, function() { ?>
<style>
.facetwp-template {
opacity: 0;
}
</style>
<script>
(function($) {
$(document).on(‘facetwp-refresh’, function() {
if ( FWP.loaded ) {
$(‘.facetwp-template’).animate({opacity: 0}, 1000);
}
});
$(document).on(‘facetwp-loaded’, function() {
$(‘.facetwp-template’).animate({ opacity: 1 }, 1000);
});
})(jQuery);
</script>
<?php });
{{/gist}}