sciactive / pnotify

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

Positioning on id html element #311

Closed gordett closed 6 years ago

gordett commented 6 years ago

Hello,

is this possible ?

Like this example on https://notifyjs.com/

Positioning The position string option is used to describe both vertical and horizontal alignment. Element notifications and Global notifications can be vertically repositioned to: "top", "middle" or "bottom" and horozontally repositioned to: "left", "center" or "right". If we don't provide a position option the default alignments are defined in the default settings: globalPosition and elementPosition. When only one alignment is provided, the vertical alignment is middle and horizontal alignment is centre.

$(".pos-demo").notify( "I'm to the right of this box", { position:"right" } );

hperrin commented 6 years ago

This is possible, except the middle position would take a bit more work than what they allow.

In PNotify, you would accomplish this with a custom stack. You can define your stack like this:

const customStackTopLeft = {"dir1": "down", "dir2": "right", "push": "top"};

And you would use your stack like this:

const notice = new PNotify({
  text: "I'm in the top left corner.",
  stack: customStackTopLeft,
  addclass: "stack-topleft"
});

The dir1 and dir2 determine the direction that the notices in that stack wrap. dir1 being down means that the next notice will be below the first notice. dir2 being right means that once the columns fill the screen height, the next column will be to the right. Adding the stack-topleft class will position the notices into the top left corner.

The included positioning classes are:

Positioning a stack in the middle of the screen would be a bit harder, as there is not a class provided that will do that for you. You'll have to create a class that positions the notices and add it.