Browse Source

考试测评动画

gzb
guozhongbo 1 year ago
parent
commit
4489eb55f9
4 changed files with 121 additions and 29 deletions
  1. 46
    0
      css/product.css
  2. 57
    25
      js/product.js
  3. 16
    2
      js/trial.js
  4. 2
    2
      sections/product.html

+ 46
- 0
css/product.css View File

219
   width: 100%;
219
   width: 100%;
220
   height:  100%;
220
   height:  100%;
221
   position: absolute;
221
   position: absolute;
222
+  visibility: hidden;
223
+}
224
+.exam_vise{
225
+ visibility: visible;
222
 }
226
 }
223
 .exam_content img {
227
 .exam_content img {
224
   width: 100%;
228
   width: 100%;
480
 }
484
 }
481
 .nav .active {
485
 .nav .active {
482
   color: #2d8cf0;
486
   color: #2d8cf0;
487
+}
488
+/* 过度动画 */
489
+.flip-scale-down-hor {
490
+  -webkit-animation: flip-scale-down-hor 0.5s linear both;
491
+  animation: flip-scale-down-hor 0.5s linear both;
492
+}
493
+@keyframes flip-scale-down-hor {
494
+  0% {
495
+    -webkit-transform: scale(1) ;
496
+    transform: scale(1) ;
497
+  }
498
+
499
+  50% {
500
+    -webkit-transform: scale(0.5) ;
501
+    transform: scale(0.5);
502
+  }
503
+
504
+  100% {
505
+    -webkit-transform: scale(0);
506
+    transform: scale(0) ;
507
+    transform-origin: top center;
508
+  }
509
+}
510
+.flip-scale-up-hor {
511
+  -webkit-animation: flip-scale-up-hor 0.5s linear both;
512
+  animation: flip-scale-up-hor 0.5s linear both;
513
+}
514
+@keyframes flip-scale-up-hor {
515
+  0% {
516
+    -webkit-transform: scale(0);
517
+    transform: scale(0) ;
518
+    transform-origin: bottom center;
519
+  }
520
+ 50% {
521
+   -webkit-transform: scale(0.5);
522
+   transform: scale(0.5);
523
+ }
524
+  100% {
525
+    -webkit-transform: scale(1);
526
+    transform: scale(1);
527
+    transform-origin: center center;
528
+  }
483
 }
529
 }

+ 57
- 25
js/product.js View File

15
   var timer;
15
   var timer;
16
   var blue = $(".blue");
16
   var blue = $(".blue");
17
   var grey = $(".grey");
17
   var grey = $(".grey");
18
-  var that = $;
19
-  function animate(offset, type) {
20
-    var top = parseInt(list.css("top")) + offset;
21
-    // console.log(list.css("top"));
22
-    var absnum = Math.abs(offset);
18
+  function showimg(index) {
23
     $.each(exam_slide, (idx, item) => {
19
     $.each(exam_slide, (idx, item) => {
24
       if (index != idx) {
20
       if (index != idx) {
25
         //隐藏
21
         //隐藏
26
-        exam_slide.eq(idx).css("visibility", "hidden");
22
+        setTimeout(() => {
23
+          exam_slide.eq(idx).css("visibility", "hidden");
24
+        }, 500);
27
       } else {
25
       } else {
28
         //显示当前索引图片
26
         //显示当前索引图片
29
-        exam_slide.eq(idx).css("visibility", "visible");
27
+        // exam_slide.eq(idx).css("visibility", "visible");
28
+        setTimeout(() => {
29
+          exam_slide.eq(idx).css("visibility", "visible");
30
+        }, 500);
30
       }
31
       }
31
     });
32
     });
32
-
33
+  }
34
+  function animate(offset, type) {
33
     if (!type) {
35
     if (!type) {
36
+      //自动轮播
37
+      showimg(index);
34
       beforeidx = index;
38
       beforeidx = index;
35
       index++;
39
       index++;
36
       offset = "-=" + Math.abs(offset);
40
       offset = "-=" + Math.abs(offset);
40
       }
44
       }
41
 
45
 
42
       showButton();
46
       showButton();
47
+    } else {
48
+      showimg(beforeidx);
49
+      console.log("显示上一张图片");
43
     }
50
     }
44
     if (index > beforeidx) {
51
     if (index > beforeidx) {
45
       console.log("从下往上滚");
52
       console.log("从下往上滚");
53
+      exam_slide
54
+        .eq(beforeidx)
55
+        .addClass("flip-scale-down-hor")
56
+        .siblings("div")
57
+        .removeClass("flip-scale-down-hor");
46
     } else {
58
     } else {
47
       console.log("从上往下滚");
59
       console.log("从上往下滚");
60
+      exam_slide
61
+        .eq(beforeidx)
62
+        .addClass("flip-scale-up-hor")
63
+        .siblings("div")
64
+        .removeClass("flip-scale-up-hor");
48
     }
65
     }
49
     console.log("当前索引", index, "上一个索引", beforeidx);
66
     console.log("当前索引", index, "上一个索引", beforeidx);
67
+    //
50
 
68
 
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
-        }
69
+    setTimeout(() => {
70
+      showimg(index);
71
+      exam_slide
72
+        .eq(index)
73
+        .addClass("flip-scale-up-hor")
74
+        .siblings("div")
75
+        .removeClass("flip-scale-up-hor");
76
+      console.log("显示当前图片");
77
+      if (index > beforeidx) {
78
+        // exam_slide
79
+        //   .eq(index)
80
+        //   .addClass("flip-scale-up-hor")
81
+        //   .siblings("div")
82
+        //   .removeClass("flip-scale-up-hor");
83
+      } else {
84
+        // exam_slide
85
+        //   .eq(index)
86
+        //   .addClass("flip-scale-down-hor")
87
+        //   .siblings("div")
88
+        //   .removeClass("flip-scale-down-hor");
63
       }
89
       }
64
-    );
90
+    }, 500);
91
+    if (type) {
92
+      beforeidx = index;
93
+    }
65
   }
94
   }
66
   var imglist = [
95
   var imglist = [
67
     {
96
     {
145
   // 获取每个楼梯的offset().top,点击楼层让对应的内容模块移动到对应的位置
174
   // 获取每个楼梯的offset().top,点击楼层让对应的内容模块移动到对应的位置
146
   var $stepItem = $(".step");
175
   var $stepItem = $(".step");
147
   $stepItem.on("click", function () {
176
   $stepItem.on("click", function () {
148
-    $(this).addClass("active").siblings("li").removeClass("active");
177
+    $(this).addClass("active").siblings("div").removeClass("active");
149
     var $stepTop = $(".piece")
178
     var $stepTop = $(".piece")
150
       .eq($(this).index() - 1)
179
       .eq($(this).index() - 1)
151
       .offset().top;
180
       .offset().top;
164
     mouseenter: function () {
193
     mouseenter: function () {
165
       //移入
194
       //移入
166
       var myIndex = parseInt($(this).attr("index"));
195
       var myIndex = parseInt($(this).attr("index"));
196
+      if (myIndex == index) {
197
+        return;
198
+      }
167
       $.each(grey, function (idx, item) {
199
       $.each(grey, function (idx, item) {
168
         $(this).show();
200
         $(this).show();
169
       });
201
       });
185
       scrollTop: 0
217
       scrollTop: 0
186
     });
218
     });
187
   });
219
   });
188
-  container.hover(stop, play);
220
+  // container.hover(stop, play);
189
 
221
 
190
-  play();
191
-  showButton();
222
+  // play();
223
+  // showButton();
192
 });
224
 });

+ 16
- 2
js/trial.js View File

26
   $("#phone").focus(() => {
26
   $("#phone").focus(() => {
27
     $(".err_phone").hide();
27
     $(".err_phone").hide();
28
   });
28
   });
29
-
29
+  var mailboxf = true;
30
   //邮箱
30
   //邮箱
31
   $("#mailbox").blur(() => {
31
   $("#mailbox").blur(() => {
32
     let mailbox = $("#mailbox").val();
32
     let mailbox = $("#mailbox").val();
33
+    mailboxf = false;
33
     var filter =
34
     var filter =
34
       /^[\w\-\.]+@[a-z0-9]+(\-[a-z0-9]+)?(\.[a-z0-9]+(\-[a-z0-9]+)?)*\.[a-z]{2,4}$/i;
35
       /^[\w\-\.]+@[a-z0-9]+(\-[a-z0-9]+)?(\.[a-z0-9]+(\-[a-z0-9]+)?)*\.[a-z]{2,4}$/i;
35
     let blnTest = filter.test(mailbox);
36
     let blnTest = filter.test(mailbox);
36
-    console.log(mailbox);
37
     if (mailbox && !blnTest) {
37
     if (mailbox && !blnTest) {
38
       $(".err_mailbox").show();
38
       $(".err_mailbox").show();
39
+      mailboxf = true;
39
     }
40
     }
40
   });
41
   });
41
   $("#mailbox").focus(() => {
42
   $("#mailbox").focus(() => {
43
   });
44
   });
44
   $("#mailbox").bind("input propertychange change", function (event) {
45
   $("#mailbox").bind("input propertychange change", function (event) {
45
     let mailbox = $("#mailbox").val();
46
     let mailbox = $("#mailbox").val();
47
+    mailboxf = false;
46
     var filter =
48
     var filter =
47
       /^[\w\-\.]+@[a-z0-9]+(\-[a-z0-9]+)?(\.[a-z0-9]+(\-[a-z0-9]+)?)*\.[a-z]{2,4}$/i;
49
       /^[\w\-\.]+@[a-z0-9]+(\-[a-z0-9]+)?(\.[a-z0-9]+(\-[a-z0-9]+)?)*\.[a-z]{2,4}$/i;
48
     let blnTest = filter.test(mailbox);
50
     let blnTest = filter.test(mailbox);
49
     if (mailbox && !blnTest) {
51
     if (mailbox && !blnTest) {
50
       $(".err_mailbox").show();
52
       $(".err_mailbox").show();
53
+      mailboxf = true;
51
     } else {
54
     } else {
52
       $(".err_mailbox").hide();
55
       $(".err_mailbox").hide();
53
     }
56
     }
69
       $(".err_phone").show();
72
       $(".err_phone").show();
70
       return;
73
       return;
71
     }
74
     }
75
+    if (mailboxf) {
76
+      //邮箱不合法
77
+      return;
78
+    }
72
     var data = {
79
     var data = {
73
       account: $("#account").val(),
80
       account: $("#account").val(),
74
       phone: $("#phone").val(),
81
       phone: $("#phone").val(),
88
         Loading = false;
95
         Loading = false;
89
         if (data.code === 0) {
96
         if (data.code === 0) {
90
           alert("申请成功");
97
           alert("申请成功");
98
+          $("#account").val("");
99
+          $("#phone").val("");
100
+          $("#mailbox").val("");
101
+          $("#comm").val("");
102
+          $(".err_account").hide();
103
+          $(".err_phone").hide();
104
+          $(".err_mailbox").hide();
91
         } else {
105
         } else {
92
           alert(data.msg);
106
           alert(data.msg);
93
         }
107
         }

+ 2
- 2
sections/product.html View File

220
               </div>
220
               </div>
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 exam_vise">
224
                     <img 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">
423
     </div>
423
     </div>
424
     <div class="nav">
424
     <div class="nav">
425
       <div>导航</div>
425
       <div>导航</div>
426
-      <div class="step">
426
+      <div class="step active">
427
         <p>区域大数据</p>
427
         <p>区域大数据</p>
428
         <p>平台</p>
428
         <p>平台</p>
429
       </div>
429
       </div>

Loading…
Cancel
Save