No Way To Set Initial Color After Init
jwbats opened this issue · 1 comments
Afaik, there is currently no way to set the initial color once the picker has already been initialized.
Real life use case:
I want to set the color picker's initial color to the same color of the object that I have just selected in my fabricjs canvas, which has multiple objects of various colors.
I have to reinitialize the whole thing in order to get set an initial color. It works and thankfully does not make my interface glitchy, but it is cumbersome.
I am currently destroying the object before reinitializing it with the initial color of choice. Is this necessary, or can I just leave out the destroy call without worrying about memory bloat?
I use this so with palette, so when user click on different color he can pick initial color, by default if you use color option you can click on it again after changing color.
$('.color').each(function() {
var self = $(this);
var color = this.style.getPropertyValue('--color').trim();
self.spectrum({
show: function() {
self.spectrum('option', 'color', color);
self.find('[title="' + color + '"]').addClass('sp-thumb-active');
}
});
});
don't know if option change anything