[英]fullpage.js will only scrollOverflow after window resize
I have a fullpage.js site setup here . 我在这里有一个fullpage.js网站设置。 The first section has no scrollOverflow, but the second section is a grid (generated using gridify), which requires (on certain screen sizes), for it to be a scrollable section.
第一部分没有scrollOverflow,但是第二部分是一个网格(使用gridify生成),需要(在某些屏幕尺寸上)它才能成为可滚动部分。
The problem is it refuses to scroll. 问题是它拒绝滚动。 However, if I resize the window (even by a single pixel in any direction), then the fullpage.js scrollbar will appear for that section.
但是,如果我调整窗口的大小(即使在任何方向上都按单个像素调整大小),则针对该部分将显示fullpage.js滚动条。
Does anyone have any idea why fullpage.js is acting this way? 有谁知道为什么fullpage.js是这样工作的? And how can I get the scrollbar to appear in that section without having the resize the window manually?
以及如何使滚动条显示在该部分中而无需手动调整窗口大小?
It's worth noting, I've been able to get the same thing working using the fullpage.js example page for scrollOverflow. 值得一提的是,我已经使用scrolloverflow的fullpage.js示例页面获得了同样的效果。 That is setup right here .
那就是这里的设置。 However, I haven't been able to figure out why it works there, but not in my original page!
但是,我无法弄清楚它为什么能在这里工作,但无法在我的原始页面中找到!
That's probably because the content of your section or slide is being generated (or modified somehow) after fullPage.js gets initialized. 这可能是因为在初始化fullPage.js之后会生成(或以某种方式修改)您的部分或幻灯片的内容。
You should have used that javascript code inside the afterRender
callback as fullPage.js documentation details : 您应该在
afterRender
回调内使用该javascript代码作为fullPage.js文档详细信息 :
afterRender()
afterRender()
This callback is fired just after the structure of the page is generated.
页面结构生成后立即触发此回调。 This is the callback you want to use to initialize other plugins or fire any code which requires the document to be ready (as this plugin modifies the DOM to create the resulting structure).
这是您要用来初始化其他插件或触发任何需要准备文档的代码的回调 (因为此插件修改DOM来创建结果结构)。
In any case, I believe you can solve it by calling the method reBuild
provided by fullPage.js. 无论如何,我相信您可以通过调用
reBuild
提供的reBuild方法来解决。 You can try to use it in the afterRender
callback or directly after the code you use to generate the layout/content of the section to which you want to apply the scrollOverflow
option. 您可以尝试在
afterRender
回调中使用它,或者直接在用于生成您要对其应用scrollOverflow
选项的节的布局/内容的代码之后使用它。
$('#fullpage').fullpage({
//your options
});
//code used to generate the content of your section
//...
//re-building fullPage.js to detect the current content of each section
$.fn.fullpage.reBuild();
If that doesn't work, you can always try to use a timeout which should also solve it with some delay: 如果这不起作用,您可以随时尝试使用超时,这也应该延迟解决:
setTimeout(function(){
$.fn.fullpage.reBuild();
}, 1000);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.