add next page frontpage

This commit is contained in:
2024-08-13 18:34:49 +03:00
parent 85c2625635
commit 92e1eef21e
3 changed files with 35 additions and 12 deletions

View File

@@ -17,6 +17,7 @@
$query = new WP_Query($args);
?>
<?php get_template_part('partials/post-list', null, ['large_first_image' => false, 'query' => $query]); ?>
<div class="frontpage-next"><a href="https://agroexpert.press/category/all-events/page/2/">Еще новости</a></div>
</div>
</div>
<?php get_footer(); ?>

View File

@@ -88,6 +88,32 @@
flex-direction: column;
}
.frontpage-next{
padding: 1.8rem 0 1.7rem;
grid-column: span 2;
width: 100%;
text-align: center;
border-top: 0.1rem solid var(--gray);
margin-top: -1px;
font-family: 'Raleway', sans-serif;
font-weight: bold;
transition: 0.3s;
font-size: 1.4em;
display: flex;
justify-content: center;
}
.frontpage-next a{
color: var(--secondary);
}
.frontpage-next a:hover{
color: var(--primary);
}
.articles-preview__show-next {
padding: 1.8rem 0 1.7rem;
grid-column: span 2;
@@ -96,13 +122,14 @@
border-top: 0.1rem solid var(--gray);
margin-top: -1px;
font-family: 'Raleway', sans-serif;
transition: 0.3s;
font-size: 1.3rem;
font-size: 1.4em;
display: flex;
justify-content: center;
}
.articles-preview__show-next:hover {
color: var(--primary);
}

View File

@@ -2,7 +2,6 @@ jQuery(function($) {
var loading = false;
var loadCount = 0;
var maxLoads = 5;
var mobileThreshold = 768; // Ширина экрана, считаемая мобильной
function loadMorePosts() {
if (loading || loadCount >= maxLoads) return;
@@ -14,11 +13,6 @@ jQuery(function($) {
// Условие для определения, что мы достигли конца страницы
var scrollTrigger = (scrollTop + windowHeight >= documentHeight - 200);
// Дополнительное условие для мобильных устройств
if ($(window).width() < mobileThreshold) {
scrollTrigger = (scrollTop + windowHeight >= documentHeight - 100); // Изменяем порог для мобильных
}
if (scrollTrigger) {
loading = true;
@@ -48,13 +42,13 @@ jQuery(function($) {
ym(96621494, 'hit', location.pathname + '?page=' + my_load_more_params.current_page, {title: titlePage, referer: location.pathname});
if (my_load_more_params.current_page == my_load_more_params.max_page || loadCount >= maxLoads) {
$(window).off('scroll', loadMorePosts);
$(window).off('scroll touchmove', loadMorePosts);
$('.articles-preview__show-next').remove();
} else {
loading = false;
}
} else {
$(window).off('scroll', loadMorePosts);
$(window).off('scroll touchmove', loadMorePosts);
$('.articles-preview__show-next').remove();
}
}
@@ -62,5 +56,6 @@ jQuery(function($) {
}
}
$(window).on('scroll', loadMorePosts);
$(window).on('scroll touchmove', loadMorePosts);
});