Jquery自定义滚动条和IE问题

时间:2016-04-21 13:10:36

标签: jquery mcustomscrollbar

我使用了jquery自定义滚动条插件来显示自定义滚动条。 Link

它适用于所有浏览器和设备,但有一个奇怪的问题。虽然它在IE中工作正常但滚动条是可见的,而不需要滚动。我还使用了回调函数(onOverflowYNone)来删除它,但它将删除滚动功能。如果比率接近1,我该如何删除滚动。

1 个答案:

答案 0 :(得分:0)

您可能会执行以下操作:

/*CSS*/
.hidden { display: none; }

// jQuery
$(document).ready(function() {
    $(window).resize(function() {
        var windowHeight = $(this).height();
        var containerHeight = $(".<container-class>").height(); //<container-class> is just a placeholder. Your real class should go here.
        if (containerHeight <= windowHeight) {
            $(".mCustomScrollbar").addClass("hidden"); // This is the example default class that was in the link you provided
        } else {
            $(".mCustomScrollbar").removeClass("hidden");            
        }
    });
});

这将等待文档加载,然后附加一个调整大小动作侦听器,在调整窗口大小的任何时候,运行此检查以查看窗口和容器的尺寸。如果愿意,您还可以将此检查外部化并将其添加到更多动作侦听器。

显然,您应该定制评估以满足您的需求,但核心概念仍然完好无损。

相关问题