PitPik/colorPicker

appendTo different from document.body causes wrong placement using jsColorPicker

Opened this issue · 2 comments

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;';

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

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