A
A
Alexander-K2014-08-13 19:37:23
css
Alexander-K, 2014-08-13 19:37:23

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

4 answer(s)
V
Vladik Limonadik, 2014-08-13
@knitevision1

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}); // То возвращаем стили
      }
  });
});

S
Sergey, 2014-08-13
Protko @Fesor

mojotech.github.io/stickymojo

D
Dmitry Evgrafovich, 2014-08-13
@Tantacula

stickyjs.com I used it in the last project for the same panel

L
Leonid, 2015-06-22
@TalismanV

HTML:
CSS:

.ui-panel.ui-panel-open {
    position:fixed;
}
.ui-panel-inner {
    position: absolute;
    top: 1px;
    left: 0;
    right: 0;
    bottom: 0px;
    overflow: scroll;
    -webkit-overflow-scrolling: touch;
}
.ui-page-active.ui-page-panel {
height: 70%;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question