Prechádzať zdrojové kódy

Merge branch 'dev/v4.9.48_tsz' of qmx/jy into release/v4.9.48

汤世哲 1 rok pred
rodič
commit
4fae0cc6ad

+ 14 - 8
src/web/staticres/frontRouter/pc/customExport/js/consult.js

@@ -8,10 +8,11 @@ $(function(){
   windowScrollFn();
   $(window).on('scroll', windowScrollFn);
   $(window).on('resize', windowScrollFn);
-
+  let isHovering = false;  
 // 经典案例模块展开收缩
   document.querySelectorAll('.case-module-component').forEach(item => {  
     item.addEventListener('mouseenter', function() {  
+        isHovering = true;
         // 移除所有项目的expanded类  
         document.querySelectorAll('.case-module-component').forEach(otherItem => {  
             otherItem.classList.remove('expanded');  
@@ -21,13 +22,18 @@ $(function(){
         this.classList.add('expanded');  
     });
     item.addEventListener('mouseleave', function() {
-      // 移除所有项目的expanded类  
-      document.querySelectorAll('.case-module-component').forEach((otherItem, index) => {  
-          otherItem.classList.remove('expanded');
-      });
-  
-      // 为当前项目添加expanded类  
-      document.querySelectorAll('.case-module-component')[0].classList.add('expanded');  
+        // 标记为非悬停状态
+        isHovering = false;
+        // 移除所有项目的expanded类  
+        document.querySelectorAll('.case-module-component').forEach((otherItem, index) => {  
+            otherItem.classList.remove('expanded');
+        });
+        setTimeout(() => {  
+            if (!isHovering) {  
+              // 假设此时没有元素被悬停,给第一个元素添加expanded类
+              document.querySelectorAll('.case-module-component')[0].classList.add('expanded'); 
+            }  
+        }, 200);
     });
   });