UNPKG

@visactor/vtable

Version:

canvas table width high performance

19 lines (16 loc) 1.07 kB
"use strict"; function calcStartPosition(left, top, width, height, contentWidth, contentHeight, textAlign = "left", textBaseline = "middle", margin = [ 0, 0, 0, 0 ], paddingLeft = 0, paddingRight = 0, paddingTop = 0, paddingBottom = 0) { const right = left + width, bottom = top + height; let x = left + margin[3] + paddingLeft; "right" === textAlign || "end" === textAlign ? x = right - contentWidth - margin[1] - paddingRight : "center" === textAlign && (x = left + (width - contentWidth + paddingLeft - paddingRight) / 2); let y = top + margin[0] + paddingTop; return "bottom" === textBaseline || "alphabetic" === textBaseline || "ideographic" === textBaseline ? y = bottom - contentHeight - margin[2] - paddingBottom : "middle" === textBaseline && (y = top + (height - contentHeight + paddingTop - paddingBottom) / 2), { x: x, y: y }; } Object.defineProperty(exports, "__esModule", { value: !0 }), exports.calcStartPosition = void 0, exports.calcStartPosition = calcStartPosition; //# sourceMappingURL=cell-pos.js.map