Download the X Distribution File.
xParaEq(ele, xExpr, yExpr, totalTime)
// xParaEq r4, Copyright 2004-2007 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL // Animation with Parametric Equations function xParaEq(e, xExpr, yExpr, totalTime) { if (!(e=xGetElementById(e))) return; e.t = 0; e.tStep = .008; if (!e.timeout) e.timeout = 25; e.xExpr = xExpr; e.yExpr = yExpr; e.slideTime = totalTime; var d = new Date(); e.C = d.getTime(); if (!e.moving) {e.stop=false; _xParaEq(e);} } function _xParaEq(e) { if (!(e=xGetElementById(e))) return; var now = new Date(); var et = now.getTime() - e.C; e.t += e.tStep; t = e.t; if (e.stop) { e.moving = false; } else if (!e.slideTime || et < e.slideTime) { setTimeout("_xParaEq('"+e.id+"')", e.timeout); var p = e.offsetParent, centerX, centerY; centerX = (xWidth(p)/2)-(xWidth(e)/2); centerY = (xHeight(p)/2)-(xHeight(e)/2); e.xTarget = Math.round((eval(e.xExpr) * centerX) + centerX) + xScrollLeft(p); e.yTarget = Math.round((eval(e.yExpr) * centerY) + centerY) + xScrollTop(p); xMoveTo(e, e.xTarget, e.yTarget); e.moving = true; } else { e.moving = false; if (e.onslideend) e.onslideend(); } }
xparaeq - xParaEq demo
By your use of X and/or CBE and/or any Javascript from this site you consent to the GNU LGPL - please read it. If you have any questions about the license, read the FAQ and/or come to the forums.
Forum support is available at the X Library Support Forums.
Cross-Browser.com is the home of X - a cross-browser Javascript library, and many demos, applications, articles and documentation.
If you are using X, XC or anything from this site, show off your work by posting a link in the X Showcase forum.