[JavaScript] Great timeline UI controls (pure JavaScript, cross-browser, comparable to Flash animations)

Source: Internet
Author: User
Tags comparable difference between two times

Portal

 

Time training is achieved by calculating the difference between two times and the length of the entire timeline.

 
Locatehandler = function () {var refertime = (that [that. length]-That [0])/86400000, I = 0, Len = That. handler. length, temp = 0; For (; I <Len;) {temp = (that [I]-That [0])/(refertime * 86400000) * That. parent. offsetwidth; that. FX (that. handler [I], 'left', (I = len-1 | I = 0 )? Temp-20: temp), 50); I ++ ;}

In order to reduce the number of computations, you can store the graphic panel, time point, and time location information during operations, so that you can compute and store the information during operations, the second operation reads the cache location information. Set the position directly with CSS to reduce the calculation workload

 
Cache = [[], [], []

There is only one set of information during initialization.

 

After touching two time points, the location data has been cached.

 

If (! Indicator. cache [1] [Index]) {If (rect. left-Div. offsetwidth/2) <limit. left) {indicator. cache [1] [Index] = 'visibility: visible; left: 0px; ';} else if (rect. left + Div. offsetwidth/2)> limit. right) {indicator. cache [1] [Index] = 'visibility: visible; left: '+ (limit. right-Div. offsetwidth-limit. left) + 'px; ';} else {indicator. cache [1] [Index] = 'visibility: visible; left: '+ (rect. left-Div. offsetwidth/2-limit. left) + 'px ;';}}

The position of the graphic panel is also obtained through intelligent computing. If the left side is exceeded, it is left aligned. In other cases, the time point is referenced in the center, and the right side is exceeded.

Some of the animations use tweenAlgorithmYou can modify it by yourself.

 

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.