From 901fdced904536951acda56a382c5694a75e2ab4 Mon Sep 17 00:00:00 2001 From: amritrai5757 Date: Tue, 3 Jan 2023 06:29:19 +0000 Subject: [PATCH 1/3] Fixed removal of all the colors from palette --- js/PaletteBlock.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/js/PaletteBlock.js b/js/PaletteBlock.js index 3035e43..5189d79 100644 --- a/js/PaletteBlock.js +++ b/js/PaletteBlock.js @@ -109,10 +109,17 @@ const PaletteBlock = (() => { endIndex = tmp; } - for (let i=startIndex; i<=endIndex; i++) { - coloursList.removeChild(coloursList.children[startIndex]); + 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 Date: Tue, 3 Jan 2023 12:58:14 +0000 Subject: [PATCH 2/3] Issue of removal of all colors from palette --- js/PaletteBlock.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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. From 153f0366d4aa588ed4ebaace4cf621bec365d925 Mon Sep 17 00:00:00 2001 From: amritrai5757 Date: Tue, 3 Jan 2023 13:57:55 +0000 Subject: [PATCH 3/3] Issue of removal of all colors from palette --- js/PaletteBlock.js | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/js/PaletteBlock.js b/js/PaletteBlock.js index c841856..e6056ba 100644 --- a/js/PaletteBlock.js +++ b/js/PaletteBlock.js @@ -108,21 +108,19 @@ 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 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(); + // If there is only 1 color in palette and user wants to remove it, do nothing + if(coloursList.childElementCount == 1) { + return; } - - //To avoid removal of any color by just pressing remove button without selecting any color - currentSelection.startIndex=endIndex; + + // 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++) { + coloursList.removeChild(coloursList.children[startIndex]); + } + clearBorders(); } /** Starts selecting a ramp. Saves the data needed to draw the outline.