ayjays132 commited on
Commit
3c91b2d
1 Parent(s): 4e4c5c3

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +30 -8
README.md CHANGED
@@ -538,6 +538,8 @@ body {
538
 
539
  <script>
540
  let currentIndex = 0;
 
 
541
 
542
  function showSlide(index) {
543
  const slides = document.querySelectorAll('.carousel-item');
@@ -561,6 +563,34 @@ function prevSlide() {
561
  showSlide(currentIndex - 1);
562
  }
563
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
564
  let slideIndex = 1;
565
  showSlides(slideIndex);
566
 
@@ -587,12 +617,4 @@ function showSlides(n) {
587
  slides[slideIndex-1].style.display = "block";
588
  dots[slideIndex-1].className += " active";
589
  }
590
-
591
- function updateDots() {
592
- const dots = document.getElementsByClassName("dot");
593
- for (let i = 0; i < dots.length; i++) {
594
- dots[i].className = dots[i].className.replace(" active", "");
595
- }
596
- dots[currentIndex].className += " active";
597
- }
598
  </script>
 
538
 
539
  <script>
540
  let currentIndex = 0;
541
+ let startX = 0;
542
+ let endX = 0;
543
 
544
  function showSlide(index) {
545
  const slides = document.querySelectorAll('.carousel-item');
 
563
  showSlide(currentIndex - 1);
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 handleTouchStart(event) {
575
+ startX = event.touches[0].clientX;
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
 
 
617
  slides[slideIndex-1].style.display = "block";
618
  dots[slideIndex-1].className += " active";
619
  }
 
 
 
 
 
 
 
 
620
  </script>