Full version: jsB@nk » Misc » Simultaneous MOVE demo
URL: https://www.javascriptbank.com/simultaneousmove.html
The code will make the objects move when visitors move mouse over specified link.
Full version: jsB@nk » Misc » Simultaneous MOVE demo
URL: https://www.javascriptbank.com/simultaneousmove.html
<STYLE type=text/css>#ver {LEFT: 100px; WIDTH: 100px; CLIP: rect(0px 100px 90px 0px); POSITION: absolute; TOP: 0px; HEIGHT: 90px; BACKGROUND-COLOR: thistle; layerbackground-color: thistle}#hor {LEFT: 400px; WIDTH: 170px; CLIP: rect(0px 170px 20px 0px); POSITION: absolute; TOP: 80px; HEIGHT: 20px; BACKGROUND-COLOR: darkcyan; layerbackground-color: darkcyan}#ff {LEFT: 0px; POSITION: absolute; TOP: 30px}#dia {LEFT: -100px; POSITION: absolute; TOP: 190px}</STYLE><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->
<SCRIPT language=JavaScript type=text/javascript>function move_init() { mVobj = new Object() ; var brw , i //insure browser type is known 0=IE,1=NS4,2=NS6 if (document.all) brw = 0 else if (document.layers) brw = 1 else if (document.getElementById) brw = 2 else brw = 3 for (i=0; i< move_list.length; i++) move_item[i]=new makemVObj(i,brw) }function move_now() { var j var i = 0 ; while (i < move_now.arguments.length) { j= move_now.arguments[i] if (j < move_list.length){move_item[j].mVnow()} i++ }}move_item = new Array() ;function mVput() { this.ref.top=this.ys this.ref.left=this.xs }function mVnow() { if (this.status < 0) return //error? mVobj[this.mVid].mVput() //update position //end of move sequence? if (this.xs == this.xq && this.ys == this.yq){ this.xs = this.xreset; this.ys = this.yreset; if (this.status == 1) mVobj[this.mVid].mVput() //really should have time delay here return } //incr/decr positions - dont go too far this.xs += this.xi ; this.ys += this.yi if (this.xi < 0) {if (this.xs < this.xq) this.xs = this.xq} else if (this.xi > 0) {if (this.xs > this.xq) this.xs = this.xq} if (this.yi < 0) {if (this.ys < this.yq) this.ys = this.yq} else if (this.yi > 0) {if (this.ys > this.yq) this.ys = this.yq} setTimeout('mVobj["'+ this.mVid + '"].mVnow()',this.speed) } function mVrange(first,last){ var range, negl//check for large negative numbers which affect timing if (first < 0) {neg1 = first * -1 ; first = 0} else neg1 = 0 if (last < 0) {neg1 += (last * -1) ; last = 0} if (first < last) range = last - first else range = first - last range += neg1 return range }/* * register move sequence - make move_list item an object * which points to (divid,xstart,xstop,ystart,ystop,step,speed,reset)*/function makemVObj(which,bw){ var xr, yr, xdir, ydir,z1, zx, zy, i var error = 0// p/u parms, error check, set defaults var p = new Array(0,0,0,0,0,5,20,0) var parms=move_list[which].split(",") var divid = "" + parms[0] for (i=1; i< parms.length ;i++){ p[i] = parseInt(parms[i],10) } if (p[1] < 0 && p[2] < 0) error = 1 // from/to both negative? if (p[3] < 0 && p[4] < 0) error = 1 if (p[5] < 0) p[5] *= -1 //insure positive step value if (p[5] == 0) p[5] = 1 //no endless loops if (p[6] < 0) p[6] *= -1 //insure positive delay value this.xreset = p[1] //reset for x this.yreset = p[3] //reset for y this.status = p[7] //reset desired?// get move range sizes, determine step directions// try to decrease step size for shorter move leg xr = mVrange(p[1],p[2]) ; xy = mVrange(p[3],p[4]) if (p[2] < p[1]) xdir = -1 else xdir = 1 if (p[4] < p[3]) ydir = -1 else ydir = 1 zx = zy = p[5] if (yr > xr) {z1 = Math.round(yr/zx); zx=Math.round(xr/z1)} else if (xr > yr) { z1 = Math.round(xr/zy); zy=Math.round(yr/z1)}//bw is browser type - 0=IE, 1=NS4, 2=NS6 if (bw == 0) this.ref=document.all[divid].style else if (bw == 1) this.ref=document[divid] else if (bw == 2) this.ref=document.getElementById(divid).style else error = 1 this.xs = p[1] //xstart this.xq = p[2] //xstop this.xi = zx * xdir //xstep this.ys = p[3] //ystart this.yq = p[4] //ystop this.yi = zy * ydir //ystep this.speed = p[6] //delay time this.mVid = which //identify by index if (error != 0) this.status = -1 //dont process this one this.mVput = mVput this.mVnow = mVnow mVobj[which] = this; }</SCRIPT><SCRIPT language=JavaScript><!--//// list= " divId, xStart, xStop, yStart, yStop, stepPx, Speed, reset sw "// move_list = new Array() move_list[0] = "dia,-100,190,190,-100,2,60,0" move_list[1] = "hor,400,158,80,80,4,70,0" move_list[2] = "ver,100,100,0,90,3,150,0" move_list[3] = "ff,500,122,59,177,2,10,1" //--></SCRIPT><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->
<BODY onload=move_init()>Mouseover to <A onmouseover=move_now(0,3,2,1) href="http://javascriptbank.com">MOVE STUFF</A><DIV id=dia><IMG height=39 src="fly.gif" width=41></DIV><DIV id=ver><FONT size=2>Vertical<BR>MOVE</FONT></DIV><DIV id=hor><FONT size=2>Horizontal MOVE</FONT></DIV><DIV id=ff><FONT color=khaki size=6>hello..</FONT></DIV><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->
http://javascriptbank.com/javascript/misc/fly.gif