mirror of
https://github.com/lospec/pixel-editor.git
synced 2023-08-10 21:12:51 +03:00
Moved clickedColor to ColorModule
This commit is contained in:
parent
53d51c4567
commit
85db99a7c1
@ -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');
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,6 @@
|
||||
|
||||
/**buttons**/
|
||||
//=include _toolButtons.js
|
||||
//=include _clickedColor.js
|
||||
//=include _fileMenu.js
|
||||
//=include _createButton.js
|
||||
//=include _rectSelect.js
|
||||
|
Loading…
Reference in New Issue
Block a user