Issue of removal of all colors from palette

This commit is contained in:
amritrai5757 2023-01-03 12:58:14 +00:00
parent 901fdced90
commit d928f897a4
1 changed files with 8 additions and 5 deletions

View File

@ -108,18 +108,21 @@ 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(coloursList.childElementCount > Math.abs(startIndex-endIndex)+1) { if(coloursList.childElementCount > Math.abs(startIndex-endIndex)+1) {
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(coloursList.childElementCount > 1){ }
for (let i=startIndex; i<endIndex; i++) { //else,if there is more than 1 color in palette & user wants to remove all colors -> Remove last color
coloursList.removeChild(coloursList.children[startIndex]); else if(coloursList.childElementCount > 1){
} coloursList.removeChild(coloursList.children[endIndex]);
clearBorders(); 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.