garand / sticky

jQuery Plugin for Sticky Objects
Other
3.3k stars 1.06k forks source link

Change order of getWidthFrom calculation to prevent innaccurate widths #144

Open dpedu opened 9 years ago

dpedu commented 9 years ago

This is to fix inaccurate widths being applied from getWidthFrom, under specific conditions:

Under these conditions, when the sticky element is changed to position:fixed, it's width becomes equal to the width of the container + left/right padding on the container (due to border-box). This can lead to unexpected widths being applied to the stick element. Calculating the width from getWidthFrom before setting position:fixed fixes this issue.

duzun commented 9 years ago

I think commit a429b78f from PR #148 addresses this issue. In that commit the width is applied exactly once, at once with position: fixed.