#46 paintbox and current element color set issue fixed

master
Agriya Dev5 2021-02-05 19:31:12 +05:30
parent 2a59e75cab
commit 166b602887
2 changed files with 6 additions and 7 deletions

View File

@ -1,4 +1,3 @@
/* globals $ */
import {jGraduate} from './jgraduate/jQuery.jGraduate.js';
/**
*
@ -21,7 +20,7 @@ class PaintBox {
let docElem = svgdocbox.documentElement;
docElem = document.importNode(docElem, true);
container.append(docElem);
container.appendChild(docElem);
this.rect = docElem.firstElementChild;
this.defs = docElem.getElementsByTagName('defs')[0];
@ -49,7 +48,7 @@ class PaintBox {
case 'radialGradient': {
this.grad.remove();
this.grad = paint[ptype];
this.defs.append(this.grad);
this.defs.appendChild(this.grad);
const id = this.grad.id = 'gradbox_' + this.type;
fillAttr = 'url(#' + id + ')';
break;
@ -71,7 +70,7 @@ class PaintBox {
const opts = {alpha: opac};
if (color.startsWith('url(#')) {
let refElem = svgCanvas.getRefElem(color);
refElem = (refElem) ? refElem.cloneNode(true) : $('#' + type + '_color defs *')[0];
refElem = (refElem) ? refElem.cloneNode(true) : document.querySelectorAll('#' + type + '_color defs *')[0];
opts[refElem.tagName] = refElem;
} else if (color.startsWith('#')) {
opts.solidColor = color.substr(1);

View File

@ -170,13 +170,13 @@ export class SeColorPicker extends HTMLElement {
*/
connectedCallback () {
this.paintBox = new PaintBox(this.$block, this.type);
let {paint} = this.paintBox;
$(this.$picker).click(() => {
/* $(this.$color_picker)
.draggable({
cancel: '.jGraduate_tabs, .jGraduate_colPick, .jGraduate_gradPick, .jPicker',
containment: 'window'
}); */
let {paint} = this.paintBox;
jGraduateMethod(
this.$color_picker,
{
@ -192,10 +192,10 @@ export class SeColorPicker extends HTMLElement {
paint
}});
this.dispatchEvent(changeEvent);
$('#color_picker').hide();
this.$color_picker.style.display = 'none';
},
() => {
$('#color_picker').hide();
this.$color_picker.style.display = 'none';
}
);
});