JS Animation 3 Perfect Frame

Source: Internet
Author: User

JS Frame:
function GetStyle (obj,attr) {if (Obj.currentstyle) {return obj.currentstyle[attr];} Else{return getComputedStyle (Obj,false) [attr];}} function Startmove (OBJ,JSON,FN) {var flag = true;//assumes clearinterval (obj.timer); obj.timer = SetInterval (function () {for ( var attr in JSON) {//Fetch current value var icur = 0;if (attr = = ' opacity ') {icur = Math.Round (parsefloat (GetStyle (obj,attr)) *100);} Else{icur = parseint (GetStyle (obj,attr))}//calculate speed var = (json[attr]-icur)/8;speed = Tempo >0? Math.ceil: Math.floor (speed);//Detect Stop if (icur! = json[attr]) {flag = false;} if (attr = = ' opacity ') {obj.style.filter = ' alpha ' (opacity: ' + (icur +speed) + ') '; obj.style.opacity = (icur + speed)/100;} ELSE{OBJ.STYLE[ATTR] = icur + speed + ' px ';}} if (flag) {clearinterval (Obj.timer), if (FN) {fn ();}}},30)}

Chain Animation (the previous action is complete, the latter action continues):

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

Simultaneous animation (simultaneous completion of multiple actions):

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

JS Animation 3 Perfect 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.