UNPKG

@visactor/vtable

Version:

canvas table width high performance

28 lines (22 loc) 1.37 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: !0 }), exports.updateTextPose = exports.getTextPos = void 0; const get_prop_1 = require("./get-prop"), padding_1 = require("./padding"); function getTextPos(padding, textAlign, textBaseline, width, height) { let textX = padding[3] || 10; "right" === textAlign || "end" === textAlign ? textX = width - 0 - (padding[1] || 10) : "center" === textAlign && (textX = 0 + (width - 0 + (padding[3] || 10) - (padding[1] || 10)) / 2); let textY = 0 + (padding[0] || 10); return "bottom" === textBaseline || "alphabetic" === textBaseline || "ideographic" === textBaseline ? textY = height - 0 - (padding[2] || 10) : "middle" === textBaseline && (textY = 0 + (height - 0 - (padding[0] || 10) - (padding[2] || 10)) / 2 + (padding[0] || 10)), { x: textX, y: textY }; } function updateTextPose(table, cell, col, row, theme) { const headerStyle = table._getCellStyle(col, row), padding = (0, padding_1.getQuadProps)((0, get_prop_1.getProp)("padding", headerStyle, col, row, table)); cell.getChildByName("text").setAttributes(getTextPos(padding, theme.text.textAlign, theme.text.textBaseline, cell.attribute.width, cell.attribute.height)); } exports.getTextPos = getTextPos, exports.updateTextPose = updateTextPose; //# sourceMappingURL=text-pos.js.map