Javascript enables seamless up/down scrolling

Source: Internet
Author: User
The principle of seamless up/down scrolling in js is as follows: 1. First set the height or width for the container, then overflow: hidden; & amp; nbsp; 2. After the container height is set, if the content is exceeded, it is hidden. 3. Change the scrollTop of the container (scroll up or down)

The principle of seamless up/down scrolling in Javascript is as follows:

1. First set the height or width for the container, and then overflow: hidden;
2. When the container height is set, the content exceeding the limit is hidden.
3. Change the value of the scrollTop attribute of the container to move the content up or down a node (the principle of scrolling );
4. When scrollTop is greater than or equal to the height of the node to be rolled, set scrollTop to 0, move the first node in the subnode tree to the end, and start rolling again, the effect of continuous loop scrolling appears.

The Code is as follows:


Php

Java

Ruby

Python

Www.phpddt.com

Script // speed setting var speed = 1; var colee2 = document. getElementById ("colee2"); var colee1 = document. getElementById ("colee1"); var colee = document. getElementById ("colee"); colee2.innerHTML = response; // clone colee1 to colee2function Marquee1 () {// if (colee2.offsetTop-cole2. scrollTop <= 0) {colee. scrollTop-= colee1.offsetHeight; // colee jump to the top} else {colee. scrollTop ++} var MyMar1 = setInterval (Marquee1, speed) // sets the timer. // when the mouse moves up, the timer is cleared to stop the scroll. onmouseover = function () {clearInterval (MyMar1)} // reset the timer colee when you move the mouse away. onmouseout = function () {MyMar1 = setInterval (Marquee1, speed)} script

As follows:

Related Article

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.