Skip to content

Instantly share code, notes, and snippets.

@Giannisduke
Forked from djrmom/custom-hooks.php
Created September 26, 2020 14:59
Show Gist options
  • Save Giannisduke/aee07f3f3fb692897454ca5b759dbf44 to your computer and use it in GitHub Desktop.
Save Giannisduke/aee07f3f3fb692897454ca5b759dbf44 to your computer and use it in GitHub Desktop.
facetwp loading animation to cover all facets
<?php
/** sample of css and js to create a custom loading animation to cover the full facet area
** change #facet-container to a id or class of container element for your facets
** update css as needed
** please see https://facetwp.com/documentation/support/ for questions
**/
add_action( 'wp_head', function() { ?>
<style>
#facet-container {
position: relative;
}
.custom-loader {
position: absolute;
background-image: url("/path/to/image");
background-position: center;
background-repeat: no-repeat;
}
</style>
<?php });
add_action( 'wp_head', function() {
?>
<script>
(function($) {
$(document).on('facetwp-refresh', function() {
if (FWP.loaded) {
$('#facet-container').prepend('<div class="custom-loader facetwp-loading"></div>');
$('.custom-loader').height( $('#facet-container').height() ).width( $('#facet-container').width() );
}
});
$(document).on('facetwp-loaded', function() {
$('.custom-loader').remove();
});
})(jQuery);
</script>
<?php
},100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment