我正在使用 SweetAlert2 v8 和 animate.css 来更改弹出动画。我使用的动画是fadeInRight。我也在使用链式警报,并希望将关闭动画更改为 fadeOutLeft 以使其在页面上滑动。
我添加 animate.css 类的方式是使用 customClass 弹出属性。
我试过了:
这两种方法似乎都不起作用。如果有人知道如何更改结束动画,将不胜感激。
谢谢
最佳答案
swal({
title: 'swal title',
html: 'some content',
showLoaderOnConfirm: true,
animation: false,
customClass: "animated fadeInLeft",
onClose: function(){
return delaySwalWithAnimation("fadeInLeft","fadeOutRight");
},
preConfirm: function(){
return delaySwalWithAnimation("fadeInLeft","fadeOutRight");
}
}).then(function(result) {
//...
}
function delaySwalWithAnimation(animationA, animationB){
return new Promise(function(resolve) {
$(".swal2-popup").removeClass(animationA);
$(".swal2-popup").addClass(animationB);
setTimeout(function() {
resolve();
},300);
});
}
关于javascript - 如何更改 SweetAlert2 的关闭动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57341949/