Text scroll effect (Operation node)

Source: Internet
Author: User

First, let's take a look at the effect:Demo
Next is the analysis of ideas:
The first is the idea of the main function:
1. Extract the first Li in the list and copy it.
2. Check whether the margin-top of Li is-20px.
If it is true, delete the first Li from UL and add its copy to the end of ul. And set the margin-top of Li to 0;
If this parameter is set to false, margin-top is reduced, such as-2. Call the main function using setTimeout until the value is true in step 2;
Then:
3. Define the onload event processing function of the window and use setinterval to repeatedly call the main function.
Note 1:Childnodes In the Firefox browser is different from children. In this example,

 



There are nine childnodes, and the first five are all text "\ n ". In this example, we want to operate on the node, that is, childnodes. Obviously, we cannot directly extract the first node of UL. Therefore, we have defined a getfirstchild function for filtering.

Note 2:In this example, the closure technique is used multiple times, which is very effective and necessary. Ensure that the parameters passed to the function are correct.CodeAs follows:

Window. setinterval (function () {scrollit (parentnode, 20,0)}, 3000 );
SetTimeout (function () {scrollit (OBJ, top, I) ;}, 20 );

For the closure, I will make a more detailed summary in the future log. Here I just want to emphasize its role.

 

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.