kylepaulsen / NanoModal

A small, self-contained JavaScript modal library with some extra features.
MIT License
47 stars 5 forks source link

howto position? #10

Open ghost opened 8 years ago

ghost commented 8 years ago

the position of the popups seems "hardwired" into the css and on long pages the popup may easily end up "out of sight".

What would I do to ensure the popup is always displayed in the visible part of the page or near the mouse click? Can't seem to find the api to pass the position.

kylepaulsen commented 8 years ago

This is the easy fix as seen in the readme:

.nanoModal.nanoModalOverride {
    position: fixed;
}

If you want it to be extra custom, you'll have to use js to position it yourself.

ghost commented 8 years ago

doing it in JavaScript seem better in my case anyway. Do I need to take special care where exactly to the document I attach the css?

kylepaulsen commented 8 years ago

You probably don't need to do anything more special than something like (when using jquery):

// if you want it near the mouse click
$(".nanoModal").css({
    top: mouseY + someOffset,
    left: mouseX + someOtherOffset
});

But this is just a guess.

ghost commented 8 years ago

No jquery here, I am experimenting in the context of a PageMod script of a Firefox extension where I want very little external dependencies.

At the same time I am slightly nervous as it will is displayed over a webpage which is not under my control - my javascript is fully sandboxed but in theory the webpage could attempt to sabotage me by defining conflicting CSS.