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.