7

I'm using a basic setup for mCustomScrollbar which is working great except when I call the following:

jQuery("#mcs_container").mCustomScrollbar("scrollTo","top");

Nothing happens. There is not error shown in firebug, it just does nothing. Has anyone experienced this before or does anyone have any idea why this might be happening?

Thanks!

Medulla Oblongata
  • 3,771
  • 8
  • 36
  • 75
Matt
  • 89
  • 1
  • 1
  • 10

6 Answers6

10

MCustomScrollbar doesn't provide feature of scrolling to top of the page. However, it does support scrolling to specific element in HTML.

For example, if I have an element with id "logout" which is at top of the page and i need to scroll at top, then write

$("#mcs_container").mCustomScrollbar("scrollTo", "#logout");

Hope you find this useful.

Cheers!

varunvlalan
  • 940
  • 10
  • 23
2

I had the same problem and solved it simply with calculating the position of my first element and scrolling to that number

Salvador Dali
  • 214,103
  • 147
  • 703
  • 753
  • Thanks man! Mine was not working, even selecting the object perfectly. But I tried your approach and worked like a charm! – Vitox Jul 02 '14 at 11:32
1

After searching for a day. Here's what I got:

Tested and working (2019): $('.demo-yx').mCustomScrollbar('scrollTo',['top',null]);

From this link. Cheers!

elimariaaa
  • 796
  • 4
  • 10
  • 30
0

You just need a mCustomScrollbar class..... Here is your answer...

$(".scroller-back").mCustomScrollbar("scrollTo",jQuery("#mcs_container"));
DmitryArc
  • 4,757
  • 2
  • 37
  • 42
0

I use like this, it'is working!

// set scrollbar
$('.scroll-y').mCustomScrollbar({
  theme: 'minimal-dark'
});

// then set scrollTo
$('.scroll-y').mCustomScrollbar('scrollTo', 'bottom');
wangchi
  • 2,945
  • 1
  • 16
  • 11
0
setTimeout( function () {
   $("#mcs_container").mCustomScrollbar('scrollTo','last');
 }, 100);

Use with time out

Ashish Yadav
  • 3,039
  • 1
  • 16
  • 23