简体   繁体   English

Jscrollpane:水平滚动条可以滚动200px吗?

[英]Jscrollpane: Is the function scroll 200px possible with horizontal scrollbar?

I tried doing it like in the vertical example but could not get that to work. 我尝试像在垂直示例中那样进行操作,但是无法正常工作。

So what I have is a div with a horizontal scrollbar in it with a lot of pictures in it. 因此,我所拥有的是一个带有水平滚动条的div,其中包含许多图片。 I now want to make a button that if clicked will scroll +200px or something like that. 我现在要制作一个按钮,如果单击该按钮,它将滚动+ 200px或类似的内容。 Is this possible and where do I start? 这可能吗,我应该从哪里开始? Couldn't find anything on google or here... 在Google或此处找不到任何内容...

Which version are you using? 您正在使用哪个版本? According to the documentation this did not exist but has been fixed in the latest version, which came out a few months ago... 根据文档,此功能不存在,但已在几个月前发布的最新版本中得到修复。

see http://code.google.com/p/jscrollpane/issues/detail?id=8 参见http://code.google.com/p/jscrollpane/issues/detail?id=8

If this doesn't work for you, there is another plugin http://plugins.jquery.com/project/jscrollhorizontalpane that may do the job for you. 如果这对您不起作用,则还有另一个插件http://plugins.jquery.com/project/jscrollhorizo​​ntalpane可以为您完成这项工作。

It sounds like you are looking for the scrollBy functionality of jScrollPane 2: 听起来您正在寻找jScrollPane 2的scrollBy功能:

http://jscrollpane.kelvinluck.com/scroll_to.html http://jscrollpane.kelvinluck.com/scroll_to.html

Since you only want to scroll horizontally you will use the scrollByX function like so: 由于您只想水平滚动,因此将使用scrollByX函数,如下所示:

$(function()
{
    var scrollPane = $('.scroll-pane').jScrollPane();
    var api = scrollPane.data('jsp');
    $('#your-button-id').bind(
        'click',
        function()
        {
            api.scrollByX(200);
        }
    );
}

Additionally, you mention that your scrollpane contains lots of images. 此外,您提到您的滚动窗格包含很多图像。 If this is the case you will need to ensure that the scrollpane can correctly calculate it's width by using one of the following two techniques: 如果是这种情况,则需要使用以下两种技术之一来确保滚动窗格可以正确计算其宽度:

http://jscrollpane.kelvinluck.com/image2.html http://jscrollpane.kelvinluck.com/image2.html

http://jscrollpane.kelvinluck.com/image.html http://jscrollpane.kelvinluck.com/image.html

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

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