fix logic infinity

This commit is contained in:
Profile Profile
2026-03-13 19:32:50 +03:00
parent 48db849ba3
commit d3b8a0bb63
4 changed files with 758 additions and 1114 deletions

View File

@@ -204,6 +204,7 @@ function shouldBeLarge(index: number, columns: number): boolean {
private endCursor: string | null = null;
private currentIndex: number;
private gridColumns: 3 | 4 = 4;
private loadMoreConfig: any;
// Константы для разных сеток
private readonly CYCLE_LENGTH = {
@@ -228,6 +229,12 @@ function shouldBeLarge(index: number, columns: number): boolean {
this.endCursor = this.sentinel.dataset.endCursor || null;
this.currentIndex = parseInt(this.sentinel.dataset.currentIndex || '0');
this.gridColumns = parseInt(this.sentinel.dataset.gridColumns || '4') as 3 | 4;
try {
this.loadMoreConfig = JSON.parse(this.sentinel.dataset.loadConfig || '{}');
} catch {
this.loadMoreConfig = { type: 'latest', slug: '', gridColumns: this.gridColumns };
}
this.init();
}
@@ -398,4 +405,9 @@ function shouldBeLarge(index: number, columns: number): boolean {
}, 200);
}
}
// Очистка при навигации Astro
document.addEventListener('astro:before-swap', () => {
// Здесь можно добавить логику очистки если нужно
});
</script>