【发布时间】: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