JScrollPane 无法正确处理隐藏内容
我在我的网站上安装了 jScrollPane 但无法使其工作。
我的网站的工作原理如下:从主页,使用 jQuery 的 load()
方法动态加载页面。在我加载的页面中,我有以下脚本来启动 jScrollPane:
$(function(){
$('.scroll-pane').jScrollPane();
});
这似乎被调用。我想到目前为止还没有问题。问题是页面一开始不够长,不需要滚动条。我隐藏了仅在特定操作上显示的内容(即单击按钮显示特定段落的内容),并且当我单击以显示隐藏 div 的内容时,滚动条不会出现。
我还尝试在显示新内容时调用 $('.scroll-pane').jScrollPane();
(即触发 .show()
的事件)在隐藏的 div
上,我还调用了 $('.scroll-pane').jScrollPane();
) 但我也没有成功。
有人可以帮助我吗?
谢谢
编辑:
我忘了提及页面的结构:我有一个 div
,它有 class="scroll-pane"
并随页面加载一起加载,它包含单击特定区域时会显示小的隐藏 div。我想使用滚动窗格类向 div 添加一个滚动条,以便使显示的 div 的内容可滚动(现在内容保持在 div 的大小中,但它不可滚动,因为没有 jScrollPane 滚动条)所示)。
更新:
我尝试将 $('.scroll-pane').jScrollPane();
放入 div 的 .show()
方法的回调中,并尝试将 class="scroll-pane"
放入出现的那些 div 中,但同样没有显示任何内容(滚动条不出现并且 div 不可滚动)。
I installed jScrollPane on my website and can't make it work.
My website works as follows: from the main page, pages are loaded dynamically using jQuery's load()
method. In the page I load I have the following script to launch jScrollPane:
$(function(){
$('.scroll-pane').jScrollPane();
});
Which seems to be called. No problems so far I guess. The problem is that the page, at the beginning, is not long enough to need a scrollbar. I have hidden content that shows up only on specific actions (i.e. clicking on a button shows the content of a certain paragraph), and when I click to show the content of a hidden div, the scrollbar doesn't appear.
I also tried to call $('.scroll-pane').jScrollPane();
as I show the new content (i.e. in the event that triggers .show()
on the hidden div
I also call $('.scroll-pane').jScrollPane();
) but I had no success with that either.
Can anyone help me?
Thanks
EDIT:
I forgot to mention the structure of the page: I have a div
which has class="scroll-pane"
and is loaded with the page load and it contains small hidden divs that show up when clicking on particular areas. I would like to add a scroll bar to the div with the class scroll-pane in order to make the content of the showed div scrollable (right now the content stays in the size of the div but it's not scrollable since no jScrollPane scroll bar is shown).
Update:
I tried to put $('.scroll-pane').jScrollPane();
in the callback of the .show()
method of my divs and tried to put class="scroll-pane"
to those divs that appear, but again nothing is shown (the scroll bar doesn't appear and the div is not scrollable).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看插件开发人员提供的演示
http://jscrollpane.kelvinluck.com/examples/隐形.html
您所需要的只是
并且可能是该插件的最新版本
Check this demo provided by the developer of the plugin
http://jscrollpane.kelvinluck.com/examples/invisibles.html
All that you need is
and may be the recent version of the plugin
我建议使用 css 可见性属性而不是自动重新初始化。每次调用 show() 方法时,jScrollPane 都会重新初始化自身。这需要时间并且会对动画产生影响。
如果您使用,比如说,slide..() 方法,那么动画会正常启动,但可滚动容器(及其元素)会稍后出现,这看起来很糟糕。
I suggest to use css visibility property instead auto reinitialising. Each time you call show() method, jScrollPane reinitialises itself. This takes time and has impact on animation.
If you use, say, slide..() methods, then animation starts properly, but scrollable container (and its elements) appears little bit later, and that looks bad.