jScrollPane scrollbar disappears when applying scrollTo

早过忘川 提交于 2020-01-11 12:32:30

问题


I have a problem with the jQuery extension jScrollPane combined with the scrollTo plugin. The scrollbar disappears if I apply the scrollTo command to the scrollable container and the scroll is at the top position. (If the scroll is not at the top position, everything is working fine.)

To get the scrollbar back, I try to reinitialize it. What happens then is that the scroll goes back to the top, canceling the scrollTo command.

My code:

  $('#myScrollableDiv div.jspContainer').scrollTo(delta);
  c = $('#myScrollableDiv').jScrollPane({
        autoReinitialise: true,
        maintainPosition: true
  });

回答1:


If you use jScrollPane, you have to use the functions of jScrollPane to scroll down.

var delta = 20;
var element = $('#myContainer').jScrollPane();
var api = element.data('jsp');
$('#scroll').click(function() {
    api.scrollByY(delta);
});​

Try it on jsfiddle

Refer the jScrollPane Api for a list of functions for the api variable.

Note: It doesn't work when you omit the p tags around the text.



来源:https://stackoverflow.com/questions/10445403/jscrollpane-scrollbar-disappears-when-applying-scrollto

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!