On 1/24/07, Matthew Kwiecien <[EMAIL PROTECTED]> wrote:
> I didn't really look at your code, but here's the function I've been using
> to center an element:
>
> function centerElement(obj){
> var vpDim = getViewportDimensions();
> var elemDim = getElementDimensions(obj);
> setElementPosition(obj, {'x':((vpDim.w -elemDim.w)/2),'y':((vpDim.h -
> elemDim.h)/2)});
> }
Related to this. I have before proposed adding operations to add and
subtract two dimension and/or coordinate objects, as well as multiply
by factor etc. The last line in the above would be reduced to
setElementPosition(obj, vpDim.sub(elemDim).mult(0.5));
I'd be happy to write this a patch for such a thing if people feel it
would be a useful addition..
Arnar
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---