12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- 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;
|