2015-09-30 43 views
0

我有notifyjs jQuery插件的通知。notifyjs消失沒有隱藏效果

var notifyProps = {}; 
notifyProps.showAnimation = 'slideDown'; 
notifyProps.showDuration = 2500; 
notifyProps.hideAnimation = 'slideUp'; 
notifyProps.hideDuration = 2500; 
notifyProps.style = 'myStyle'; 
notifyProps.clickToHide = true; 
var insertId = ("myId"+ Math.random()).replace('0\.',''); //just an id 
$.notify({title: $('<div id="'+insertId+'"></div>').append(elem.element)},notifyProps); 

通知用了slideDown的showAnimation顯示正確,但點擊時,它就會消失,而不是向上滑動,或者如果fadeOut設置爲hideAnimation淡出。

我使用addStyle定義myStyle像這樣:

$notify.addStyle("myStyle", { 
    html: 
"<div>" + 
     "<div class='clearfix'>" + 
      "<div class='lb-close'></div>" + 
      "<div class='notify-title' data-notify-html='title'/>" + 
     "</div>" + 
"</div>", 
css: "-webkit-box-shadow: 0px 2px 4px 0px rgba(0,0,0,0.1);-moz-box-shadow: 0px 2px 4px 0px rgba(0,0,0,0.1);box-shadow: 0px 2px 4px 0px rgba(0,0,0,0.1);" 
}); 

調試此,通知的方法show()被調用以false作爲參數,但是,當它到達這個函數的最終行:

return elems[fn].apply(elems, args); 

通知div立即消失,而不是過渡出來。我還能檢查什麼?

回答

0

正是因爲這些行,在Notification.prototype.show

callback = function() { 
    if (!show && !_this.elem) { 
    _this.destroy(); 
    } 
    if (userCallback) { 
    return userCallback(); 
    } 
}; 

出於某種原因,_this.elem永遠是不確定的,這一點我想反過來破壞通告元素。我只是評論一下,檢查回調,一切似乎都沒問題。