UNPKG

@antv/f2

Version:

Charts for mobile visualization.

89 lines 2.62 kB
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray"; import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; import _createClass from "@babel/runtime/helpers/esm/createClass"; import { mix } from '@antv/util'; var Layout = /*#__PURE__*/function () { function Layout(layout) { _classCallCheck(this, Layout); this.left = 0; this.top = 0; this.width = 0; this.height = 0; this.update(layout); } _createClass(Layout, [{ key: "update", value: function update(layout) { mix(this, layout); var left = this.left, top = this.top, width = this.width, height = this.height; this.right = left + width; this.bottom = top + height; return this; } }, { key: "padding", value: function padding(style) { if (!style) { return this; } var _style$top = style.top, paddingTop = _style$top === void 0 ? 0 : _style$top, _style$right = style.right, paddingRight = _style$right === void 0 ? 0 : _style$right, _style$bottom = style.bottom, paddingBottom = _style$bottom === void 0 ? 0 : _style$bottom, _style$left = style.left, paddingLeft = _style$left === void 0 ? 0 : _style$left; var top = this.top, right = this.right, bottom = this.bottom, left = this.left; this.top = top + paddingTop; this.right = right - paddingRight; this.bottom = bottom - paddingBottom; this.left = left + paddingLeft; this.width = this.right - this.left; this.height = this.bottom - this.top; return this; } }, { key: "clone", value: function clone() { var left = this.left, top = this.top, width = this.width, height = this.height; return new Layout({ left: left, top: top, width: width, height: height }); } }], [{ key: "fromStyle", value: function fromStyle(style) { var left = style.left, top = style.top, width = style.width, height = style.height, padding = style.padding; var _padding = _slicedToArray(padding, 4), paddingTop = _padding[0], paddingRight = _padding[1], paddingBottom = _padding[2], paddingLeft = _padding[3]; return new Layout({ left: left + paddingLeft, top: top + paddingTop, width: width - paddingLeft - paddingRight, height: height - paddingTop - paddingBottom }); } }]); return Layout; }(); export default Layout;