Fixed bug that caused the wrong colour to be modified with jscolor
This commit is contained in:
parent
f5807417ec
commit
1daeb81ef4
|
@ -22,7 +22,7 @@ const ColorModule = (() => {
|
||||||
// Changes all of one color to another after being changed from color picker
|
// Changes all of one color to another after being changed from color picker
|
||||||
function colorChanged(colorHexElement) {
|
function colorChanged(colorHexElement) {
|
||||||
console.log("Clicked:");
|
console.log("Clicked:");
|
||||||
console.log(colorHexElement);
|
console.log(colorHexElement.target);
|
||||||
// Get old and new colors from the element
|
// Get old and new colors from the element
|
||||||
const hexElement = colorHexElement.target;
|
const hexElement = colorHexElement.target;
|
||||||
const hexElementValue = hexElement.value;
|
const hexElementValue = hexElement.value;
|
||||||
|
@ -31,7 +31,7 @@ const ColorModule = (() => {
|
||||||
|
|
||||||
//if the color is not a valid hex color, exit this function and do nothing
|
//if the color is not a valid hex color, exit this function and do nothing
|
||||||
const newColorHex = hexElementValue.toLowerCase();
|
const newColorHex = hexElementValue.toLowerCase();
|
||||||
if (/^[0-9a-f]{6}$/i.test(newColorHex) == false) return
|
if (/^[0-9a-f]{6}$/i.test(newColorHex) == false) return;
|
||||||
|
|
||||||
currentPalette.splice(currentPalette.indexOf("#" + newColor), 1);
|
currentPalette.splice(currentPalette.indexOf("#" + newColor), 1);
|
||||||
newColor.a = 255;
|
newColor.a = 255;
|
||||||
|
@ -180,13 +180,13 @@ const ColorModule = (() => {
|
||||||
newEditButton = editButtonTemplate.cloneNode(true);
|
newEditButton = editButtonTemplate.cloneNode(true);
|
||||||
listItem.appendChild(newEditButton);
|
listItem.appendChild(newEditButton);
|
||||||
|
|
||||||
newEditButton.addEventListener('click', () => {
|
newEditButton.addEventListener('click', (event) => {
|
||||||
//hide edit button
|
//hide edit button
|
||||||
newEditButton.parentElement.lastChild.classList.add('hidden');
|
event.target.parentElement.lastChild.classList.add('hidden');
|
||||||
|
|
||||||
//show jscolor picker, if basic mode is enabled
|
//show jscolor picker, if basic mode is enabled
|
||||||
if (pixelEditorMode == 'Basic')
|
if (pixelEditorMode == 'Basic')
|
||||||
newEditButton.parentElement.firstChild.jscolor.show();
|
event.target.parentElement.firstChild.jscolor.show();
|
||||||
else
|
else
|
||||||
showDialogue("palette-block", false);
|
showDialogue("palette-block", false);
|
||||||
});
|
});
|
||||||
|
|
|
@ -318,14 +318,11 @@ function flatten(onlyVisible) {
|
||||||
let nToFlatten = 0;
|
let nToFlatten = 0;
|
||||||
|
|
||||||
for (let i=0; i<layers.length; i++) {
|
for (let i=0; i<layers.length; i++) {
|
||||||
console.log(layers[i].name);
|
|
||||||
if (layers[i].menuEntry != null && layers[i].isVisible) {
|
if (layers[i].menuEntry != null && layers[i].isVisible) {
|
||||||
visibleLayers.push(layers[i]);
|
visibleLayers.push(layers[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("da piallare: " + visibleLayers.length);
|
|
||||||
|
|
||||||
// Sorting them by z-index
|
// Sorting them by z-index
|
||||||
visibleLayers.sort((a, b) => (a.canvas.style.zIndex > b.canvas.style.zIndex) ? -1 : 1);
|
visibleLayers.sort((a, b) => (a.canvas.style.zIndex > b.canvas.style.zIndex) ? -1 : 1);
|
||||||
// Selecting the last visible layer (the only one that won't get deleted)
|
// Selecting the last visible layer (the only one that won't get deleted)
|
||||||
|
|
Loading…
Reference in New Issue