mirror of
https://github.com/lospec/pixel-editor.git
synced 2023-08-10 21:12:51 +03:00
Issue of removal of all colors from palette
This commit is contained in:
parent
d928f897a4
commit
153f0366d4
@ -108,22 +108,20 @@ const PaletteBlock = (() => {
|
|||||||
startIndex = endIndex;
|
startIndex = endIndex;
|
||||||
endIndex = tmp;
|
endIndex = tmp;
|
||||||
}
|
}
|
||||||
// If total colors in palette is more than colors selected -> remove all selected colors
|
// If there is only 1 color in palette and user wants to remove it, do nothing
|
||||||
if(coloursList.childElementCount > Math.abs(startIndex-endIndex)+1) {
|
if(coloursList.childElementCount == 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If user wants to remove all colors of palette, remove all colors except last one
|
||||||
|
if(coloursList.childElementCount == endIndex-startIndex+1) {
|
||||||
|
endIndex--;
|
||||||
|
}
|
||||||
for (let i=startIndex; i<=endIndex; i++) {
|
for (let i=startIndex; i<=endIndex; i++) {
|
||||||
coloursList.removeChild(coloursList.children[startIndex]);
|
coloursList.removeChild(coloursList.children[startIndex]);
|
||||||
}
|
}
|
||||||
clearBorders();
|
clearBorders();
|
||||||
}
|
}
|
||||||
//else,if there is more than 1 color in palette & user wants to remove all colors -> Remove last color
|
|
||||||
else if(coloursList.childElementCount > 1){
|
|
||||||
coloursList.removeChild(coloursList.children[endIndex]);
|
|
||||||
clearBorders();
|
|
||||||
}
|
|
||||||
|
|
||||||
//To avoid removal of any color by just pressing remove button without selecting any color
|
|
||||||
currentSelection.startIndex=endIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Starts selecting a ramp. Saves the data needed to draw the outline.
|
/** Starts selecting a ramp. Saves the data needed to draw the outline.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user