sciactive / pnotify

Beautiful JavaScript notifications with Web Notifications support.
https://sciactive.com/pnotify/
Apache License 2.0
3.65k stars 513 forks source link

if you provide context, multiple pnotify messages getting overlapped #273

Closed aksharj closed 6 years ago

aksharj commented 7 years ago

Hello There,

I have declared the stack outside of the loop so that its not called multiple times

if (typeof stack_context_notice === "undefined") stack_context_notice = {
    "dir1": "up",
    "dir2": "left",
    "context": $("#notice_pnotify")
};

and then execute the below code

$("div#error, div#notice, div#warning, div#info").each(function( i, e ){
    e = $(e);
    if(e.html().trim() != ''){
        if(e.attr('id') == 'notice'){
            if ($(".row.submenuvisible nav").length == 1) {
                message = {text: e.html(), type: 'success',stack: stack_context_notice,delay:4000,animate:animate_var};
            } else {
                message = {text: e.html(), type: 'success',delay:4000,animate:animate_var};
            }
            new PNotify(message);
        } else if ((e.attr('id') == 'error') || (e.attr('id') == 'warning')){
            if ($(".row.submenuvisible nav").length == 1) {
                message = { text: e.html(), type: 'error',stack: stack_context_notice,hide:false,animate:animate_var};
            } else {
                message = { text: e.html(), type: 'error',hide:false,animate:animate_var};
            }
            new PNotify(message);
        } else{
            title = e.attr('id');
            if ($(".row.submenuvisible nav").length == 1) {
                message = { text: e.html(), type: 'info', hide: (stiky==null) ? true : stiky,stack: stack_context_notice,delay:4000,animate:animate_var};
            } else {
                message = { text: e.html(), type: 'info', hide: (stiky==null) ? true : stiky,delay:4000,animate:animate_var};
            }
            new PNotify(message);
        }
    }
});

but i observe that notices are getting overlapped, can anyone please suggest as to what could be causing the issue. Thanks.

hperrin commented 7 years ago

Can you try adding "let message;" in the beginning of each block in the if statement. Maybe the variable is being overwritten while PNotify is using it. (Just a guess.)

aksharj commented 7 years ago

Hello There,

Thanks for your reply.

Actually the same code is working for a root div and not for a inner div.

hperrin commented 7 years ago

Does the inner div have position: relative;?

aksharj commented 7 years ago

Hello There,

nope, the div does not have position relative.

hperrin commented 6 years ago

I'm gonna close this and assume you got it working. If you need any more help with this, please reopen it.