diff --git a/js/PaletteBlock.js b/js/PaletteBlock.js index 5189d79..c841856 100644 --- a/js/PaletteBlock.js +++ b/js/PaletteBlock.js @@ -108,18 +108,21 @@ const PaletteBlock = (() => { startIndex = endIndex; endIndex = tmp; } - + // If total colors in palette is more than colors selected -> remove all selected colors if(coloursList.childElementCount > Math.abs(startIndex-endIndex)+1) { for (let i=startIndex; i<=endIndex; i++) { coloursList.removeChild(coloursList.children[startIndex]); } clearBorders(); - } else if(coloursList.childElementCount > 1){ - for (let i=startIndex; i 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.