jquery Split-screen indicator picture rotation effect instance _jquery

Source: Internet
Author: User
Tags setinterval

This example describes the implementation of the jquery split-screen indicator picture rotation effect. Share to everyone for your reference. The specific analysis is as follows:

In the Web app's big Way today, the split-screen indicator is used very widely, from Android, to Tencent's Web OS, and so on. Split-screen indicator gives a good user experience, the following implementation of a split-screen indicator, used to achieve a simple picture rotation effect, only to introduce ~

The code is as follows:

 <script type= "Text/javascript" > var curr = 0, next = 0, count = 0;
     $ (document). Ready (function () {//record number of pictures count = $ (' #img_list a '). Size ();
     t = setinterval (' Imgplay () ', 3000);
     The mouse moves to stop playing on the picture or navigation, and resumes playing after removing the $ (' #imgs Li, #img_list a '). Hover (function () {clearinterval (t);
     The function () {t = setinterval (' Imgplay () ', 3000);
     }); Click on the navigation to play to the corresponding picture $ (' #img_list a '). Click (function () {//index () functions to return the current navigation subscript var index = $ (' #img_list a ')
       . index (this);
         if (Curr!= index) {play (index);
       Curr = index;
       };
     return false;
   });
   });
     Play the function of the picture var imgplay = functions () {next = Curr + 1;
     If the current picture is played to the last one, this sets the next picture to be played as the subscript for the first picture (Curr = = count-1) Next = 0;
     Play (next);
     curr++;  After the subscript of the current picture plus 1, if the value is greater than the bottom of the last picture, set the next round of actually playing the picture subscript as the subscript for the first picture, and next is always larger than Curr 1 if (Curr > count-1) {curr = 0; next = Curr + 1;
   }
   }; Functions that control the playback effect var play = function (next) {//the current picture slides to the left -500px and returns to the right 490px//The next picture slides to 0px, the focus of the navigation is switched to the next point $ (' #imgs Li ') after completion. EQ (curr ). css ({' opacity ': ' 0.5 '}). Animate ({' Left ': ' -530px ', ' opacity ': ' 1 "}, ' slow ', function () {$ (this). css ({' Left
     ': ' 520px '}); ). End (). EQ (next). Animate ({' Left ': ' 0px ', ' opacity ': ' 1 '}, ' slow ', function () {$ (' #img_list a '). Siblings (' a '). Remov
Eclass (' active '). End (). EQ (next). addclass (' active ');
   });
 };

 </script>

I hope this article will help you with your jquery programming.

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.