-
-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hide color-picker spectrum when using choices
.
#74
Comments
This seems impossible to be done with the current Here the list of candidates: |
That would be nice. I came here to inspect how hard it would be to add hsl support as I have my palette defined in that. |
Moving away from JSColor would be good as whilst this package is MIT Licensed JSColor is not. It's only GNU GPL v3 for opensource packages any commercial or even private projects would not be able to use this library due to their license. |
@StevenMapes I'm aware of this limitation, unfortunately at the moment I have not the time for working on it. I created this discussion #83. |
Here is a workaround:
Since the jscolor library destroys and recreates the HTML node everytime it's activated, we have to use the |
@Nicholas-Toh great workaround, thanks for sharing it! Considering how JSColor creates/destroys the element I think that this is the only possible solution. |
@Nicholas-Toh I tested your snippet is an admin page with many colorfields because I wanted to implement it, but it seems to have many issues:
Here an improved version of your script in case you would like to adjust it / submit a PR: document.addEventListener('DOMContentLoaded', function () {
const startObserving = (domNode) => {
const observer = new MutationObserver(mutations => {
mutations.forEach(function (mutation) {
const element = Array.from(mutation.addedNodes).find(
element => element.classList && element.classList.contains('jscolor-picker-wrap')
);
if (element) {
const wrapper = element;
const picker = document.querySelector('.jscolor-picker');
const palette = document.querySelector('.jscolor-palette');
document.querySelectorAll(".jscolor-picker > div:not(.jscolor-palette)").forEach((el) => el.remove());
const newHeight = wrapper.offsetHeight - palette.offsetTop + 20;
wrapper.style.height = `${newHeight}px`;
picker.style.height = `${newHeight}px`;
palette.style.top = '20px';
}
});
});
observer.observe(domNode, {
childList: true,
attributes: true,
characterData: true,
subtree: true,
});
return observer;
};
startObserving(document.body);
}); |
The continuation of #68
The text was updated successfully, but these errors were encountered: