简体   繁体   English

调用隐藏的div时,jscrollbar不显示

[英]jscrollbar doesn't show when calling a hidden div

I have content in a hidden div that contains a list box with a vertical scroll bar. 我在一个隐藏的div中包含内容,该div包含一个带有垂直滚动条的列表框。 When a link is clicked the div becomes visible along with the list box and the default scroll bar. 单击链接后,div随列表框和默认滚动条一起可见。

The challenge is that jscrollpane is declared on the div that contains the list box not the default scroll bar. 挑战在于,jscrollpane是在包含列表框而不是默认滚动条的div上声明的。

Within the same page I have an event that if the browser window is re-sized the jscrollpane is reinitialize for the browser horizontal scroll. 在同一页面中,我有一个事件,如果调整了浏览器窗口的大小,则会为浏览器水平滚动重新初始化jscrollpane。 If the browser is re-sized the correct jscrollpane is then displayed for both horizontal and vertical. 如果调整了浏览器的大小,则正确显示水平和垂直jscrollpane。

I am trying to get the jscrollpane to load when the initial div state is changed from hidden to visible. 我正在尝试将初始div状态从隐藏更改为可见时加载jscrollpane。 I know the jscrollpane works because it will trigger on the re-size. 我知道jscrollpane可以工作,因为它将在重新调整大小时触发。

What do I need to do to get it to work on the initial change state of the div from hidden to visible? 我需要做什么才能使其在div的初始更改状态(从隐藏到可见)上起作用? What event should I look for? 我应该寻找什么活动? I have tried the following and more.. 我已经尝试了以下方法和更多方法。

$(document).onload(function () {
                 $(function () {
                     jScrollPane = $('.scroll-pane').jScrollPane({ showArrows: true, arrowScrollOnHover: true });
                 });
             });

Also

$(document).ready(function () {
                 $(function () {
                     jScrollPane = $('.scroll-pane').jScrollPane({ showArrows: true, arrowScrollOnHover: true });
                 });
             });

Resize code that corrects all jscrollpane 调整可纠正所有jscrollpane的代码的大小

               $(window).resize(function () {
                 if (this.resizeTO) clearTimeout(this.resizeTO);
                 this.resizeTO = setTimeout(function () {
                     $(this).trigger('resizeEnd');
                 }, 500);
             });

             $(window).bind('resizeEnd', function () {

                 $(function () {
                    jScrollPane = $('.scroll-pane').jScrollPane({ showArrows: true, arrowScrollOnHover: true });
                 });
                var newHeight = $(window).height();

             });

Code to show hidden DIV 显示隐藏的DIV的代码

function showDiv(elemId, userDivId) {
var elem = document.getElementById(elemId);
var calcedPos = (window.outerWidth - mouseXpos);
var userDetailWidth = $(".UserDetail").width();
if (calcedPos >= (userDetailWidth + 100)) {
    $(elem).animate({ width: 'show' }, 210);
}

document.getElementById(elemId).style.visibility = 'visible';
document.getElementById(elemId).style.display = 'block';

$('.user-list-container').css('background-color', 'inherit');
document.getElementById(userDivId).style.backgroundColor = '#e6e6e6';

$('.spacer-container').height(100);

vph = $(window).height();
cvph = vph - 730;
$('.spacer-container').css({ 'height': cvph + 'px' });

} }

在使div可见后,只需在窗口中调整大小即可。

$(window).trigger('resize');

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

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