simonwep / pickr

🎨 Flat, simple, multi-themed, responsive and hackable Color-Picker library. No dependencies, no jQuery. Compatible with all CSS Frameworks e.g. Bootstrap, Materialize. Supports alpha channel, rgba, hsla, hsva and more!
https://simonwep.github.io/pickr
MIT License
4.29k stars 287 forks source link

Is there any way to set the position of the pickr independently of the button? #239

Closed GreenFootballs closed 4 years ago

GreenFootballs commented 4 years ago

In an app I'm developing I have a key command that opens the pickr. If the trigger button isn't currently visible when the key is typed, the pickr appears in the center of the window. Is there a way to set the position in the 'show' method, independently of the button's position? I'd like to have it pop open at the current mouse position, for example, to make it easier to set the color of an object that was just selected with the mouse.

GreenFootballs commented 4 years ago

Closing this because I discovered you can set the css top and left in the 'show' method. Works great!

The code looks like this:

.on("show", (color, instance) => { const style = instance.getRoot().app.style; style.left = myLeft; style.top = myTop; })