Merge pull request #116 from amritrai5757/main

Resolved  previous color selection. Issue #111
This commit is contained in:
Nicola 2023-02-09 14:41:41 +01:00 committed by GitHub
commit b1f1564b7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

@ -158,14 +158,15 @@ const ColorModule = (() => {
*/
function addColorButtonEvent() {
//generate random color
const newColor = new Color("hsv", Math.floor(Math.random()*360), Math.floor(Math.random()*100), Math.floor(Math.random()*100)).hex;
//remove current color selection
document.querySelector('#colors-menu li.selected')?.classList.remove('selected');
const newColor = new Color("hsv", Math.floor(Math.random()*360), Math.floor(Math.random()*100), Math.floor(Math.random()*100)).hex;
//add new color and make it selected
let addedColor = addColor(newColor);
addedColor.classList.add('selected');
//remove previous color selection
document.querySelector('#colors-menu li.selected')?.classList.remove('selected');
addedColor.style.width = squareSize + "px";
addedColor.style.height = squareSize + "px";
updateCurrentColor(newColor);