Using Sticky Kit jQuery plugin, but can't figure out how to use the 'offset_top' option?

StephenMeehan picture StephenMeehan · Oct 6, 2013 · Viewed 11.6k times · Source

Has anyone had any experience using the excellent Sticky Kit jQuery plugin? http://leafo.net/sticky-kit/

I can't figure out how to use the 'offset_top' option? The documentation for the options is a bit vague, the example shown is below:

$("#sticky_item").stick_in_parent(options)

I guess I have to write something like this:

$("#sticky_item").stick_in_parent(offset_top)

But how do I specify the number of pixels I want to offset #sticky_item by?

Any help would be greatly appreciated!

Answer

StephenMeehan picture StephenMeehan · Oct 7, 2013

Ah, figured it out.

To add a 20 pixel offset to #sticky_item do this:

$("#primary").stick_in_parent({offset_top: 20});