Answer the question
In order to leave comments, you need to log in
How to make a floating panel like on Vkontakte using jQuery?
How to make such a floating panel on jQuery?
Like here, right panel
: vk.com/search
when scrolling down, it scrolls to its bottom border, and further, when scrolling down, the user always sees the bottom of this panel. If he then starts scrolling up, the panel also starts scrolling up until the top border of that panel appears and then when scrolling up, the top of the panel is always visible to the user.
To see, make the browser window small, and after that go to vk.com/search, and see how the right panel behaves when scrolling up and down the page.
Answer the question
In order to leave comments, you need to log in
jQuery(document).ready(function ($) {
$fixed = $('#your-id'); // ID элемента
$(window).scroll(function(){
if($(window).scrollTop()>254) // Если сверху проскроллено 254 пикселя
{
$fixed.css({position:"fixed", top:0}); // То фиксируем элемент
}
else // Если нет
{
$fixed.css({position:"relative", top:0}); // То возвращаем стили
}
});
});
stickyjs.com I used it in the last project for the same panel
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question