简体   繁体   English

mCustomScrollbar“scrollTo”无法正常工作

[英]mCustomScrollbar “scrollTo” not working

I am using a basic setup for mCustomScrollbar which is working great accept when I call the following:- 我正在使用mCustomScrollbar的基本设置,当我调用以下内容时它非常接受: -

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

Nothing happens. 什么都没发生。 There is not error shown in firebug, it just does nothing. 在firebug中没有显示错误,它什么也没做。 Has anyone experienced this before, or does anyone have any idea why this might be happening? 有没有人以前经历过这个,或者有人知道为什么会这样吗?

thanks! 谢谢!

MCustomScrollbar doesn't provide feature of scrolling to top of the page. MCustomScrollbar不提供滚动到页面顶部的功能。 However, it does support scrolling to specific element in HTML. 但是,它支持滚动到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 例如,如果我有一个id为“logout”的元素位于页面顶部,我需要在顶部滚动,然后写

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

Hope you find this useful. 希望您觉得这个有帮助。

Cheers! 干杯!

我有同样的问题,只需计算我的第一个元素的位置并滚动到该数字即可解决它

setTimeout( function () {
   $("#mcs_container").mCustomScrollbar('scrollTo','last');
 }, 100);

Use with time out 使用超时

you just need a mCustomScrollbar class..... here is your answer... 你只需要一个mCustomScrollbar类......这是你的答案......

$(".scroller-back").mCustomScrollbar("scrollTo",jQuery("#mcs_container")); $( “滚动回 ”)mCustomScrollbar(“ scrollTo”,jQuery的( “#mcs_container”))。

I use like this, it'is working! 我这样用,它有效!

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

// then set scrollTo
$('.scroll-y').mCustomScrollbar('scrollTo', 'bottom');

After searching for a day. 寻找一天后。 Here's what I got: 这是我得到的:

Tested and working (2019): $('.demo-yx').mCustomScrollbar('scrollTo',['top',null]); 经过测试和工作(2019): $('.demo-yx').mCustomScrollbar('scrollTo',['top',null]);

From this link . 从这个链接 Cheers! 干杯!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM