#1066 enhancement
Michael Morris


Reported by Michael Morris | May 28th, 2010 @ 09:01 PM

I don't have Ruby or know much about it, and from I understand of the documents Ruby is needed to directly submit code.. Anyway, I have a center function I use frequently enough I'd like to submit for consideration for core inclusion. It simply moves an element to the computed center of the viewport.

center: function ( element ) {

return $(element).absolutize().setStyle({
    position: 'absolute', 
        top: Math.floor(document.viewport.getHeight() / 2 + document.viewport.getScrollOffsets().top - element.getDimensions().height / 2) + 'px', 
        left: Math.floor(document.viewport.getWidth() / 2 + document.viewport.getScrollOffsets().left - element.getDimensions().width / 2) + 'px' 

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Prototype JavaScript library.

Shared Ticket Bins