javascript - 检测 JQuery 动画的结束
问题描述
我有一个这样的工作 Jquery 动画:
const e = $("#span-7");
e.css({fill: "#4287f5", transition: "0.5s"});
如何检测动画的结束?
我试过这个没有运气!
e.one("animationend webkitAnimationEnd oAnimationEnd MSAnimationEnd", function(){
console.log('Animation Ended!');
});
编辑:伙计们,动画不适用于填充动画。我需要使用 .css 动画。
解决方案
If you use jQuery you can animate with .animate()
method
.animate() method has complete callback
const e = $("#span-7");
e.animate({
fill: "#4287f5"
}, 500, function(){
// animation complete
})
UPD: For animate fill property you must use jQuery plugin jQuery Color
Working demo https://codepen.io/-greg-/pen/jOqMJNp
UPD: if you don't want use jQuery color plugin:
Use event transitionend
and webkitTransitionEnd
demo
推荐阅读
- r - 在 data.table 中创建子组
- mysql - 使用 mysql/nodejs 返回更新的行
- html - 使用 ng-click 根据屏幕上单击的元素在新屏幕上显示数据
- ios - XCUITest 等待一个包含特定静态文本的单元格
- javascript - 单击外部组件时关闭弹出窗口
- ios - 使用 SwiftUI 创建手势以编辑列表项
- react-native - 从我的反应本机应用程序中关闭正在运行的应用程序
- reactjs - Draft-js 更好的方法来保存和检索 MySql 中的内容
- python - 如何在 Pandas DataReader 中修复此 RemoteDataError
- php - PHP sql查询没有向前端返回正确的行数