Code example for implementing sliding door effects based on JavaScript

Source: Internet
Author: User
This article describes in detail the Code related to js sliding door effects, which has some reference value, interested friends can refer to the examples in this article to share with you the specific code of the sliding door effect for your reference. The specific content is as follows:

Sliding Door effect:

Principle:

There are four doors in total. Initially, the first door is opened, and the other three doors are closed, as shown in the first figure.
Assume that the image width is 120px, and the other three door Exposure width is 80px.
In the initial state,
The left distance of the second door is 120px,
The distance to the left of the third door is 200px,
The left distance of the fourth door is 280px.
When the second door opens,
The left distance of the second door is 80 px, which is (120-40) px.
The distance to the left of the third and fourth doors remains unchanged.
When the third door opens,
The left distance of the second door is 80 PX,
The left distance of the third door is 160px. (200-40) px
The fourth door remains unchanged

Therefore, when each door is opened, the image width minus the exposed width is the distance to move to the left. The third door opens. The second door needs to be moved first, and then the third door moves. The distance between each door is the image width minus the exposed width.

Program:

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.