PitPik / colorPicker

Advanced javaScript color picker and color conversion / calculation (rgb, hsv, hsl, hex, cmyk, cmy, XYZ, Lab, alpha, WCAG 2.0, ...)
http://www.dematte.at/colorPicker/
MIT License
570 stars 136 forks source link

appendTo different from document.body causes wrong placement using jsColorPicker #41

Open shooshx opened 8 years ago

shooshx commented 8 years ago

If I pass jsColorPicker() an appendTo element that is different from document.body and does is not placed at (0,0), the created color picker popup will be placed in an offset from where its supposed to be, the same offset the appendTo element is from (0,0) The fix is (jsColor.js) line 109: add var atrect = (options.appendTo || document.body).getBoundingClientRect();

line 112: 'left:' + (position.left + options.margin.left - atrect.left) + 'px;' + 'top:' + (position.top + +input.offsetHeight + options.margin.top - atrect.top) + 'px;';

PitPik commented 8 years ago

Hi @shooshx,

thanks for your participation. I will check this as soon as possible (I'm on the road ;o) and will take over your suggestion. Looks good.

Cheers Peter

PitPik commented 8 years ago

Hi @shooshx, thanks again for this hint and solution. I just updated the JS and jQuery implementation (including a new method .toString()). I had to add a check though if the appendTo element is positioned other than static...

Thanks and keep the good spirit ;o) Cheers