Here I have a div in a right sidebar that supposed to act in this way:
1) When you scroll down the page and div reaches the top of the browser screen, it's class changes and it will get fixed on top of the screen untill you reach to the bottom of div's parent element.
2) Once the bottom of div reaches the bottom of parent element, it's class changes back to non-fixed position.
Here is the jsfiddle for you to play with http://jsfiddle.net/comparebest/z2Nyn/1/
Now to the problem:
For some reason in FireFox once div reaches the bottom of parent element, div disappears, while in Chrome, IE and Safari it stays visible.
You might need to make the size of your browser screen smaller in order to observe this behavior.
How can I prevent div from disappearing in FF?
P.S:
Heres the jQuery code:
function fixInParent(selector) {
var $el = $(selector);
$(window).scroll(function() {
if($el.parent().offset().top > $(this).scrollTop())
$el.addClass('top').removeClass('floating').removeClass('bottom');
else if ($(this).scrollTop() + $el.height() < $el.parent().offset().top + $el.parent().height())
$el.addClass('floating').removeClass('top').removeClass('bottom');
else
$el.addClass('bottom').removeClass('top').removeClass('floating');
});
}
$(document).ready(function() {
fixInParent('#floater');
});