straydogstudio / film_roll

A lightweight jQuery carousel that centers one item at a time on the page.
MIT License
207 stars 60 forks source link

Prevent child divs from receiving new widths #8

Closed omundy closed 10 years ago

omundy commented 10 years ago

Hi, thanks for creating this. It's exactly what I need. I do have one problem and looking through the documentation and source isn't helping me figure out how to fix it: All the child divs of .film_roll are receiving new style attributes setting the width of the div to 354px. Here's an example.

<div class="program film_roll_child" data-film-roll-child-id="7" style="width: 354px;"> ... (image and text) ... </div>

I attempted to turn off default CSS with no_css: true and to restyle the divs (but of course the local style attribute overrides my CSS). Thanks.

omundy commented 10 years ago

Update: I realize now the width attribute is necessary to figure out scrolling distances and that it is probably computed dynamically using padding and contents of the div itself. I was able to alter my own styling to accommodate the way that new widths are computed and assigned and remedy my problem. Thanks.

straydogstudio commented 10 years ago

I will add more about this process to the documentation. In short, the plugin measures the widths of all elements before the surrounding div's are expanded for shuttling back and forth. Knowing this, you can ensure all elements are styled the way you want before the plugin is applied. When the window is resized it does this again, removing the expanded div and measuring the child element widths. As you guessed, it uses that width to position everything, so it has to apply it to the content.

It is difficult if all elements have different heights, but it is still possible to make it work. I have a solution in place that uses the first image to configure the size of all other elements. It uses some of the event triggers in FilmRoll. I also have responsive image solutions in the works. I will post this at some point. Let me know if you are interested and I'll bump this thread when it is up.