1 |
joko |
1.1 |
/* cbe_slide2.js $Revision: 0.11 $ |
2 |
|
|
* CBE v4.19, Cross-Browser DHTML API from Cross-Browser.com |
3 |
|
|
* Copyright (c) 2002 Michael Foster (mike@cross-browser.com) |
4 |
|
|
* Distributed under the terms of the GNU LGPL from gnu.org |
5 |
|
|
*/ |
6 |
|
|
CrossBrowserElement.prototype.slideCornerBy = function(corner, dX, dY, totalTime, endListener) { |
7 |
|
|
var targetX, targetY; |
8 |
|
|
dX = parseInt(dX); |
9 |
|
|
dY = parseInt(dY); |
10 |
|
|
switch(corner.toLowerCase()) { |
11 |
|
|
case 'nw': targetX = this.left() + dX; targetY = this.top() + dY; break; |
12 |
|
|
case 'sw': targetX = this.left() + dX; targetY = this.top() + this.height() + dY; break; |
13 |
|
|
case 'ne': targetX = this.left() + this.width() + dX; targetY = this.top() + dY; break; |
14 |
|
|
case 'se': targetX = this.left() + this.width() + dX; targetY = this.top() + this.height() + dY; break; |
15 |
|
|
default: alert("CBE: Invalid corner"); return; |
16 |
|
|
} |
17 |
|
|
this.slideCornerTo(corner, targetX, targetY, totalTime, endListener) |
18 |
|
|
} |
19 |
|
|
CrossBrowserElement.prototype.slideCornerTo = function(corner, targetX, targetY, totalTime, endListener) { |
20 |
|
|
if (this.onslidestart) cbeEval(this.onslidestart, this); |
21 |
|
|
this.xTarget = parseInt(targetX); |
22 |
|
|
this.yTarget = parseInt(targetY); |
23 |
|
|
this.slideTime = parseInt(totalTime); |
24 |
|
|
this.corner = corner.toLowerCase(); |
25 |
|
|
if (endListener) { |
26 |
|
|
this.autoRemoveListener = true; |
27 |
|
|
this.addEventListener('slideend', endListener); |
28 |
|
|
} |
29 |
|
|
this.stop = false; |
30 |
|
|
switch(this.corner) { |
31 |
|
|
case 'nw': this.xA = this.xTarget - this.left(); this.yA = this.yTarget - this.top(); this.xD = this.left(); this.yD = this.top(); break; |
32 |
|
|
case 'sw': this.xA = this.xTarget - this.left(); this.yA = this.yTarget - (this.top() + this.height()); this.xD = this.left(); this.yD = this.top() + this.height(); break; |
33 |
|
|
case 'ne': this.xA = this.xTarget - (this.left() + this.width()); this.yA = this.yTarget - this.top(); this.xD = this.left() + this.width(); this.yD = this.top(); break; |
34 |
|
|
case 'se': this.xA = this.xTarget - (this.left() + this.width()); this.yA = this.yTarget - (this.top() + this.height()); this.xD = this.left() + this.width(); this.yD = this.top() + this.height(); break; |
35 |
|
|
default: alert("CBE: Invalid corner"); return; |
36 |
|
|
} |
37 |
|
|
this.B = Math.PI / ( 2 * this.slideTime ); |
38 |
|
|
var d = new Date( ) |
39 |
|
|
this.C = d.getTime(); |
40 |
|
|
if (!this.moving) this.slideCorner(); |
41 |
|
|
} |
42 |
|
|
CrossBrowserElement.prototype.slideCorner = function() { |
43 |
|
|
var now, seX, seY; |
44 |
|
|
now = new Date(); |
45 |
|
|
t = now.getTime() - this.C; |
46 |
|
|
if (this.stop) { this.moving = false; this.stop = false; return; } |
47 |
|
|
else if (t < this.slideTime) { |
48 |
|
|
setTimeout("window.cbeAll["+this.index+"].slideCorner()", this.timeout); |
49 |
|
|
s = Math.sin( this.B * t ); |
50 |
|
|
newX = Math.round(this.xA * s + this.xD); |
51 |
|
|
newY = Math.round(this.yA * s + this.yD); |
52 |
|
|
if (this.onslide) cbeEval(this.onslide, this, newX, newY, t); |
53 |
|
|
} |
54 |
|
|
else { newX = this.xTarget; newY = this.yTarget; } |
55 |
|
|
seX = this.left() + this.width(); |
56 |
|
|
seY = this.top() + this.height(); |
57 |
|
|
switch(this.corner) { |
58 |
|
|
case 'nw': this.moveTo(newX, newY); this.sizeTo(seX - this.left(), seY - this.top()); break; |
59 |
|
|
case 'sw': if (this.xTarget != this.left()) { this.left(newX); this.width(seX - this.left()); } this.height(newY - this.top()); break; |
60 |
|
|
case 'ne': this.width(newX - this.left()); if (this.yTarget != this.top()) { this.top(newY); this.height(seY - this.top()); } break; |
61 |
|
|
case 'se': this.width(newX - this.left()); this.height(newY - this.top()); break; |
62 |
|
|
default: this.stop = true; |
63 |
|
|
} |
64 |
|
|
this.clip('auto'); |
65 |
|
|
this.moving = true; |
66 |
|
|
if (t >= this.slideTime) { |
67 |
|
|
this.moving = false; |
68 |
|
|
if (this.onslideend) { |
69 |
|
|
var tmp = this.onslideend; |
70 |
|
|
if (this.autoRemoveListener) { |
71 |
|
|
this.autoRemoveListener = false; |
72 |
|
|
this.removeEventListener('slideend'); |
73 |
|
|
} |
74 |
|
|
cbeEval(tmp, this); |
75 |
|
|
} |
76 |
|
|
} |
77 |
|
|
} |
78 |
|
|
CrossBrowserElement.prototype.parametricEquation = function(exprX, exprY, totalTime, endListener) { |
79 |
|
|
if (this.onslidestart) cbeEval(this.onslidestart, this); |
80 |
|
|
this.t = 0; |
81 |
|
|
this.stop = false; |
82 |
|
|
this.exprX = exprX; |
83 |
|
|
this.exprY = exprY; |
84 |
|
|
if (endListener && window.cbeEventJsLoaded) { |
85 |
|
|
this.autoRemoveListener = true; |
86 |
|
|
this.addEventListener('slideend', endListener); |
87 |
|
|
} |
88 |
|
|
this.slideTime = parseInt(totalTime); |
89 |
|
|
var d = new Date( ) |
90 |
|
|
this.C = d.getTime(); |
91 |
|
|
if (!this.moving) this.parametricEquation1(); |
92 |
|
|
} |
93 |
|
|
CrossBrowserElement.prototype.parametricEquation1 = function() { |
94 |
|
|
var now = new Date(); |
95 |
|
|
var et = now.getTime() - this.C; |
96 |
|
|
this.t += this.tStep; |
97 |
|
|
t = this.t; |
98 |
|
|
if (this.stop) { this.moving = false; } |
99 |
|
|
else if (!this.slideTime || et < this.slideTime) { |
100 |
|
|
setTimeout("window.cbeAll["+this.index+"].parametricEquation1()", this.timeout); |
101 |
|
|
var centerX = (this.parentNode.width()/2)-(this.width()/2); |
102 |
|
|
var centerY = (this.parentNode.height()/2)-(this.height()/2); |
103 |
|
|
this.xTarget = Math.round((eval(this.exprX) * centerX) + centerX) + this.parentNode.scrollLeft(); |
104 |
|
|
this.yTarget = Math.round((eval(this.exprY) * centerY) + centerY) + this.parentNode.scrollTop(); |
105 |
|
|
if (this.onslide) cbeEval(this.onslide, this, this.xTarget, this.yTarget, et); |
106 |
|
|
this.moveTo(this.xTarget, this.yTarget); |
107 |
|
|
this.moving = true; |
108 |
|
|
} |
109 |
|
|
else { |
110 |
|
|
this.moving = false; |
111 |
|
|
if (this.onslideend) { |
112 |
|
|
var tmp = this.onslideend; |
113 |
|
|
if (this.autoRemoveListener && window.cbeEventJsLoaded) { |
114 |
|
|
this.autoRemoveListener = false; |
115 |
|
|
this.removeEventListener('slideend'); |
116 |
|
|
} |
117 |
|
|
cbeEval(tmp, this); |
118 |
|
|
} |
119 |
|
|
} |
120 |
|
|
} |
121 |
|
|
var cbeSlideRateLinear=0, cbeSlideRateSine=1, cbeSlideRateCosine=2; |
122 |
|
|
CrossBrowserElement.prototype.slideRate = cbeSlideRateSine; |
123 |
|
|
CrossBrowserElement.prototype.tStep = .008; |
124 |
|
|
CrossBrowserElement.prototype.exprX = ""; |
125 |
|
|
CrossBrowserElement.prototype.exprY = ""; |
126 |
|
|
CrossBrowserElement.prototype.corner = ""; |
127 |
|
|
CrossBrowserElement.prototype.xTarget = 0; |
128 |
|
|
CrossBrowserElement.prototype.yTarget = 0; |
129 |
|
|
CrossBrowserElement.prototype.slideTime = 1000; |
130 |
|
|
CrossBrowserElement.prototype.xA = 0; |
131 |
|
|
CrossBrowserElement.prototype.yA = 0; |
132 |
|
|
CrossBrowserElement.prototype.xD = 0; |
133 |
|
|
CrossBrowserElement.prototype.yD = 0; |
134 |
|
|
CrossBrowserElement.prototype.B = 0; |
135 |
|
|
CrossBrowserElement.prototype.C = 0; |
136 |
|
|
CrossBrowserElement.prototype.moving = false; |
137 |
|
|
CrossBrowserElement.prototype.stop = true; |
138 |
|
|
CrossBrowserElement.prototype.timeout = 35; |
139 |
|
|
CrossBrowserElement.prototype.autoRemoveListener = false; |
140 |
|
|
CrossBrowserElement.prototype.onslidestart = null; |
141 |
|
|
CrossBrowserElement.prototype.onslide = null; |
142 |
|
|
CrossBrowserElement.prototype.onslideend = null; |
143 |
|
|
var cbeSlide2JsLoaded = true; |
144 |
|
|
// End cbe_slide2.js |