garand / sticky

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

How to change topSpacing when window resize #128

Open minhtranite opened 9 years ago

minhtranite commented 9 years ago

My code

$(document).ready(function(){
   var navigation = $('.region-navigation');
      if (navigation.length === 0) return;
      var toolbar = $('#toolbar');
      navigation.sticky({
        topSpacing: function () {
          return (toolbar.length === 0 || !toolbar.is(":visible")) ? 0 : toolbar.height();
        },
        getWidthFrom: $('body'),
        responsiveWidth: true
      });
      var timer;
      $(window).resize(function () {
        clearTimeout(timer);
        timer = setTimeout(function () {
          navigation.sticky('update');
        }, 200);
      });
});

but it don't work correct.

onigetoc commented 9 years ago

thank for this but what it's the #toolbar ?

your mobile menu?

max-ci commented 9 years ago

Great idea, but I can't apply this to bottomSpacing, any ideas?