How to use JS to implement banner diagram scrolling

Source: Internet
Author: User

Using JS to realize the scrolling of banner graph is mainly the application of timer

Create a few pictures of the banner map first, the last one with the first one, to ensure that the rolling uninterrupted

Change the style, you need to note that all the pictures to show in the peer, otherwise you cannot scroll to the left

A function is declared as a timer function, which executes through a switch structure, and the value of case is added by declaring a global variable each time the function is executed, and the number of times the function is executed to determine how far the banner graph is moved to the left. Note that the 5th time you want to zero the global variable to make the switch structure in the timer infinite loop, you can set the transition effect in the style sheet, so that the scrolling more rhythmic

The next step is to achieve the banner click Switch Effect

Start writing functions After you have done your style

Define a parametric function, with different parameters to operate the switch structure, change the banner to the left scroll distance, the bottom of num = Num1-1 is to let the page stop after the click to scroll, but wait for a timer operation after a scroll, Make the banner of the stay show a longer-lasting effect.

The last of the following

How to use JS to implement banner diagram scrolling

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.