Seamless image scrolling code (left/down/UP) _ javascript skills

Source: Internet
Author: User
We have noticed that marquee does not scroll cyclically, so there are many alternative scripts. Next we will introduce them in detail: scroll to the left. scroll to the left. Scroll down the image seamlessly. So there are a lot of alternative scripts, or iframe or JS output. No matter how you do it, it is a little troublesome. The following is a simple implementation concept: A container demo that sets the width and hides content beyond its width. demo1 and demo2 are included in the demo, and demo1 is the scrolling content, demo2 is a direct clone of demo1. By constantly changing the scrollTop or scrollLeft of demo1 to scroll, the original position is directly jumped back when rolling to the junction of demo1 and demo2 because demo1 is the same as demo2, therefore, we can't tell the beat moment to achieve the goal of "seamless" rolling.

Some modifications have been made based on the original author, mainly in the style above, replace the table with a label. And standardize JavaScript to run in all browsers.

First, let's take a look at several attributes of the object: innerHTML: set or obtain the HTML scrollHeight located in the start and end labels of the object: get the scroll height of the object.

ScrollLeft: sets or obtains the scrollTop distance between the left edge of the object and the leftmost end of the currently visible content in the window: set or get the scrollWidth between the top of the object and the top of the visible content in the window: get the scroll width of the object offsetHeight: obtain the height of an object relative to the layout or the height of the parent coordinate specified by the parent coordinate offsetParent attribute offsetLeft: Obtain the left position of the object relative to the layout or the parent coordinate specified by the offsetParent attribute offsetTop: obtains the top position of an object relative to the layout or the parent coordinate specified by the offsetTop attribute. offsetWidth: obtains the width of the object relative to the layout or the parent coordinate specified by the parent coordinate offsetParent attribute.

The Code is as follows:


Seamless Scrolling on Images

Scroll up











Script

Script
Seamless scrolling under images

Scroll down











Script

Script
Seamless left scrolling

Scroll left














Script

Script
Seamless Scrolling on the right

Scroll to the right














Script

Script

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.