protae5544 commited on
Commit
400c7c9
·
verified ·
1 Parent(s): 098aff7

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +75 -4
index.html CHANGED
@@ -360,6 +360,18 @@
360
  background: linear-gradient(135deg, var(--success), #5af78e);
361
  box-shadow: 0 10px 25px rgba(46, 213, 115, 0.4);
362
  }
 
 
 
 
 
 
 
 
 
 
 
 
363
 
364
  .carousel-container {
365
  perspective: 1200px;
@@ -877,6 +889,38 @@ function solution() {
877
 
878
  // Event listeners setup
879
  function setupEventListeners() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
880
  // Mode toggle
881
  document.getElementById('carouselModeBtn').addEventListener('click', () => switchMode('carousel'));
882
  document.getElementById('chatModeBtn').addEventListener('click', () => switchMode('chat'));
@@ -886,8 +930,18 @@ function solution() {
886
  document.getElementById('settingsToggle').addEventListener('click', toggleSettings);
887
 
888
  // Carousel controls
889
- document.getElementById('prevCard').addEventListener('click', () => rotateCarousel(-1));
890
- document.getElementById('nextCard').addEventListener('click', () => rotateCarousel(1));
 
 
 
 
 
 
 
 
 
 
891
  document.getElementById('applyPromptBtn').addEventListener('click', applyPromptsAndSwitchToChat);
892
 
893
  // Chat controls
@@ -943,7 +997,8 @@ function solution() {
943
  }
944
  }
945
 
946
- // Carousel functionality
 
947
  function setupCarousel() {
948
  updateCarouselPosition();
949
  }
@@ -953,7 +1008,23 @@ function solution() {
953
  currentCarouselIndex = (currentCarouselIndex + direction + totalCards) % totalCards;
954
  updateCarouselPosition();
955
  }
956
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
957
  function goToCarouselIndex(index) {
958
  currentCarouselIndex = index;
959
  updateCarouselPosition();
 
360
  background: linear-gradient(135deg, var(--success), #5af78e);
361
  box-shadow: 0 10px 25px rgba(46, 213, 115, 0.4);
362
  }
363
+ .carousel {
364
+ touch-action: pan-x pan-y;
365
+ transition: transform 0.6s ease-in-out;
366
+ }
367
+
368
+ .carousel-controls button {
369
+ touch-action: manipulation;
370
+ user-select: none; }
371
+
372
+ .carousel.dragging {
373
+ touch-action: none;
374
+ }
375
 
376
  .carousel-container {
377
  perspective: 1200px;
 
889
 
890
  // Event listeners setup
891
  function setupEventListeners() {
892
+ let startX = 0;
893
+ let startY = 0;
894
+ let lastTranslateX = 0;
895
+ let lastTranslateY = 0;
896
+ let isDragging = false;
897
+
898
+ document.getElementById('carousel').addEventListener('touchstart', (e) => {
899
+ isDragging = true;
900
+ startX = e.touches[0].clientX;
901
+ startY = e.touches[0].clientY;
902
+ });
903
+
904
+ document.getElementById('carousel').addEventListener('touchmove', (e) => {
905
+ if (!isDragging) return;
906
+
907
+ const dx = e.touches[0].clientX - startX;
908
+ const dy = e.touches[0].clientY - startY;
909
+
910
+ const newX = lastTranslateX + dx;
911
+ const newY = lastTranslateY + dy;
912
+
913
+ document.getElementById('carousel').style.transform = `translate3D(${newX}px, ${newY}px, 0)`;
914
+
915
+ startX = e.touches[0].clientX;
916
+ startY = e.touches[0].clientY;
917
+ }, { passive: false });
918
+
919
+ document.getElementById('carousel').addEventListener('touchend', () => {
920
+ isDragging = false;
921
+ lastTranslateX = parseFloat(document.getElementById('carousel').style.transform.match(/-?\d+(\.\d+)?px/g)[0]);
922
+ lastTranslateY = parseFloat(document.getElementById('carousel').style.transform.match(/-?\d+(\.\d+)?px/g)[1]);
923
+ });
924
  // Mode toggle
925
  document.getElementById('carouselModeBtn').addEventListener('click', () => switchMode('carousel'));
926
  document.getElementById('chatModeBtn').addEventListener('click', () => switchMode('chat'));
 
930
  document.getElementById('settingsToggle').addEventListener('click', toggleSettings);
931
 
932
  // Carousel controls
933
+ document.getElementById('prevCard').addEventListener('touchstart', () => rotateCarousel(-1, 0));
934
+ document.getElementById('nextCard').addEventListener('touchstart', () => rotateCarousel(1, 0));
935
+
936
+ document.getElementById('prevCard').addEventListener('touchmove', (e) => {
937
+ const dx = e.touches[0].clientX - startX;
938
+ if (dx > 50) rotateCarousel(-1, 0);
939
+ });
940
+
941
+ document.getElementById('nextCard').addEventListener('touchmove', (e) => {
942
+ const dx = e.touches[0].clientX - startX;
943
+ if (dx < -50) rotateCarousel(1, 0);
944
+ });
945
  document.getElementById('applyPromptBtn').addEventListener('click', applyPromptsAndSwitchToChat);
946
 
947
  // Chat controls
 
997
  }
998
  }
999
 
1000
+
1001
+ // Carousel functionality
1002
  function setupCarousel() {
1003
  updateCarouselPosition();
1004
  }
 
1008
  currentCarouselIndex = (currentCarouselIndex + direction + totalCards) % totalCards;
1009
  updateCarouselPosition();
1010
  }
1011
+ function rotateCarousel(dx, dy) {
1012
+ const totalCards = 6;
1013
+ const cardWidth = 100 / totalCards;
1014
+ const cardHeight = 100 / totalCards;
1015
+
1016
+ let newIndex = currentCarouselIndex;
1017
+
1018
+ if (dx > 0) newIndex--;
1019
+ if (dx < 0) newIndex++;
1020
+ if (dy > 0) newIndex++;
1021
+ if (dy < 0) newIndex--;
1022
+
1023
+ newIndex = (newIndex + totalCards) % totalCards;
1024
+
1025
+ currentCarouselIndex = newIndex;
1026
+ updateCarouselPosition();
1027
+ }
1028
  function goToCarouselIndex(index) {
1029
  currentCarouselIndex = index;
1030
  updateCarouselPosition();