Показать сообщение отдельно
  #39 (permalink)  
Старый 28.01.2016, 19:23
Аватар для рони
Профессор
Отправить личное сообщение для рони Посмотреть профиль Найти все сообщения от рони
 
Регистрация: 27.05.2010
Сообщений: 33,070

sergiocharm,
попробуйте так
$(function() {
    var offset = $("#fixed").offset();
    var topPadding = 20,
        bottomPadding = 210;
    $(window).scroll(function() {
        var max = $(document).height() - ($(window).height() - bottomPadding),
            scroll = $(window).scrollTop();
        if (scroll > offset.top && scroll < max) {
            if ($(document).height() - bottomPadding > scroll + $("#fixed").height()) $("#fixed").stop().animate({
                marginTop: scroll - offset.top + topPadding
            })
        } else $("#fixed").stop().animate({
            marginTop: 0
        })
    })
});
Ответить с цитированием