Fixed removal of all colors from palette

This commit is contained in:
amritrai5757 2022-12-30 06:14:11 +00:00
parent c2014682d0
commit 501ef33df2
1 changed files with 8 additions and 4 deletions

View File

@ -108,11 +108,15 @@ const PaletteBlock = (() => {
startIndex = endIndex;
endIndex = tmp;
}
for (let i=startIndex; i<=endIndex; i++) {
coloursList.removeChild(coloursList.children[startIndex]);
// Checks if user is trying to remove all the colours from the palette and gives an alert if so
if(coloursList.childElementCount > Math.abs(startIndex-endIndex)+1) {
for (let i=startIndex; i<=endIndex; i++) {
coloursList.removeChild(coloursList.children[startIndex]);
}
clearBorders();
} else {
alert("You can't remove all the colours from the palette!");
}
clearBorders();
}
/** Starts selecting a ramp. Saves the data needed to draw the outline.