HSolidElement.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import {
  2. extendPrototype,
  3. } from '../../utils/functionExtensions';
  4. import createNS from '../../utils/helpers/svg_elements';
  5. import createTag from '../../utils/helpers/html_elements';
  6. import BaseElement from '../BaseElement';
  7. import TransformElement from '../helpers/TransformElement';
  8. import HierarchyElement from '../helpers/HierarchyElement';
  9. import FrameElement from '../helpers/FrameElement';
  10. import RenderableDOMElement from '../helpers/RenderableDOMElement';
  11. import HBaseElement from './HBaseElement';
  12. function HSolidElement(data, globalData, comp) {
  13. this.initElement(data, globalData, comp);
  14. }
  15. extendPrototype([BaseElement, TransformElement, HBaseElement, HierarchyElement, FrameElement, RenderableDOMElement], HSolidElement);
  16. HSolidElement.prototype.createContent = function () {
  17. var rect;
  18. if (this.data.hasMask) {
  19. rect = createNS('rect');
  20. rect.setAttribute('width', this.data.sw);
  21. rect.setAttribute('height', this.data.sh);
  22. rect.setAttribute('fill', this.data.sc);
  23. this.svgElement.setAttribute('width', this.data.sw);
  24. this.svgElement.setAttribute('height', this.data.sh);
  25. } else {
  26. rect = createTag('div');
  27. rect.style.width = this.data.sw + 'px';
  28. rect.style.height = this.data.sh + 'px';
  29. rect.style.backgroundColor = this.data.sc;
  30. }
  31. this.layerElement.appendChild(rect);
  32. };
  33. export default HSolidElement;