Repository navigation
Expand file tree
/
Copy pathDHTMLanimate.html
More file actions
178 lines (171 loc) · 6.5 KB
/
Copy pathDHTMLanimate.html
File metadata and controls
178 lines (171 loc) · 6.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<html>
<head>
<title>Simultaneous MOVE demo</title>
<STYLE type="text/css">
<!--
#ver {position:absolute;left:100; top:0; width:100; height:90;clip:rect(0,100,90,0);layerbackground-color:thistle;background-color:thistle}
#hor {position:absolute;left:400; top:80; width:170; height:20;clip:rect(0,170,20,0);layerbackground-color:darkcyan;background-color:darkcyan}
#ff {position:absolute; left:0; top:30;}
#dia {position:absolute;left:-100;top:190;}
-->
</STYLE>
<script language="JavaScript">
/*
***********************MOVE Sequences Library*******************************
*
* Predefine Movement Sequences - then perform animation when you want it
*
* Free for all users, but leave in this header
* Author: Sally Ferreira, contact thru web site @
* www.stormloaders.com/4colors
*
* Setup: Encase move items in DIVs
* Enter move info into move_list array
* call move_init() upon page load
* call move_now(ix[,ix2 ..]) to activate animation(s)
* where ix = move_list index number(s)
*
* Place an array called move_list in your HTML and define your move sequences
* in string variables containing parameters in this order:
*
* div id name, Xstart, Xstop, Ystart, Ystop, Max pixels moved per Step,
* Speed in milliseconds, Reset flag (1= move back to 1st X,Y pos at move end)
*
* Ex: move_list = new Array()
* move_list[0] = "mydiv,-100,340,340,-100,5,30,0" (diagonal move)
* move_list[1] = "div3,400,40,10,10,14,70,0" (horizontal move)
* move_list[2] = "ss1,115,115,0,300,8,18,0" (vertical move)
* move_list[3] = "ss1,500,222,59,177,10,20,1" (freeform move + reset)
*
* ... onmouseover="move_now(3,1,0)"
*
***************************************************************************
*/
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;
}
/* ******************End MOVE Sequences Library******************************* */
//
</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>
</HEAD>
<BODY onload="move_init()" topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">
<table width=500><tr><td width=500 height=325> </td></tr>
<tr><td width=500 align=center>
Mouseover to <a href="#" onmouseover="move_now(0,3,2,1)">MOVE STUFF</a>
</td></tr></table>
<div id='dia'><img src=fly.gif width=41 height=39></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 size=6 color=khaki>hello..</font></div>
</BODY></HTML>