UNPKG

sketch-json-parse

Version:

sketch-json解析

20 lines (19 loc) 653 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * 处理父元素是文本的情况, 子元素使用 absoulte 定位 * * @param {*} data */ const handleParentIsText = (data, parent) => { parent.style['position'] = parent.style['position'] ? parent.style['position'] : 'relative'; for (let child of data) { child.style = Object.assign(Object.assign({}, child.style), { 'position': 'absolute', 'left': child.structure.x - parent.structure.x, 'top': child.structure.y - parent.structure.y }); } return data; }; exports.default = handleParentIsText;