Variable speed Dynamic Motion

Source: Internet
Author: User

function GetStyle (obj,name) {return Obj.currentstyle?obj.currentstyle[name]:getcomputedstyle (obj,false) [name];}; function Move (obj,json,options) {options=options| | {};options.time=options.time| | 700;options.type=options.type| | ' Ease-out '; var start={};var dis={};for (var name in JSON) {if (name== ' opacity ') {start[name]=parsefloat (GetStyle (obj, name));} Else{start[name]=parseint (GetStyle (Obj,name));} Dis[name]=json[name]-start[name];}; var count=math.round (OPTIONS.TIME/30), Var n=0;clearinterval (Obj.timer), Obj.timer=setinterval (function () {n++;for (   var name in JSON) {switch (options.type) {case ' linear '://constant speed var cur=start[name]+dis[name]*n/count;break;case ' ease-in ': Accelerated var a=n/count;var cur=start[name]+dis[name]*a*a*a;break;case ' ease-out '://deceleration var a=1-n/count;var cur=start[name] +dis[name]* (1-a*a*a); break;}}; if (name== ' opacity ') {obj.style.opacity=cur;obj.style.filter= ' alpha (opacity: ' +cur*100+ ') ';} else{obj.style[name]=cur+ ' px ';}; if (n==count) {clearinterval (Obj.timer); Options.fn&&options.fn ();}})} 

  

Variable speed Dynamic Motion

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.