Browse Source

产品中心增加导航

gzb
guozhongbo 1 year ago
parent
commit
572e05f5db
4 changed files with 75 additions and 25 deletions
  1. 29
    1
      css/product.css
  2. 0
    15
      js/about.js
  3. 38
    2
      js/product.js
  4. 8
    7
      sections/product.html

+ 29
- 1
css/product.css View File

443
 .nav{
443
 .nav{
444
   position: fixed;
444
   position: fixed;
445
   top: 5rem;
445
   top: 5rem;
446
-  left: 2rem;
446
+  left: 0.6rem;
447
+  border-radius: 0.08rem;
448
+    background: #ffffffff;
449
+    box-shadow: 1px 0 3px 0 #0000001a;
447
 }
450
 }
448
 .nav>div{
451
 .nav>div{
449
   font-size: 0.14rem;
452
   font-size: 0.14rem;
451
   color: white;
454
   color: white;
452
   color: #2d8cf0;
455
   color: #2d8cf0;
453
   line-height: 0.4rem;
456
   line-height: 0.4rem;
457
+  width: 1.4rem;
458
+  border-bottom: 1px solid #f7f7f7f7 ;
459
+  cursor: pointer;
460
+}
461
+.nav div:first-of-type {
462
+  background-color: #298df0;
463
+  border-top-right-radius:0.08rem ;
464
+  border-top-left-radius: 0.08rem;
465
+  color: white;
466
+  border-bottom: 1px solid #298df0;
467
+}
468
+.nav div:last-of-type{
469
+  background-color: #298df0;
470
+    border-bottom-right-radius: 0.08rem;
471
+    border-bottom-left-radius: 0.08rem;
472
+    color: white;
473
+}
474
+.nav img{
475
+  width: 0.16rem;
476
+  height: 0.16rem;
477
+}
478
+.nav .active {
479
+  background-color: #298df0;
480
+  color: white;
481
+  border-bottom: 1px solid #298df0;
454
 }
482
 }

+ 0
- 15
js/about.js View File

75
   var offsetpx = (datalist.length - len) * divwidth; //可偏移度
75
   var offsetpx = (datalist.length - len) * divwidth; //可偏移度
76
   var offleft = 0; //当前偏移量
76
   var offleft = 0; //当前偏移量
77
   function animate(offset) {
77
   function animate(offset) {
78
-    if (datalist.length <= 5) {
79
-      return;
80
-    }
81
     var left = parseInt(list.css("left")) + offset;
78
     var left = parseInt(list.css("left")) + offset;
82
     var absnum = Math.abs(offset);
79
     var absnum = Math.abs(offset);
83
     if (left < 0 - offsetpx) {
80
     if (left < 0 - offsetpx) {
109
   }
106
   }
110
   //点击高亮滚动
107
   //点击高亮滚动
111
   function animates(offset) {
108
   function animates(offset) {
112
-    if (datalist.length <= 5) {
113
-      return;
114
-    }
115
     var left = parseInt(list.css("left")) + offset; //获取元素属性
109
     var left = parseInt(list.css("left")) + offset; //获取元素属性
116
     if (index < 6 && left >= 0) {
110
     if (index < 6 && left >= 0) {
117
       list.animate({ left: 0 }, 300, function () {});
111
       list.animate({ left: 0 }, 300, function () {});
143
 
137
 
144
   // 鼠标离开图片区域时,轮播继续
138
   // 鼠标离开图片区域时,轮播继续
145
   function play() {
139
   function play() {
146
-    if (datalist.length <= 5) {
147
-      return;
148
-    }
149
     timer = setTimeout(function () {
140
     timer = setTimeout(function () {
150
       next.trigger("click");
141
       next.trigger("click");
151
       play();
142
       play();
162
 
153
 
163
   // 右按钮点击事件
154
   // 右按钮点击事件
164
   next.bind("click", function () {
155
   next.bind("click", function () {
165
-    if (datalist.length <= 5) {
166
-      return;
167
-    }
168
     // 判断当前是否在动画
156
     // 判断当前是否在动画
169
     if (list.is(":animated")) {
157
     if (list.is(":animated")) {
170
       return;
158
       return;
186
 
174
 
187
   // 左按钮事件
175
   // 左按钮事件
188
   prev.bind("click", function () {
176
   prev.bind("click", function () {
189
-    if (datalist.length <= 5) {
190
-      return;
191
-    }
192
     // 判断当前是否在动画
177
     // 判断当前是否在动画
193
     if (list.is(":animated")) {
178
     if (list.is(":animated")) {
194
       return;
179
       return;

+ 38
- 2
js/product.js View File

14
 
14
 
15
   function animate(offset) {
15
   function animate(offset) {
16
     var top = parseInt(list.css("top")) + offset;
16
     var top = parseInt(list.css("top")) + offset;
17
-    console.log(list.css("top"));
17
+    // console.log(list.css("top"));
18
     var absnum = Math.abs(offset);
18
     var absnum = Math.abs(offset);
19
     index++;
19
     index++;
20
 
20
 
30
       offset = 0;
30
       offset = 0;
31
     }
31
     }
32
     showButton();
32
     showButton();
33
-    console.log("当前索引", index, top, offset);
33
+    // console.log("当前索引", index, top, offset);
34
     list.animate({ top: offset }, 300, function () {
34
     list.animate({ top: offset }, 300, function () {
35
       if (top > -200) {
35
       if (top > -200) {
36
       }
36
       }
99
 
99
 
100
   play();
100
   play();
101
   showButton();
101
   showButton();
102
+
103
+  //楼梯导航
104
+  $(window).on("scroll", function () {
105
+    var $scroll = $(this).scrollTop();
106
+    // 拖动滚轮,点亮对应的楼层标签
107
+    $(".piece").each(function () {
108
+      var $stepTop = $(".piece").eq($(this).index()).offset().top;
109
+      // 楼层的top大于滚动条的距离
110
+      if ($stepTop > $scroll) {
111
+        $(".step").removeClass("active");
112
+        $(".step").eq($(this).index()).addClass("active");
113
+        // 中断循环
114
+        return false;
115
+      }
116
+    });
117
+  });
118
+
119
+  // 获取每个楼梯的offset().top,点击楼层让对应的内容模块移动到对应的位置
120
+  var $stepItem = $(".step");
121
+  $stepItem.on("click", function () {
122
+    $(this).addClass("active").siblings("li").removeClass("active");
123
+    var $stepTop = $(".piece")
124
+      .eq($(this).index() - 1)
125
+      .offset().top;
126
+    // 获取每个楼梯的offsetTop值
127
+    $("html,body").animate({
128
+      scrollTop: $stepTop
129
+    });
130
+  });
131
+
132
+  // 回到顶部
133
+  $(".top").on("click", function () {
134
+    $("html,body").animate({
135
+      scrollTop: 0
136
+    });
137
+  });
102
 });
138
 });

+ 8
- 7
sections/product.html View File

370
     </div>
370
     </div>
371
     <div class="nav">
371
     <div class="nav">
372
       <div>导航</div>
372
       <div>导航</div>
373
-      <div>区域大数据平台</div>
374
-      <div>校园教学平台</div>
375
-      <div>考试及测评系统</div>
376
-      <div>网课平台</div>
377
-      <div>校本资源库</div>
378
-      <div>微课工具</div>
379
-      <div>
373
+      <div class="step">区域大数据平台</div>
374
+      <div class="step">校园教学平台</div>
375
+      <div class="step">考试及测评系统</div>
376
+      <div class="step">网课平台</div>
377
+      <div class="step">智慧教学系统</div>
378
+      <div class="step">校本资源库</div>
379
+      <div class="step">云鸽微课</div>
380
+      <div class="top">
380
         <img src="../img/product/top.png" />
381
         <img src="../img/product/top.png" />
381
       </div>
382
       </div>
382
     </div>
383
     </div>

Loading…
Cancel
Save