javascript - 如何在滚动事件发生之前为元素设置动画?

标签 javascript jquery css animation fullpage.js

Fullpage.js 方面需要一些帮助,但这个问题也可以看得更笼统。

如何在滚动事件发生之前插入动画?如果您有没有 Fullpage.js 的解决方案,我们也欢迎您。我阅读了有关在某处完全阻止滚动/单击事件并赋予自己的函数和方法的信息,但这不是我要搜索的内容,因为我无法从 Fullpage.js 脚本重写任何事件。只想将动画粘贴在滚动输入和实际滚动之间。

实际示例:我滚动,元素淡出,然后页面滚动到下一部分。

实例:http://www.basicagency.com/yir/

提前致谢。

最佳答案

我相信您正在寻找 onLeave回调。

This callback is fired once the user leaves a section, in the transition to the new section. Returning false will cancel the move before it takes place.

$('#fullpage').fullpage({
  onLeave: function(index, nextIndex, direction){
    alert('onLeave fired');
  }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="http://alvarotrigo.com/fullPage/jquery.fullPage.min.js"></script>
<div id="fullpage">
  <div class="section">section</div>
  <div class="section">section</div>
  <div class="section">section</div>
  <div class="section">section</div>
</div>

关于javascript - 如何在滚动事件发生之前为元素设置动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42380396/

相关文章:

javascript - 跟踪按钮被点击的次数

html - 与表格单元格居中对齐

javascript - 如何将自定义 map 控件放置在 Google map 中的 "Google"标签上方?

javascript - jQuery 全局/本地事件执行顺序

javascript - 在 URL 后添加随机数

jquery - 使 Stratus 2 Beta 使用网站 HTML 代码有困难

javascript - Jquery:windows.onunload 在 Firefox 和 Chrome 中不起作用

javascript - "this"的正确 JavaScript 使用

javascript - 将对象及其方法传递给 Javascript 中的 onchange 函数

javascript - 垂直显示图像直到页面末尾,然后在 100% 高度响应 div 内继续水平显示