Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery mCustomScrollbar "scrollTo" not working

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!

like image 588
Matt Avatar asked Jul 17 '12 09:07

Matt


3 Answers

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!

like image 172
varunvlalan Avatar answered Nov 12 '22 05:11

varunvlalan


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

like image 2
Salvador Dali Avatar answered Nov 12 '22 03:11

Salvador Dali


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

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

From this link. Cheers!

like image 1
elimariaaa Avatar answered Nov 12 '22 04:11

elimariaaa