Starchik1 commited on
Commit
7df12c5
·
verified ·
1 Parent(s): 87d6724

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +18 -10
index.html CHANGED
@@ -930,21 +930,29 @@
930
  });
931
 
932
  // Обработчики для мобильных описаний
933
- document.querySelectorAll('.material-card').forEach(card => {
934
- card.addEventListener('click', function(e) {
935
- if (window.matchMedia("(max-width: 768px)").matches) {
 
 
 
 
 
 
 
936
  this.classList.toggle('active');
937
  }
938
- });
939
  });
 
940
 
941
  document.addEventListener('click', (e) => {
942
- if (!e.target.closest('.material-card') && window.matchMedia("(max-width: 768px)").matches) {
943
- document.querySelectorAll('.material-card').forEach(card => {
944
- card.classList.remove('active');
945
- });
946
- }
947
- });
948
  </script>
949
  </body>
950
  </html>
 
930
  });
931
 
932
  // Обработчики для мобильных описаний
933
+ document.querySelectorAll('.material-card').forEach(card => {
934
+ card.addEventListener('click', function(e) {
935
+ if (window.matchMedia("(max-width: 768px)").matches) {
936
+ // Проверяем что клик не внутри описания
937
+ if (!e.target.closest('.material-description')) {
938
+ // Закрываем все другие карточки
939
+ document.querySelectorAll('.material-card').forEach(c => {
940
+ if (c !== this) c.classList.remove('active');
941
+ });
942
+ // Переключаем текущую карточку
943
  this.classList.toggle('active');
944
  }
945
+ }
946
  });
947
+ });
948
 
949
  document.addEventListener('click', (e) => {
950
+ if (!e.target.closest('.material-card') && window.matchMedia("(max-width: 768px)").matches) {
951
+ document.querySelectorAll('.material-card').forEach(card => {
952
+ card.classList.remove('active');
953
+ });
954
+ }
955
+ });
956
  </script>
957
  </body>
958
  </html>