Explore JavaScript----My understanding of the gradient carousel

Source: Internet
Author: User

For a person who does not have a foundation for programming, I often want to be told that when we see an effect, how to logically analyze its behavior, and I myself need to strengthen this aspect of self-reflection, for a carousel I see this, auto play is bound to have a timer, While playing a frame (assuming the gradient is real), the gradient must also have a timer.

1: People control a carousel via the mouse to automatically play AutoPlay.

A. When the mouse moves into the range of the carousel graph, the carousel stops playing automatically, and the reverse starts to play automatically:

Obox.onmouseover=function () {

Clearinterval (play);

}

Obox.onmouseout=function () {

AutoPlay ();

}

B. When the mouse moves to a button, the frame is played: (Here is the thought: there is a link between the inevitable button and the diagram to control each other, it is the parameter)

for (Var i=0;i<anum.length;i++) {

anum[i].index=i;//Add a "number card" attribute for each button;

Show (This.index)

}

2: AutoPlay controls the playback of each frame show ():

function AutoPlay () {

Play=setinterval (

index++;

Index>=anum.length && (index=0);//When playing to the last frame, 2 seconds and then + + becomes the Anum.length frame (empty), let it play again

Show (index);

},2000)

AutoPlay ();

3: Play Show () per frame, each time the transparency of all frames is changed to 0, also mark a specific button, and then let the specific frame of the degree of increase to opacity=1;

Function Show (a) {//need to play a specific frame generated from AutoPlay, mouse over button, control by parameters

for (Var i=0;i<ali.length;i++) ali[i].style.opacity= "";//Not compatible

for (Var i=0;i<anum.length;i++) {

Anum[i].classname= "";

}

Anum[a].classname= "Current";

var alpha=0;//is best declared in function header

Timer=setinterval (function () {

alpha++2;

alpha>100 && (alpha=100);

ali[a].style.opacity = "" +alpha/100;

alpha==100 && clearinterval (timer);

},20)

}

Explore JavaScript----My understanding of the gradient carousel

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.