Search code examples
javascriptscrollbartoggletinyscrollbar

Tiny scroll on toggle is jumping to top


I'm using Tiny Scroll Bar from here http://baijs.nl/tinyscrollbar/.

My problem is that when I toggle the folder (i.e: http://prntscr.com/tqf3j), the scroll bar is jumping to the top. I want to stay at a fixed position.

Part of my JavaScript code:

$(document).on('click', '#TreeView a', function() {
  CloseFolderOptions();

  $('#TreeView a').removeClass('selected');
  $(this).addClass('selected');
  if ($(this).next('.sub').find('li').length > 0) {
      $(this).next('.sub').slideToggle();
      oScrollbar5.tinyscrollbar_update();

  }

I don't know the position of folders because every user can add a folder.


Solution

  • Try this:

    oScrollbar5.tinyscrollbar_update('relative');