Bläddra i källkod

考试测评动画

gzb
guozhongbo 1 år sedan
förälder
incheckning
4489eb55f9
4 ändrade filer med 121 tillägg och 29 borttagningar
  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 Visa fil

@@ -219,6 +219,10 @@
219 219
   width: 100%;
220 220
   height:  100%;
221 221
   position: absolute;
222
+  visibility: hidden;
223
+}
224
+.exam_vise{
225
+ visibility: visible;
222 226
 }
223 227
 .exam_content img {
224 228
   width: 100%;
@@ -480,4 +484,46 @@
480 484
 }
481 485
 .nav .active {
482 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 Visa fil

@@ -15,22 +15,26 @@ $(function () {
15 15
   var timer;
16 16
   var blue = $(".blue");
17 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 19
     $.each(exam_slide, (idx, item) => {
24 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 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 35
     if (!type) {
36
+      //自动轮播
37
+      showimg(index);
34 38
       beforeidx = index;
35 39
       index++;
36 40
       offset = "-=" + Math.abs(offset);
@@ -40,28 +44,53 @@ $(function () {
40 44
       }
41 45
 
42 46
       showButton();
47
+    } else {
48
+      showimg(beforeidx);
49
+      console.log("显示上一张图片");
43 50
     }
44 51
     if (index > beforeidx) {
45 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 58
     } else {
47 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 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 95
   var imglist = [
67 96
     {
@@ -145,7 +174,7 @@ $(function () {
145 174
   // 获取每个楼梯的offset().top,点击楼层让对应的内容模块移动到对应的位置
146 175
   var $stepItem = $(".step");
147 176
   $stepItem.on("click", function () {
148
-    $(this).addClass("active").siblings("li").removeClass("active");
177
+    $(this).addClass("active").siblings("div").removeClass("active");
149 178
     var $stepTop = $(".piece")
150 179
       .eq($(this).index() - 1)
151 180
       .offset().top;
@@ -164,6 +193,9 @@ $(function () {
164 193
     mouseenter: function () {
165 194
       //移入
166 195
       var myIndex = parseInt($(this).attr("index"));
196
+      if (myIndex == index) {
197
+        return;
198
+      }
167 199
       $.each(grey, function (idx, item) {
168 200
         $(this).show();
169 201
       });
@@ -185,8 +217,8 @@ $(function () {
185 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 Visa fil

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

+ 2
- 2
sections/product.html Visa fil

@@ -220,7 +220,7 @@
220 220
               </div>
221 221
               <div class="exam_content">
222 222
                 <div class="show_exam">
223
-                  <div class="exam_slide">
223
+                  <div class="exam_slide exam_vise">
224 224
                     <img src="../img/product/mtznh.png" />
225 225
                   </div>
226 226
                   <div class="exam_slide">
@@ -423,7 +423,7 @@
423 423
     </div>
424 424
     <div class="nav">
425 425
       <div>导航</div>
426
-      <div class="step">
426
+      <div class="step active">
427 427
         <p>区域大数据</p>
428 428
         <p>平台</p>
429 429
       </div>

Laddar…
Avbryt
Spara