leafo/sticky-kit — pull request #44 by eusonic (2014-03-31 19:54:27+00:00)
Title: Floated elements with relative positioning

Since https://github.com/leafo/sticky-kit/commit/72350acb534927430fe86aa668f4be4fab82e3c1 the css position value of the sticky element is being applied to the spacer div. This causes problems if the sticky element has a position of 'relative' and is floated.

Demo: http://jsfiddle.net/eusonic/j5LHW/1/

When the sticky element bottoms out and is given `position: absolute; bottom: 0px;` it will be positioned relative to the spacer div, when it should be positioned relative to its original container. This causes the sticky element to suddenly jump up to its original position when you reach the bottom of the scrolling area.

The problem only occurs when the sticky element is floated because otherwise it isn't inside of the spacer div.

My proposed fix is to only apply the sticky element's position value to the spacer if it is absolute. Consider the possible position values:

* **Static:** This is the default, so there's no need to apply it to the spacer.
* **Relative:** This creates the problem described above. I can't think of a situation where the spacer div would need relative positioning.
* **Absolute:** This should be applied to the spacer div.
* **Fixed:** If someone has added fixed positioning to a sticky element they clearly don't understand what Sticky-Kit does.