JQuery PNotify animate&;寻求关注的人不会一起工作
这是小提琴: 注释掉JQuery PNotify animate&;寻求关注的人不会一起工作,jquery,animate.css,pnotify,Jquery,Animate.css,Pnotify,这是小提琴: 注释掉animate:{}部分,然后单击按钮查看没有它的“jello”动画可以工作,初始加载动画可以工作,但是jello不能 我正在使用插件。以下是我的设置: PNotify.prototype.options.styling = "jqueryui"; var myStack = {"dir1":"down", "dir2":"left", "push":"top"}; var notification = new PNotify({ title: "Test Title
animate:{}
部分,然后单击按钮查看没有它的“jello”动画可以工作,初始加载动画可以工作,但是jello不能
我正在使用插件。以下是我的设置:
PNotify.prototype.options.styling = "jqueryui";
var myStack = {"dir1":"down", "dir2":"left", "push":"top"};
var notification = new PNotify({
title: "Test Title",
text: "Test Content",
stack: myStack,
icon: 'glyphicon glyphicon-info-sign',
type: 'info',
// IF I COMMENT THIS OUT, THE "jello" effect works fine but then
// when showing/hiding the notification it does not use the bellow effects
animate: {
animate: true,
in_class: 'bounceInDown',
out_class: 'bounceOutUp'
},
buttons: {
sticker: false,
closer_hover: false
},
mobile: {
swipe_dismiss: true,
styling: true
},
nonblock: {
nonblock: false,
nonblock_opacity: .2
},
});
然后我有一个点击事件按钮来激活“果冻”效果:
我需要这两种效果才能工作,当通知显示时,它必须使用该效果向下反弹,当单击时,它必须使用“果冻”效果,当隐藏/关闭时,它必须使用向上反弹效果。这很有效
$('#clickMeButton').on('click', function() {
notification.get().removeClass('animated bounceInDown bounceOutUp');
notification.attention('jello');
});
需要首先删除该类,这不是在PNotify库的intention函数中完成的
notice.attention = function(aniClass, callback){
notice.elem.one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){
notice.elem.removeClass(aniClass);
if (callback) {
callback.call(notice);
}
}).addClass("animated "+aniClass);
您可以更改PNotify库的代码,这将更便于将来使用其他动画预设。下面是对上述原始代码的一些更改。只需添加我在评论中提到的行
notice.attention = function(aniClass, callback){
//just add the line below
notice.elem.removeClass(this.options.animate.in_class + " " + this.options.animate.out_class);
notice.elem.one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){
notice.elem.removeClass(aniClass);
if (callback) {
callback.call(notice);
}
}).addClass("animated "+aniClass);
};
您现在可以直接调用注意功能
$('#clickMeButton').on('click', function() {
notification.attention('jello');
});
@Siddharth补充道,Fiddle你找到解决这个问题的方法了吗,还是还在寻找?
$('#clickMeButton').on('click', function() {
notification.attention('jello');
});