Skip to content

Commit

Permalink
Only 9 cards are visible at a time
Browse files Browse the repository at this point in the history
  • Loading branch information
bhushan354 committed Oct 7, 2024
1 parent f8e8f52 commit 756c44d
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions _includes/view-all.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,26 @@


document.addEventListener("DOMContentLoaded", () => {

prevButton.style.display = "none";
showCards(count);
updateButtonVisibility();
simulateClick();
});

function showCards(coun) {
cards.forEach((card) => {
card.style.display = "none";
});
for (let i = coun; i < coun + 9 && coun + 9 <= maxCount; i++) {
for (let i = coun; i < coun + 9 && i < maxCount; i++) {
cards[i].style.display = "block";
}

}

function updateButtonVisibility() {
prevButton.style.display = count <= 0 ? "none" : "block";
nextButton.style.display = count + 9 >= maxCount ? "none" : "block";
}
prevButton.style.display = count <= 0 ? "none" : "block";
nextButton.style.display = count + 9 >= maxCount ? "none" : "block";
}

prevButton.addEventListener("click", () => {

if (count > 0) {
Expand All @@ -58,4 +60,16 @@
}
updateButtonVisibility();
});

function simulateClick() {
if (count > 0 && count < maxCount) {
if (count % 9 === 0) {
nextButton.click();
} else {
prevButton.click();
}
}
}

window.onload = simulateClick;
</script>

0 comments on commit 756c44d

Please sign in to comment.