javascript - 如何使javascript动画第二次工作
问题描述
我有一个触发动画的功能
function jumpAnimation() {
$('.array__elem').each(function (index) {
$(this).css({
animation: `jump 1s ease-in-out`,
'animation-delay': index * 0.05 + 's',
});
});
}
但是,该函数仅在我第一次调用它时才起作用。当我再次调用该函数时,动画不会重新触发。我怎样才能做到这一点?
解决方案
尝试添加css,animation: `jump 1s infinite ease-in-out`
如果这不起作用,您也可以尝试animation-iteration-count: infinite;
所以应该看起来像
function jumpAnimation() {
$('.array__elem').each(function (index) {
$(this).css({
animation: `jump 1s infinite ease-in-out`,
'animation-delay': index * 0.05 + 's',
});
});
}
推荐阅读
- java - 如何在 jTextPane 中使用拉绳创建和填写表单?
- authentication - Route [murid.index] not defined. (View: D:\xampp\htdocs\MentorOnlinemu\resources\views\navigation-menu.blade.php)
- java - 如何在 Java 中将 object[] 转换为 char[]?
- javascript - 使用 Kraken WS API 制作的应用程序可能存在 React Memory 泄漏
- javascript - 在谷歌应用脚本的html代码中导入html文件
- kendo-grid - 如何使用与 Kendo Grid 相同的局部视图作为详细信息模板或仅在 Html 页面上
- java - soot可以对不完整的代码进行程序分析
- vba - 用序列号替换逗号字符
- animation - SVG textPath动画在页面上滚动多次
- pandas - 如何在熊猫中旋转数据框条形图?