javascript - 首次加载时不同的 jQuery 过期时间
问题描述
我正在尝试为这样的帖子制作动画。刷新页面后,在第一次加载时为不透明度设置动画需要更长的时间,而在第二次加载不透明度时需要更少的时间。看起来计时器设置为约 5 分钟(适用于所有选项卡)。
$(document).ready(function() {
jQuery(".floating-box:eq(0)").delay(300).animate({
"opacity": "1"
}, 600);
jQuery(".floating-box:eq(1)").delay(900).animate({
"opacity": "1"
}, 600);
jQuery(".floating-box:eq(2)").delay(1500).animate({
"opacity": "1"
}, 600);
jQuery(".floating-box:eq(3)").delay(2100).animate({
"opacity": "1"
}, 600);
jQuery(".floating-box:eq(4)").delay(2700).animate({
"opacity": "1"
}, 600);
jQuery(".floating-box:eq(5)").delay(3300).animate({
"opacity": "1"
}, 600);
jQuery(".floating-box:eq(6)").delay(3900).animate({
"opacity": "1"
}, 600);
jQuery(".floating-box:eq(7)").delay(4500).animate({
"opacity": "1"
}, 600);
});
h2 {
padding: 10px;
}
.floating-box {
display: inline-block;
width: 150px;
height: 75px;
margin: 10px;
padding: 10px;
border: 3px solid #4F69F8;
}
.floating-box {
opacity: 0;
transition: opacity ease-out;
will-change: opacity;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<h2>Opacity Animation</h2>
<div class="floating-box">First Floating box</div>
<div class="floating-box">Second Floating box</div>
<div class="floating-box">Third Floating box</div>
<div class="floating-box">Fourth Floating box</div>
<div class="floating-box">Fifth Floating box</div>
<div class="floating-box">Sixth Floating box</div>
<div class="floating-box">Seventh Floating box</div>
<div class="floating-box">Eighth Floating box</div>
解决方案
推荐阅读
- jquery - WordPress JQuery .. WordPress 忽略了我的代码
- reactjs - html 中的类中有太多空格会导致任何问题/性能问题吗?
- c - 静态分配的数组如何在 C 中的内存中布局?
- javascript - 试图让导航在本机反应的页面之间工作
- python - 打印文本文件的行号
- python - 填充和重塑熊猫数据框
- javascript - 前端开发人员面试编码问题:a 未定义,b 已定义?
- xml - Outlook Manifest 在 Web Outlook 中有效,无法在桌面 Outlook 中正确安装
- javascript - 通过使用 jQuery 删除类来关闭下拉菜单
- kotlin - 如何通过 Kotlin 在 Redshift JDBC PreparedStatement 中使用和设置数组