fullpage.js will only scrollOverflow after window resize

混江龙づ霸主 提交于 2019-12-11 07:43:51

问题


I have a fullpage.js site setup here. 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.

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.

Does anyone have any idea why fullpage.js is acting this way? 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. That is setup right here. However, I haven't been able to figure out why it works there, but not in my original page!


回答1:


That's probably because the content of your section or slide is being generated (or modified somehow) after fullPage.js gets initialized.

You should have used that javascript code inside the afterRender callback as fullPage.js documentation details:

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).

In any case, I believe you can solve it by calling the method reBuild provided by fullPage.js. 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.

$('#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);


来源:https://stackoverflow.com/questions/26986136/fullpage-js-will-only-scrolloverflow-after-window-resize

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!