Update README.md
Browse files
README.md
CHANGED
|
@@ -541,122 +541,64 @@ let currentIndex = 0;
|
|
| 541 |
let startX = 0;
|
| 542 |
let endX = 0;
|
| 543 |
|
| 544 |
-
function
|
| 545 |
const slides = document.querySelectorAll('.carousel-item');
|
| 546 |
-
|
| 547 |
-
|
| 548 |
-
|
| 549 |
-
|
| 550 |
-
|
| 551 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 552 |
}
|
| 553 |
-
const offset = -currentIndex * 100;
|
| 554 |
-
document.querySelector('.carousel-inner').style.transform = `translateX(${offset}%)`;
|
| 555 |
-
updateDots();
|
| 556 |
-
}
|
| 557 |
-
|
| 558 |
-
function nextSlide() {
|
| 559 |
-
showSlide(currentIndex + 1);
|
| 560 |
-
}
|
| 561 |
|
| 562 |
-
function
|
| 563 |
-
|
| 564 |
-
}
|
| 565 |
-
|
| 566 |
-
function updateDots() {
|
| 567 |
-
const dots = document.getElementsByClassName("dot");
|
| 568 |
-
for (let i = 0; i < dots.length; i++) {
|
| 569 |
-
dots[i].className = dots[i].className.replace(" active", "");
|
| 570 |
}
|
| 571 |
-
dots[currentIndex].className += " active";
|
| 572 |
-
}
|
| 573 |
|
| 574 |
-
function
|
| 575 |
-
|
| 576 |
-
}
|
| 577 |
-
|
| 578 |
-
function handleTouchMove(event) {
|
| 579 |
-
endX = event.touches[0].clientX;
|
| 580 |
-
}
|
| 581 |
-
|
| 582 |
-
function handleTouchEnd() {
|
| 583 |
-
if (startX > endX + 50) {
|
| 584 |
-
nextSlide();
|
| 585 |
-
} else if (startX < endX - 50) {
|
| 586 |
-
prevSlide();
|
| 587 |
}
|
| 588 |
-
}
|
| 589 |
-
|
| 590 |
-
document.querySelector('.carousel-inner').addEventListener('touchstart', handleTouchStart, false);
|
| 591 |
-
document.querySelector('.carousel-inner').addEventListener('touchmove', handleTouchMove, false);
|
| 592 |
-
document.querySelector('.carousel-inner').addEventListener('touchend', handleTouchEnd, false);
|
| 593 |
-
|
| 594 |
-
let slideIndex = 1;
|
| 595 |
-
showSlides(slideIndex);
|
| 596 |
-
|
| 597 |
-
function plusSlides(n) {
|
| 598 |
-
showSlides(slideIndex += n);
|
| 599 |
-
}
|
| 600 |
-
|
| 601 |
-
function currentSlide(n) {
|
| 602 |
-
showSlides(slideIndex = n);
|
| 603 |
-
}
|
| 604 |
|
| 605 |
-
function
|
| 606 |
-
|
| 607 |
-
|
| 608 |
-
|
| 609 |
-
if (n > slides.length) {slideIndex = 1}
|
| 610 |
-
if (n < 1) {slideIndex = slides.length}
|
| 611 |
-
for (i = 0; i < slides.length; i++) {
|
| 612 |
-
slides[i].style.display = "none";
|
| 613 |
-
}
|
| 614 |
-
for (i = 0; i < dots.length; i++) {
|
| 615 |
-
dots[i].className = dots[i].className.replace(" active", "");
|
| 616 |
}
|
| 617 |
-
slides[slideIndex-1].style.display = "block";
|
| 618 |
-
dots[slideIndex-1].className += " active";
|
| 619 |
-
}
|
| 620 |
-
|
| 621 |
-
document.addEventListener("DOMContentLoaded", function() {
|
| 622 |
-
let currentSlide = 0;
|
| 623 |
-
const slides = document.querySelectorAll(".carousel-item");
|
| 624 |
-
const totalSlides = slides.length;
|
| 625 |
|
| 626 |
-
|
| 627 |
-
|
| 628 |
-
}
|
| 629 |
|
| 630 |
-
|
| 631 |
-
|
| 632 |
-
}
|
| 633 |
|
| 634 |
-
function
|
| 635 |
-
|
| 636 |
-
|
| 637 |
-
|
|
|
|
|
|
|
| 638 |
}
|
| 639 |
|
| 640 |
-
|
| 641 |
-
|
|
|
|
| 642 |
|
| 643 |
-
// Dot navigation
|
| 644 |
-
const dots = document.querySelectorAll(".dot");
|
| 645 |
dots.forEach((dot, index) => {
|
| 646 |
dot.addEventListener("click", () => {
|
| 647 |
-
|
| 648 |
-
currentSlide = index;
|
| 649 |
-
slides[currentSlide].classList.add("active");
|
| 650 |
-
updateDots();
|
| 651 |
});
|
| 652 |
});
|
| 653 |
|
| 654 |
-
|
| 655 |
-
dots.forEach(dot => dot.classList.remove("active"));
|
| 656 |
-
dots[currentSlide].classList.add("active");
|
| 657 |
-
}
|
| 658 |
-
|
| 659 |
-
// Initialize first dot as active
|
| 660 |
-
dots[currentSlide].classList.add("active");
|
| 661 |
});
|
| 662 |
</script>
|
|
|
|
| 541 |
let startX = 0;
|
| 542 |
let endX = 0;
|
| 543 |
|
| 544 |
+
document.addEventListener("DOMContentLoaded", function() {
|
| 545 |
const slides = document.querySelectorAll('.carousel-item');
|
| 546 |
+
const dots = document.querySelectorAll('.dot');
|
| 547 |
+
|
| 548 |
+
function showSlide(index) {
|
| 549 |
+
if (index >= slides.length) {
|
| 550 |
+
currentIndex = 0;
|
| 551 |
+
} else if (index < 0) {
|
| 552 |
+
currentIndex = slides.length - 1;
|
| 553 |
+
} else {
|
| 554 |
+
currentIndex = index;
|
| 555 |
+
}
|
| 556 |
+
slides.forEach((slide, i) => {
|
| 557 |
+
slide.classList.toggle('active', i === currentIndex);
|
| 558 |
+
});
|
| 559 |
+
updateDots();
|
| 560 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 561 |
|
| 562 |
+
function nextSlide() {
|
| 563 |
+
showSlide(currentIndex + 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 564 |
}
|
|
|
|
|
|
|
| 565 |
|
| 566 |
+
function prevSlide() {
|
| 567 |
+
showSlide(currentIndex - 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 568 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 569 |
|
| 570 |
+
function updateDots() {
|
| 571 |
+
dots.forEach((dot, i) => {
|
| 572 |
+
dot.classList.toggle('active', i === currentIndex);
|
| 573 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 574 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 575 |
|
| 576 |
+
function handleTouchStart(event) {
|
| 577 |
+
startX = event.touches[0].clientX;
|
| 578 |
+
}
|
| 579 |
|
| 580 |
+
function handleTouchMove(event) {
|
| 581 |
+
endX = event.touches[0].clientX;
|
| 582 |
+
}
|
| 583 |
|
| 584 |
+
function handleTouchEnd() {
|
| 585 |
+
if (startX > endX + 50) {
|
| 586 |
+
nextSlide();
|
| 587 |
+
} else if (startX < endX - 50) {
|
| 588 |
+
prevSlide();
|
| 589 |
+
}
|
| 590 |
}
|
| 591 |
|
| 592 |
+
document.querySelector('.carousel-inner').addEventListener('touchstart', handleTouchStart, false);
|
| 593 |
+
document.querySelector('.carousel-inner').addEventListener('touchmove', handleTouchMove, false);
|
| 594 |
+
document.querySelector('.carousel-inner').addEventListener('touchend', handleTouchEnd, false);
|
| 595 |
|
|
|
|
|
|
|
| 596 |
dots.forEach((dot, index) => {
|
| 597 |
dot.addEventListener("click", () => {
|
| 598 |
+
showSlide(index);
|
|
|
|
|
|
|
|
|
|
| 599 |
});
|
| 600 |
});
|
| 601 |
|
| 602 |
+
showSlide(currentIndex);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 603 |
});
|
| 604 |
</script>
|