garand / sticky

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

topSpacing based on element #174

Open wpexplorer opened 9 years ago

wpexplorer commented 9 years ago
topSpacing: $( '.my-element' ),

This would be very useful. Would need to update on re-size of course ;) Thanks for considering!

joncjordan commented 9 years ago

You can get the height of an element with jquery, then use that variable in your sticky function.

var elementHeight = $('#sticky-element-1').outerHeight();

$("#sticky-element-2").sticky({ topSpacing: elementHeight });

wpexplorer commented 9 years ago

Yes of course that can be done. But this is something that would be nice to have in the script itself.