CSS-Tricks / MovingBoxes

Simple horizontal slider which grows up the current box when it's in focus (image, title & text) and back down when it's not in focus.
http://css-tricks.github.io/MovingBoxes/
GNU Lesser General Public License v3.0
280 stars 147 forks source link

Centering the images in the area. #2

Closed gfe-morris closed 14 years ago

gfe-morris commented 14 years ago

I discovered that if you have smaller images and the imagesize of the smaller ones differs stronger from big ones you'll get problems with centering the images because there is a bug in calculating the center in the script. It calculates the center of the scroll and substracts the half of the small images instead of the big ones.

My fix looks like this: Around line 105 it looks like this: var leftValue = base.$el.find('.scroll').innerWidth() / 2 - panels.eq(curPanel-1).outerWidth() / 2; you have to replace it with this: var leftValue = base.$el.find('.scroll').innerWidth() / 2 - base.options.curImgWidth / 2;

Mottie commented 14 years ago

Fixed in the latest version.