Open ebillias opened 11 years ago
The marginTop property can be a function as well; kind of like the limit property. That will be run for each scroll event. Maybe you can test for the scroll position in that function, then return the scrollTop when it meets your criteria. I have not tried this yet, but I will give it a try when I get a chance in a fiddle.
Best of luck and I hope that helps.
I also trying to accomplish this. Anyone has a concrete idea on how to do it? Thank you.
I recently had this same need and was able to use the marginTop function to accomplish it. Fiddle: http://jsfiddle.net/jenpapa/by7uetvy/1/
$(document).ready(function() {
$('#cart').scrollToFixed({
marginTop: function() {
var fix_at_me_top = $('#fix_at_me').offset().top;
var scrollpos = $(window).scrollTop();
if (fix_at_me_top <= scrollpos) {
return 0;
}
}
});
});
was wondering if I could delay the header from attaching to the window until the user has scrolled say 100px, maybe something to do with scrollTop > 100 ?? not sure how to add this condition to scrollToFixed function