sticky-kit icon indicating copy to clipboard operation
sticky-kit copied to clipboard

Accept a function for offset_top

Open maimairel opened this issue 7 years ago • 2 comments

Currently the offset_top option can only be set upon initialization. Is there anyway to update the offset_top value without detaching the plugin first? Perhaps by accepting a function for the offset_top option.

Thanks!

maimairel avatar Jun 07 '17 21:06 maimairel

See this example:

jQuery(document).ready(function(){ var window_width = jQuery( window ).width();

if (window_width < 960) { jQuery("#sticky").trigger("sticky_kit:detach"); } else { make_sticky(); }

jQuery( window ).resize(function() { window_width = jQuery( window ).width(); if (window_width < 960) { jQuery("#sticky").trigger("sticky_kit:detach"); } else { make_sticky(); } });

function make_sticky() { jQuery("#sticky").stick_in_parent({ offset_top: 100, parent: '#row-content .wrapcent' }); } });

IvanPr avatar Jul 26 '17 11:07 IvanPr

i also look for an easy event function to update offset_top!

nicmare avatar Nov 01 '17 08:11 nicmare