【问题标题】:cannot get jscrollpane api for dynamic size to work无法使动态大小的 jscrollpane api 工作
【发布时间】:2012-08-10 03:33:41
【问题描述】:

我一直在尝试使用jscrollpane 为某些内容添加自定义滚动条。数据是通过 ajax 提取的,jscrollpane api 非常适合。

但我试图使滚动窗格的高度始终为用户浏览器窗口高度的 70%。 jscrollpane site 说我可以使用以下代码使其工作,但我没有运气。

$(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();
            }
        });
    })

});

当我将 css 更改为百分比时,自定义滚动条完全失败,我得到一个默认的 chrome 滚动条,它是窗口高度的 100%。

http://jsfiddle.net/loren_hibbard/2yEsG/

非常感谢!

【问题讨论】:

  • 这实际上可能是一个 jsfiddle 问题...

标签: javascript jquery jquery-plugins jscrollpane jquery-jscrollpane


【解决方案1】:

resize 和 jsfiddle 的 api 似乎存在一些兼容性问题。 jscrollpane 仍然是一个了不起的扩展。谢谢。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-17
    • 2011-10-23
    • 1970-01-01
    • 2020-08-16
    • 1970-01-01
    • 2021-11-30
    相关资源
    最近更新 更多