Animation with timers


In this lesson we are starting with creating a id of box with div, than we give properties of this box into style portion. Now here is our drawing of box is complete, after that what can we do with Java script if we want to move this box form left to right about 400 px. let see :

Code for move box left to right :

move left to right

Code for move box left to right and than right to left continuous :

There are some changes should me must to done code complete for run box continuous left to right and right to left. Very first we have to change moveBy value because when we move box left to right than we set value moveBy = +3px; + sign is a indication for moving box left to right . In same manner if we want to move box between right to left than we have to set - (negative)moveBy value. So we setting up here for left to tight and right to left value are : we can multiply moveBy value with -1 [moveBy * -1]. Because we need to move box left to right that time we need positive moveBy value and when we need to move box right to left than we need to negative value.

Note : offsetLeft method is use for margin from left, there is a same function available for margin from top is offsetTop.

move box both side

Wconcert India © 2015   ·   All Rights Reserved

Free Web Hosting