javascript - 第一个滚动脚本之后的 fullpage.js

标签 javascript jquery scroll fullpage.js

关于整页插件的问题:http://alvarotrigo.com/fullPage/

您可以在任何部分打开该网站。例如,此链接打开第四部分中的站点:

http://alvarotrigo.com/fullPage/#4thpage

这意味着一旦您打开网站,网站就会立即开始滚动(它向下滚动到第四部分)。

但是,我有一个脚本(它加载一个聊天框)会减慢这个过程。尽管我在 Fullpage.js 初始化脚本之后添加了聊天脚本,但我的网站首先加载聊天框,然后 Fullpage 滚动到右侧部分。

我希望页面首先在网站打开时向下滚动到右侧部分,一旦网站打开并滚动到右侧部分,则聊天框脚本需要开始运行(只要网站打开)已开放)。

如何实现这一目标?我尝试将聊天脚本放在 afterLoad 和 afterRender 中,但由于某种原因,这使得我的聊天框根本不显示。有没有办法在全页加载后以及第一次滚动(在网站上打开)到右侧部分后执行一些操作?

最佳答案

正如我在之前的评论中所说:

Probably what's taking time is the loading of the JS, CSS or SWF files required for that script to run. Fullpage.js waits until all elements from the site have loaded to scroll to the section. The reason to do this is due to the use of images in section when using scrollOverflow:true, as fullpage.js needs to determine if the section needs scroll bar or not depending on the size of the loaded image.

要解决这个问题,您可以使用 jQuery 或 ajax 动态加载元素。

否则,您可以编辑 fullPage.js 并更改 line 536这个:

$window.on('load', function() {
    scrollToAnchor();
});

对此:

scrollToAnchor();

唯一的问题是您必须记住每次更新 fullpage.js 时更改该行。

欢迎提出问题 in fullPage.js github forum并且可能会在未来版本中实现解决方案。

关于javascript - 第一个滚动脚本之后的 fullpage.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35587725/

相关文章:

javascript - 将 jQuery 插件导入到 React 组件中?

javascript - jQuery 从 URL 上的过滤器搜索中获取 categoryid

javascript - 如何高效地创建和附加多个 dom 元素

jquery - 为什么将函数分配给 $.x 变量?

javascript - 我的 Ajax 脚本在提交后未隐藏 Bootstrap Modal

javascript - 滚动条和平滑滚动代码

javascript - 比较数组(不修改原始数组)

javascript - 如何使用jquery查找数组中的重复项

java - 无法在 Android 模拟器中滚动

css - 页面不会滚动