|
@@ -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);
|
|
|
});
|
|
|
});
|
|
|
|