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

Re-initialize with updating the sizes #99

Open beshur opened 11 years ago

beshur commented 11 years ago

Hello.

Is there any way to re-initialize the slider and update the slides sizes?

Mottie commented 11 years ago

Well, it's not really documented, but you can set stored width (or update the width option, which is deprecated) before updating

var slider = $('#slider');
// set a new movingboxes width
slider.data('movingBoxes').width = 300;
// update MovingBoxes
slider.movingBoxes();
beshur commented 11 years ago

Thank you for reply, Mottie,but that is not what I meant, sorry.

I mean when there is a slider in the display:none div, for example and when the div is revealed its height is expectedly 0.

Is there a way around this with a MovingBoxes script? Thanks. // I know that I can hide the div with position: absolute; visibility: hidden;, initialize the slider and then hide it completely.

beshur commented 11 years ago

Ok, when the slider is display:none (or in a parent with such style), it does not tell any data, and also is not accepting methods from outside.

May be handy: I just wrap the slider in a overflow: hidden; height: 0; container when I need to hide it yet need it accessible.