|
From: Henrik V. <hv...@ya...> - 2001-02-09 22:08:46
|
I'm developing a custom extension to the dynlayer object that positions =
against another named dynlayer. I got that part working statically, but =
now for it to be useful I need to a listener that let the dynlayer =
follow its counterpartner. How do I go about to create the required =
listener for scroll, move and resize events? Anybody got a good example, =
something to point to or any suggestion?
This is my current listener code:
****
DynLayer.prototype.positionAtLyr=3Dfunction(othLyr,pos,marginX,marginY,sl=
ide,slideBy,slideSpeed) {
this.doPos =3D function() { =
eval(this+".positionAtLyr("+othLyr+",'"+pos+"',"+marginX+","+marginY+","+=
slide+","+slideBy+","+slideSpeed+")") };=20
this.getPosAtLyr(othLyr,pos,marginX,marginY)
if (slide) {
if (!slideBy) slideBy =3D 10;
if (!slideSpeed) slideSpeed =3D 20;
this.slideTo(posX,posY,slideBy,slideSpeed)
} else {
this.moveTo(posX,posY);
}
}
DynLayer.prototype.setPersistPos =3D function(b) {
this.persistPos=3Db
if (b=3D=3Dfalse) {
this.posListener =3D new EventListener(this.parent);
this.posListener.onmove =3D function(e) {
this.doPos();=20
};
this.addEventListener(this.posListener);
}
else {
this.removeEventListener(this.posListener);
}
};
***
DynLayer.prototype.getPosAtLyr() which isn't included here, is what =
calculates and returns variables PosX and PosY (in case you wondered). =
doPos() is a function to rerun the same function again (ie calculate but =
with the new values and then move the layer there).=20
my example code has the following in the page DynAPI.onload fumction:
***
myOtherLayer =3D new DynLayer();
myOtherLayer.setSize(100,100);
myOtherLayer.setBgColor('lightgrey');
DynAPI.document.addChild(myOtherLayer);
myOtherLayer.positionAtLyr(myLayer,'middleleft',12,12);
myOtherLayer.setPersistPos(true);
***
myLayer is of course the layer to position against.
I'd be most grateful if anybody could help me solve this one...
Henrik V=E5glin [ hv...@ya... ]
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
|