Browse Source

评测系统

gzb
guozhongbo 1 year ago
parent
commit
2cfcf8c56c
3 changed files with 53 additions and 28 deletions
  1. 1
    3
      css/product.css
  2. 51
    24
      js/product.js
  3. 1
    1
      sections/product.html

+ 1
- 3
css/product.css View File

218
 .exam_slide{
218
 .exam_slide{
219
   width: 100%;
219
   width: 100%;
220
   height:  100%;
220
   height:  100%;
221
+  position: absolute;
221
 }
222
 }
222
 .exam_content img {
223
 .exam_content img {
223
   width: 100%;
224
   width: 100%;
224
   height:  100%;
225
   height:  100%;
225
   /* object-fit: cover; */
226
   /* object-fit: cover; */
226
 }
227
 }
227
-.exam_slide{
228
-  position: relative;
229
-}
230
 .exam_slide span{
228
 .exam_slide span{
231
   position: absolute;
229
   position: absolute;
232
 }
230
 }

+ 51
- 24
js/product.js View File

6
   //获取元素
6
   //获取元素
7
   var divheight = $(".exam_one").height();
7
   var divheight = $(".exam_one").height();
8
   var container = $(".exam_container");
8
   var container = $(".exam_container");
9
+  var exam_slide = $(".exam_slide"); //右侧图片
9
   var list = $(".show_exam");
10
   var list = $(".show_exam");
10
   var buts = $(".exam_item");
11
   var buts = $(".exam_item");
11
   var index = 0; //存放当前显示的图片的下标
12
   var index = 0; //存放当前显示的图片的下标
13
+  var beforeidx = 0; //之前的索引
12
   var interval = 5000; //位移时间间隔
14
   var interval = 5000; //位移时间间隔
13
   var timer;
15
   var timer;
14
   var blue = $(".blue");
16
   var blue = $(".blue");
15
   var grey = $(".grey");
17
   var grey = $(".grey");
18
+  var that = $;
16
   function animate(offset, type) {
19
   function animate(offset, type) {
17
     var top = parseInt(list.css("top")) + offset;
20
     var top = parseInt(list.css("top")) + offset;
18
     // console.log(list.css("top"));
21
     // console.log(list.css("top"));
19
     var absnum = Math.abs(offset);
22
     var absnum = Math.abs(offset);
20
-    index++;
21
-    offset = "-=" + Math.abs(offset);
22
-    if (index == 5) {
23
-      index = 0;
24
-      offset = 0;
25
-    }
23
+    $.each(exam_slide, (idx, item) => {
24
+      if (index != idx) {
25
+        //隐藏
26
+        exam_slide.eq(idx).css("visibility", "hidden");
27
+      } else {
28
+        //显示当前索引图片
29
+        exam_slide.eq(idx).css("visibility", "visible");
30
+      }
31
+    });
32
+
26
     if (!type) {
33
     if (!type) {
34
+      beforeidx = index;
35
+      index++;
36
+      offset = "-=" + Math.abs(offset);
37
+      if (index == 5) {
38
+        index = 0;
39
+        offset = 0;
40
+      }
41
+
27
       showButton();
42
       showButton();
28
     }
43
     }
29
-    list.animate({ top: offset }, 300, function () {
30
-      if (top > -200) {
44
+    if (index > beforeidx) {
45
+      console.log("从下往上滚");
46
+    } else {
47
+      console.log("从上往下滚");
48
+    }
49
+    console.log("当前索引", index, "上一个索引", beforeidx);
50
+
51
+    exam_slide.eq(beforeidx).animate(
52
+      {
53
+        visibility: "hidden",
54
+        transformOrigin: "top center",
55
+        transform: "scale(0)"
56
+      },
57
+      500,
58
+      () => {
59
+        console.log("动画完成");
60
+        if (type) {
61
+          beforeidx = index;
62
+        }
31
       }
63
       }
32
-    });
64
+    );
33
   }
65
   }
34
   var imglist = [
66
   var imglist = [
35
     {
67
     {
131
   buts.on({
163
   buts.on({
132
     mouseenter: function () {
164
     mouseenter: function () {
133
       //移入
165
       //移入
166
+      var myIndex = parseInt($(this).attr("index"));
167
+      $.each(grey, function (idx, item) {
168
+        $(this).show();
169
+      });
134
       $.each(blue, function (idx, item) {
170
       $.each(blue, function (idx, item) {
135
-        $(this).hide();
171
+        if (idx == myIndex) {
172
+          $(this).show();
173
+        } else {
174
+          $(this).hide();
175
+        }
136
       });
176
       });
137
-      var myIndex = parseInt($(this).attr("index"));
138
-      blue.eq(myIndex).show();
139
       index = myIndex;
177
       index = myIndex;
140
       animate(divheight, 1);
178
       animate(divheight, 1);
141
-      console.log("移入当前索引", myIndex);
142
     },
179
     },
143
-    mouseleave: function () {
144
-      //移出
145
-      var myIndex = parseInt($(this).attr("index"));
146
-      if (myIndex != 0 && myIndex != 4) {
147
-        console.log(123);
148
-        blue.eq(myIndex).hide();
149
-        grey.eq(myIndex).show();
150
-      }
151
-
152
-      console.log("移出当前索引", myIndex);
153
-    }
180
+    mouseleave: function () {}
154
   });
181
   });
155
   // 回到顶部
182
   // 回到顶部
156
   $(".top").on("click", function () {
183
   $(".top").on("click", function () {

+ 1
- 1
sections/product.html View File

221
               <div class="exam_content">
221
               <div class="exam_content">
222
                 <div class="show_exam">
222
                 <div class="show_exam">
223
                   <div class="exam_slide">
223
                   <div class="exam_slide">
224
-                    <img class="exam_one" src="../img/product/mtznh.png" />
224
+                    <img src="../img/product/mtznh.png" />
225
                   </div>
225
                   </div>
226
                   <div class="exam_slide">
226
                   <div class="exam_slide">
227
                     <img src="../img/product/zdqss.png" />
227
                     <img src="../img/product/zdqss.png" />

Loading…
Cancel
Save