Moved clickedColor to ColorModule

This commit is contained in:
unsettledgames 2021-07-13 22:27:29 +02:00
parent 53d51c4567
commit 85db99a7c1
3 changed files with 29 additions and 31 deletions

View File

@ -89,9 +89,37 @@ const ColorModule = (() => {
}
}
function clickedColor (e){
//left clicked color
if (e.which == 1) {
// remove current color selection
var selectedColor = document.querySelector('#colors-menu li.selected');
if (selectedColor) selectedColor.classList.remove('selected');
//set current color
for (let i=1; i<layers.length - nAppLayers; i++) {
layers[i].context.fillStyle = this.style.backgroundColor;
}
currentGlobalColor = this.style.backgroundColor;
//make color selected
e.target.parentElement.classList.add('selected');
} else if (e.which == 3) { //right clicked color
//console.log('right clicked color button');
//hide edit color button (to prevent it from showing)
e.target.parentElement.lastChild.classList.add('hidden');
//show color picker
e.target.jscolor.show();
}
}
function addColorButtonEvent() {
//generate random color
const newColor = new Color("hsl", Math.floor(Math.random()*255), 130+Math.floor(Math.random()*100), 70+Math.floor(Math.random()*100)).hex;
const newColor = new Color("hsl", Math.floor(Math.random()*360), 50+Math.floor(Math.random()*50), 50+Math.floor(Math.random()*50)).hex;
//remove current color selection
document.querySelector('#colors-menu li.selected').classList.remove('selected');

View File

@ -1,29 +0,0 @@
//color in palette has been clicked
function clickedColor (e){
//left clicked color
if (e.which == 1) {
// remove current color selection
var selectedColor = document.querySelector('#colors-menu li.selected');
if (selectedColor) selectedColor.classList.remove('selected');
//set current color
for (let i=1; i<layers.length - nAppLayers; i++) {
layers[i].context.fillStyle = this.style.backgroundColor;
}
currentGlobalColor = this.style.backgroundColor;
//make color selected
e.target.parentElement.classList.add('selected');
} else if (e.which == 3) { //right clicked color
//console.log('right clicked color button');
//hide edit color button (to prevent it from showing)
e.target.parentElement.lastChild.classList.add('hidden');
//show color picker
e.target.jscolor.show();
}
}

View File

@ -50,7 +50,6 @@
/**buttons**/
//=include _toolButtons.js
//=include _clickedColor.js
//=include _fileMenu.js
//=include _createButton.js
//=include _rectSelect.js