2015.8.2js-19 (Perfect motion frame)

Source: Internet
Author: User

1 /*Perfect Motion Frame*/2 //1. Clear the Set period, 2, get the style, if it is opacity alone, 3, define the speed, 4, define whether the current value to reach the destination, 5, determine whether the current value to reach the destination, 6 movement basic, if it is opacity3 function startmove(obj,json,fnend) {4  clearinterval(obj.timer);5Obj.timer =setinterval(function(){6         varBstop =true; //Assuming all properties reach the target value 7          for(attrinchJSON) { //multivalued motion in JSON form 8             varCur = 0;9             if(attr== "Opacity") { //transparency Special handling TenCur=math.round (parsefloat (GetStyle (obj, attr)) *100); One}Else{ ACur =parseint (GetStyle (obj,attr)); -             } -  the             varSpeed = (json[attr]-cur)/6;//define Speed -Speed = speed > 0?Math.ceil (Speed): Math.floor (speed); //Buffer motion rounding  -  -             if(cur! = Json[attr]) { //If the values do not reach the target value, continue the motion  +Bstop =false; -             } +             if(attr = = "Opacity") { //transparency Special handling  AObj.style.filter= ' alpha (opacity: ' + (cur+speed) + ') '; atobj.style.opacity= (cur+speed)/100; -}Else{ -OBJ.STYLE[ATTR] = cur+speed + "px"; -             } -         } -         if(bstop) { in clearinterval (Obj.timer); //If the values reach the target, stop the timer  -             if(fnend) { //callback function, chain-motion  to fnend (); +             } -         } the},math.round (1000/60)); *}

2015.8.2js-19 (Perfect motion frame)

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.