colorPicker icon indicating copy to clipboard operation
colorPicker copied to clipboard

appendTo different from document.body causes wrong placement using jsColorPicker

Open shooshx opened this issue 9 years ago • 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;';

shooshx avatar May 11 '16 17:05 shooshx

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 avatar May 13 '16 15:05 PitPik

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

PitPik avatar May 18 '16 13:05 PitPik