jScrollPane调整大小

ewd*_*ewd 9 jquery

我有一个div,它有100%的窗口宽度,这是jScrollPane div的容器.

窗口调整大小时,滚动窗格不会移动.有没有办法让jScrollPane调整窗口大小?

谢谢!

Ale*_*lex 13

您可以使用API​​调用reinitialise()来执行此操作.它包含在此处的一个示例页面中. http://jscrollpane.kelvinluck.com/dynamic_height.html
http://jscrollpane.kelvinluck.com/dynamic_width.html

$(function()
{
$('.scroll-pane').each(
    function()
    {
        $(this).jScrollPane(
            {
                showArrows: $(this).is('.arrow')
            }
        );
        var api = $(this).data('jsp');
        var throttleTimeout;
        $(window).bind(
            'resize',
            function()
            {
                if ($.browser.msie) {
                    // IE fires multiple resize events while you are dragging the browser window which
                    // causes it to crash if you try to update the scrollpane on every one. So we need
                    // to throttle it to fire a maximum of once every 50 milliseconds...
                    if (!throttleTimeout) {
                        throttleTimeout = setTimeout(
                            function()
                            {
                                api.reinitialise();
                                throttleTimeout = null;
                            },
                            50
                        );
                    }
                } else {
                    api.reinitialise();
                }
            }
        );
    }
)

});
Run Code Online (Sandbox Code Playgroud)


小智 8

我更喜欢这样的东西:

$(window).resize(function(){
    $.each( $('.scrollcont'), function(){
            var api = $(this).data('jsp');
            api.reinitialise();
    });
});
Run Code Online (Sandbox Code Playgroud)

其中'.scrollcont'是滚动容器.

如果您必须在操作期间调整滚动容器的大小,则此脚本也很有用.