应用 scrollTo 时 jScrollPane 滚动条消失 [英] jScrollPane scrollbar disappears when applying scrollTo

查看:26
本文介绍了应用 scrollTo 时 jScrollPane 滚动条消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 jQuery 扩展 jScrollPanescrollTo 插件.如果我将 scrollTo 命令应用于可滚动容器并且滚动条位于顶部位置,滚动条就会消失.(如果滚动不在顶部位置,一切正常.)

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.)

为了恢复滚动条,我尝试重新初始化它.然后发生的事情是滚动回到顶部,取消 scrollTo 命令.

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.

我的代码:

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

推荐答案

如果你使用jScrollPane,你必须使用jScrollPane的功能才能向下滚动.

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);
});​

在 jsfiddle 上试试

有关 api 变量的函数列表,请参阅 jScrollPane Api.

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

注意:省略文本周围的 p 标记时不起作用.

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

这篇关于应用 scrollTo 时 jScrollPane 滚动条消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆