Skip to content

Instantly share code, notes, and snippets.

@djrmom
Last active September 26, 2020 14:59
Show Gist options
  • Save djrmom/1a3ce3d77f41a0aa50b8f0f6746680c2 to your computer and use it in GitHub Desktop.
Save djrmom/1a3ce3d77f41a0aa50b8f0f6746680c2 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);
@djrmom
Copy link
Author

djrmom commented Mar 24, 2020

Hi,

Please see https://facetwp.com/documentation/support/ for questions on this snippet.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment