This project is archived and is in readonly mode.

#538 open

toElementCenter scrolls to incorrect position

Reported by woomla | March 8th, 2011 @ 10:28 AM


When the container element's scroll position (vertical) is not zero, toElementCenter scrolls to an incorrect position. This is visible when you scroll to a certain element twice. The first time the containter scrolls so the element is in the center, the next time the container element is scrolled to the top (y < 0).

A little research showed that the current scroll position should be added to the equation:

to[axis] = scroll[axis] + position[axis] - (containerSize[axis] - size[axis]) / 2;

Fiddle showing problem and solution:

Comments and changes to this ticket

Create your profile

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

The MooTools Extensions

People watching this ticket