Using Css3+jquery.js to realize micro-letter lottery Turntable effect

Source: Internet
Author: User

Why not use CSS3 to achieve it? So I'm going to use CSS3 to achieve this effect. No need to rely on jquery animation effect plug-ins, rotation angle plug-ins.

No nonsense paste Source:

PS: This animation does not support IE10 and the following (11 is not tested should also not support, want full compatibility access to the jquery version-see the first line of the connection), other browser test available. UC, micro-core test is available.

(The demo accessory is below, need wamp environment.) )



The most basic structure of the <!---->
<div class= "Demo" >


</div>

/* css*/
. done{
-webkit-transition:2s Ease, which is responsible for animation effects;
-moz-transition:2s ease;
-o-transition:2s ease;
Transition:2s ease;
}
$ (function () {     $ ("#startbtn"). Click (function () {         Lottery ()                 
     //Click Execute function Ajax    }); 
}); var a = 0;                            //Declare a value a function lottery () {    $. Ajax ({        type: "POST",         URL: " Json.php ",         dataType:" JSON ",         Cache:false,         error:function () {             alert ("Made a mistake!") 
"); 
            return false;        },         success:function (JSON) {                     // Angle   B = php from the angle of +720 (in order to ensure that the animation is not too fast to stop the first two laps) + declared value a            
  var b = json.angle+720+a;            //Awards       
      var p = json.prize;            //Click to run animation, so you must dynamically load style two values to be compatible with Chrome & Firefox & Safair             document.getElementById (" Startbtn "). setattribute (" style ","-webkit-transform:rotate "(" +b+ "deg); Transform:rotate (" +b+ "deg))             //After each execution through a so that the next 3 times more turn             //Because the value of rotate () is saved in CSS3 after each animation, if the angle is not increased, it will rotate in the angle of the return of PHP, that is, rotate within 360 degrees       
      A + + 1080;            //Animation effect is 2S, the animation plays the effect of playing the window    
         settimeout (slidefunction,2000);             function Slidefunction () {                 var con = confirm ("Congratulations, +p+") do you want to do it again? 
");                 if (con) {                     Lottery ( 
);                }else{                     return false;                }             }        }    
}); }

Because is self-study JS, write is not concise. Just to realize the effect of the idea. Excuse me!

Download Address: http://pan.baidu.com/s/1ntiCaKx



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.