home *** CD-ROM | disk | FTP | other *** search
- <PUBLIC:COMPONENT lightWeight=true>
-
- <PUBLIC:EVENT name="onslidedone" ID=done>
-
- <PUBLIC:PROPERTY NAME="direction" />
- <PUBLIC:PROPERTY NAME="steps" />
- <PUBLIC:PROPERTY NAME="maxtime" />
- <PUBLIC:PROPERTY NAME="source" />
- <PUBLIC:PROPERTY NAME="sourceBG" />
- <PUBLIC:PROPERTY NAME="destination" />
- <PUBLIC:PROPERTY NAME="destinationBG" />
- <PUBLIC:PROPERTY NAME="endPoint" />
- <PUBLIC:PROPERTY NAME="sliding" />
-
- <PUBLIC:METHOD NAME="slide" />
- <PUBLIC:METHOD NAME="Stop" />
-
- <SCRIPT LANGUAGE="JScript">
- var iEnd, iTimer;
- sliding = false;
-
- var iStartTime, iEndTime, iStepsToDo, iStepsSoFar, iStepTime, iStepDistance, iStepsDone;
-
- function slide()
- {
- var dStart = new Date();
- iStartTime = dStart.getTime();
- iEndTime = iStartTime + parseInt(maxtime);
- iStepsToDo = parseInt(steps);
- iStepsDone = 0;
- iStepTime = parseInt(maxtime) / iStepsToDo;
- iEnd = parseInt(endPoint);
-
- sliding = true;
- iSpeed = 0;
- if (parseInt(direction) < 2)
- shimmyLeft();
- else
- shimmyUp();
- }
-
-
- function fireDone()
- {
- sliding = false;
- var e = createEventObject();
- done.fire(e);
- }
-
- function CalcSpeed(iSpeed, iRange, iSteps)
- {
- if (iSpeed == 0)
- return iRange / iSteps;
- else
- {
- var dNow = new Date();
- var iNow = dNow.getTime(), iElapsed, iRet;
- iElapsed = (iNow - iStartTime) / iStepTime;
-
- iRet = (iRange / iSteps) * ((iElapsed - iStepsDone) + 1);
- return iRet;
- }
- }
-
- function shimmyLeft()
- {
- var iAdjust, ssty = source.style;
- if (ssty.posLeft != iEnd)
- {
- iSpeed = CalcSpeed(iSpeed, element.document.body.clientWidth, iStepsToDo);
- iStepsDone++;
-
- if (direction == 1)
- {
- if (ssty.posLeft - iSpeed < iEnd)
- iSpeed = ssty.posLeft - iEnd;
-
- iSpeed = -iSpeed;
- }
- else
- {
- if (ssty.posLeft + iSpeed > iEnd)
- iSpeed = iEnd - ssty.posLeft;
- }
-
- ssty.posLeft += iSpeed;
- sourceBG.style.posLeft += iSpeed;
- destination.style.posLeft += iSpeed;
-
- iTimer = window.setTimeout(shimmyLeft, iStepTime);
- }
- else
- fireDone();
- }
-
- function shimmyUp()
- {
- var iAdjust, ssty = source.style;
- if (ssty.posTop != iEnd)
- {
- iSpeed = CalcSpeed(iSpeed, element.document.body.clientHeight, iStepsToDo);
- iStepsDone++;
-
- if (direction == 3)
- {
- if (ssty.posTop - iSpeed < iEnd)
- iSpeed = ssty.posTop - iEnd;
-
- iSpeed = -iSpeed;
- }
- else
- {
- if (ssty.posTop + iSpeed > iEnd)
- iSpeed = iEnd - ssty.posTop;
- }
-
- ssty.posTop += iSpeed;
- sourceBG.style.posTop += iSpeed;
- destination.style.posTop += iSpeed;
- destinationBG.style.posTop += iSpeed;
-
- iTimer = window.setTimeout(shimmyUp, iStepTime);
- }
- else
- fireDone();
- }
-
- function Stop()
- {
- if (sliding)
- {
- var sty = source.style, iAdjust;
- window.clearTimeout(iTimer);
-
- if (parseInt(direction) < 2)
- {
- iAdjust = sty.posLeft - iEnd;
- sty.posLeft = iEnd;
- sourceBG.style.posLeft += iAdjust;
- }
- else
- {
- iAdjust = sty.posTop - iEnd;
- sty.posTop = iEnd;
- sourceBG.style.posTop += iAdjust;
- }
- fireDone();
- }
- }
- </SCRIPT>
- </PUBLIC:COMPONENT>
-