JS Motion Frame

Source: Internet
Author: User

I am also a rookie, from the Internet search for a long time, sealed equipment note a set of motion framework, to strengthen everyone's understanding of this, hope that many proposals.

GetId:function(elemid) {returndocument.getElementById (elemid); }, GetStyle:function(obj,attr) {returnObj.currentstyle?obj.currentstyle[attr]:getcomputedstyle (obj,false) [attr]; }, Startmove:function(obj,json,fnend) {/*OBJ represents a collection of properties that require the movement of the object JSON, such as {' width ': +, ' height ': the function of the fnend motion at the end of the */        var_this = This; Clearinterval (Obj.timer); //if the object has motion, clear the timer firstObj.timer= SetInterval (function(){            varEstop =true;//indicates the motion of the object             for(varattrinchJSON) {                varStart = 0; if(attr = = ' opacity ') {//if it is a property of transparencyStart = Math.Round (Math.floor (_this.getstyle (obj,attr) *100)); }Else{Start=parseint (_this.getstyle (obj,attr)); }                //if                if(Start! =Json[attr]) {Estop=false; }                //set the value of the speed                varSpeed = (json[attr]-start)/6//if it is greater than 0, take the whole upward, otherwise it will be rounded down;Speed > 0?Math.ceil (Speed): Math.floor (speed); //if the change in transparency                if(attr = = ' opacity ') {Obj.style.filter= ' Alpha (opacity: ' + (start + speed) + ') ';//Set IEObj.style.opacity = (start+ speed)/100; }Else{                    //This is the other property in addition to transparencyOBJ.STYLE[ATTR] = start + speed + ' px '; }            }            //clears the timer if the motion reaches the target point if estop = = True            if(estop) {clearinterval (Obj.timer); if(Fnend) fnend (); }        },30)    }

The above is my three methods of encapsulation:

Call the following

Elemmouse:function(){        var_this = This; varConphone = This. GetId (' Conphone ');  This. addevent (Conphone, ' mouseover ',function() {_this.startmove (conphone,{' Width ': $, ' height ': 500,},function() {alert (' End of movement ')            })        })         This. addevent (Conphone, ' mouseout ',function() {_this.startmove (conphone,{' Width ': +, ' height ': 50},function() {alert (' End of movement ')            })        })    }

JS 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.