-
Notifications
You must be signed in to change notification settings - Fork 514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Notifications center position #46
Comments
ok I found a solution $.pnotify({
title: "this is center",
text: "blablabla",
opacity: 0.90,
type: "info",
width:"390px",
before_open: function(pnotify){
pnotify.css({
"top":"50px",
"left": ($(window).width() / 2) - (pnotify.width() / 2)
});
}
}); |
when you do this though, the notification doesn't move when the screen is re-sized. so if you're resizing to a smaller screen you just lose your notification/alert/form offscreen. any hints for a fix? |
you can recenter the notification every time the screen is re-sized function get_center_pos(width, top){
// top is empty when creating a new notification and is set when recentering
if (!top){
top = 30;
// this part is needed to avoid notification stacking on top of each other
$('.ui-pnotify').each(function() { top += $(this).outerHeight() + 20; });
}
return {"top": top, "left": ($(window).width() / 2) - (width / 2)}
}
$(document).ready(function () {
new PNotify({
title: "this is center",
text: "blablabla",
opacity: 0.90,
type: "info",
width:"390px",
before_open: function (PNotify) {
PNotify.get().css(get_center_pos(PNotify.get().width()));
}
});
$(window).resize(function () {
$(".ui-pnotify").each(function () {
$(this).css(get_center_pos($(this).width(), $(this).position().top))
});
});
}); |
Hi, |
Yeah this trick does not work in the latest release.Confirmed from myend. |
This should be done with a stack. |
This should work for you: var stack_center = {"dir1": "down", "dir2": "right", "firstpos1": 25, "firstpos2": ($(window).width() / 2) - (Number(PNotify.prototype.options.width.replace(/\D/g, '')) / 2)};
$(window).resize(function(){
stack_center.firstpos2 = ($(window).width() / 2) - (Number(PNotify.prototype.options.width.replace(/\D/g, '')) / 2);
});
new PNotify({text: "Hi there.", stack: stack_center}); |
Thanks hperrin! That stack should be included on the release. |
It's possible to align the notification in the center (top) of the page ?
thanks
The text was updated successfully, but these errors were encountered: