pixel-editor/js/_clickedColor.js

28 lines
855 B
JavaScript
Raw Normal View History

2019-03-27 02:20:54 +03:00
//color in palette has been clicked
function clickedColor (e){
//left clicked color
if (e.which == 1) {
2020-04-04 10:41:56 +03:00
// remove current color selection
var selectedColor = document.querySelector('#colors-menu li.selected');
if (selectedColor) selectedColor.classList.remove('selected');
2019-03-27 02:20:54 +03:00
2020-04-04 10:41:56 +03:00
//set current color
currentLayer.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();
2019-03-27 02:20:54 +03:00
}
}
2020-04-04 10:41:56 +03:00