fix palette

This commit is contained in:
JFH
2020-11-29 01:19:09 +01:00
parent a7766d0764
commit 8ab5d331c8
3 changed files with 32 additions and 8 deletions

View File

@@ -56,10 +56,17 @@ export class SEPalette extends HTMLElement {
* @returns {void}
*/
connectedCallback () {
this.$strip.addEventListener('click', (e) => {
e.preventDefault();
console.log(e);
this.dispatchEvent(this.$event);
this.$strip.addEventListener('click', (evt) => {
evt.preventDefault();
// shift key or right click for stroke
const picker = evt.shiftKey || evt.button === 2 ? 'stroke' : 'fill';
let color = this.$strip.currentItem.dataset.rgb;
// Webkit-based browsers returned 'initial' here for no stroke
if (color === 'none' || color === 'transparent' || color === 'initial') {
color = 'none';
}
const paletteEvent = new CustomEvent('change', {detail: {picker, color}, bubbles: false});
this.dispatchEvent(paletteEvent);
});
}
}