mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-05-01 11:52:25 +08:00
24 lines
1,014 B
Text
24 lines
1,014 B
Text
add_action('wp_footer', 'add_faceet_wp_infinite_scroll');
|
|
function add_faceet_wp_infinite_scroll() {
|
|
if (is_admin() || is_checkout()) {
|
|
return;
|
|
}
|
|
?>
|
|
<script>
|
|
|
|
jQuery(document).ready(function($){
|
|
var intBottomMargin = 1500; //Pixels from bottom when script should trigger
|
|
setInterval(() => {
|
|
if (($(window).scrollTop() >= $(document).height() - $(window).height() - intBottomMargin)
|
|
&& (!$(".facetwp-load-more").hasClass("loading"))
|
|
&& (!$(".facetwp-load-more").hasClass("facetwp-hidden"))
|
|
) {
|
|
$(".facetwp-load-more").addClass('loading');
|
|
$(".facetwp-load-more").click(); //trigger click
|
|
// the class is automatically removed, as the button is recreated, as soon as it loaded the products
|
|
}
|
|
}, 1000);
|
|
});
|
|
</script>
|
|
<?php
|
|
}
|