custom.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  3. var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
  4. var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
  5. var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
  6. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  7. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  8. var Shape = require('../shape');
  9. var Custom = /*#__PURE__*/function (_Shape) {
  10. (0, _inheritsLoose2["default"])(Custom, _Shape);
  11. var _super = _createSuper(Custom);
  12. function Custom() {
  13. return _Shape.apply(this, arguments) || this;
  14. }
  15. var _proto = Custom.prototype;
  16. _proto._initProperties = function _initProperties() {
  17. _Shape.prototype._initProperties.call(this);
  18. this._attrs.canFill = true;
  19. this._attrs.canStroke = true;
  20. this._attrs.createPath = null;
  21. this._attrs.type = 'custom';
  22. };
  23. _proto.createPath = function createPath(context) {
  24. var createPath = this.get('createPath');
  25. createPath && createPath.call(this, context);
  26. };
  27. _proto.calculateBox = function calculateBox() {
  28. var calculateBox = this.get('calculateBox');
  29. return calculateBox && calculateBox.call(this);
  30. };
  31. return Custom;
  32. }(Shape);
  33. Shape.Custom = Custom;
  34. module.exports = Custom;