Simple to achieve JS intermittent or seamless scrolling effect _javascript skills

Source: Internet
Author: User
Tags setinterval

Intermittent, seamless scrolling effect (the effect of recording with GIF is not very good, interested can down code), the specific contents are as follows

Code:

<! DOCTYPE html>  

Note the point:
1. Box block to CSS overflow hidden: overflow:hidden
2. Two features: intermittent scrolling/seamless scrolling
3. First copy a piece of the same code, seamless scrolling: The execution timer has been increased scrolltop value, when the scrolltop value is greater than the box height, set the scrolltop to 0, to start over. Intermittent scrolling on this basis adds a settimeout, intermittent execution, which reaches the specified height stop at scrolltop
4. Question: SetInterval in code (function () {scrolling ()},30); This can be done, setinterval (' Scrolling () ', 30); So no, there is no great God under the guidance of the two, what is the difference? What's the mechanism?

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

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.