blob: 1e4e2df75be09da8d58fd364ce31e2a169e4134b [file] [log] [blame]
import {
styleDiv,
} from '../../utils/common';
import createNS from '../../utils/helpers/svg_elements';
import createTag from '../../utils/helpers/html_elements';
import BaseRenderer from '../../renderers/BaseRenderer';
import SVGBaseElement from '../svgElements/SVGBaseElement';
import CVEffects from '../canvasElements/CVEffects';
import MaskElement from '../../mask';
function HBaseElement() {}
HBaseElement.prototype = {
checkBlendMode: function () {},
initRendererElement: function () {
this.baseElement = createTag(this.data.tg || 'div');
if (this.data.hasMask) {
this.svgElement = createNS('svg');
this.layerElement = createNS('g');
this.maskedElement = this.layerElement;
this.svgElement.appendChild(this.layerElement);
this.baseElement.appendChild(this.svgElement);
} else {
this.layerElement = this.baseElement;
}
styleDiv(this.baseElement);
},
createContainerElements: function () {
this.renderableEffectsManager = new CVEffects(this);
this.transformedElement = this.baseElement;
this.maskedElement = this.layerElement;
if (this.data.ln) {
this.layerElement.setAttribute('id', this.data.ln);
}
if (this.data.cl) {
this.layerElement.setAttribute('class', this.data.cl);
}
if (this.data.bm !== 0) {
this.setBlendMode();
}
},
renderElement: function () {
var transformedElementStyle = this.transformedElement ? this.transformedElement.style : {};
if (this.finalTransform._matMdf) {
var matrixValue = this.finalTransform.mat.toCSS();
transformedElementStyle.transform = matrixValue;
transformedElementStyle.webkitTransform = matrixValue;
}
if (this.finalTransform._opMdf) {
transformedElementStyle.opacity = this.finalTransform.mProp.o.v;
}
},
renderFrame: function () {
// If it is exported as hidden (data.hd === true) no need to render
// If it is not visible no need to render
if (this.data.hd || this.hidden) {
return;
}
this.renderTransform();
this.renderRenderable();
this.renderElement();
this.renderInnerContent();
if (this._isFirstFrame) {
this._isFirstFrame = false;
}
},
destroy: function () {
this.layerElement = null;
this.transformedElement = null;
if (this.matteElement) {
this.matteElement = null;
}
if (this.maskManager) {
this.maskManager.destroy();
this.maskManager = null;
}
},
createRenderableComponents: function () {
this.maskManager = new MaskElement(this.data, this, this.globalData);
},
addEffects: function () {
},
setMatte: function () {},
};
HBaseElement.prototype.getBaseElement = SVGBaseElement.prototype.getBaseElement;
HBaseElement.prototype.destroyBaseElement = HBaseElement.prototype.destroy;
HBaseElement.prototype.buildElementParenting = BaseRenderer.prototype.buildElementParenting;
export default HBaseElement;