zent
Version:
一套前端设计语言和基于React的实现
62 lines (55 loc) • 1.66 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
var navUtil = {
// 获取宽高
getOffsetWH: function getOffsetWH(node) {
var prop = 'offsetWidth';
return node[prop];
},
// 获取偏移量
getOffsetLT: function getOffsetLT(node) {
var prop = 'left';
return node.getBoundingClientRect()[prop];
},
modifyTabListData: function modifyTabListData(props) {
var widthInfo = this.getWidth(props) || {};
var tabListData = props.tabListData,
candel = props.candel;
var modifiedTabListData = [];
var modifiedTabInfo = void 0;
tabListData.forEach(function (tabItem, i) {
modifiedTabInfo = {
key: tabItem.key,
actived: tabItem.actived,
disabled: tabItem.disabled,
title: tabItem.title,
prefix: tabItem.prefix,
className: tabItem.tabClassName,
minWidth: i === tabListData.length - 1 ? widthInfo.lastWidth || '' : widthInfo.width || '',
candel: candel && !tabItem.disabled
};
modifiedTabListData.push(modifiedTabInfo);
});
return modifiedTabListData;
},
getWidth: function getWidth(props) {
// 当align为center时做处理
var align = props.align,
tabListData = props.tabListData;
if (align === 'center') {
var width = '';
var lastWidth = '';
var childCount = tabListData.length;
width = 1 / childCount * 100 + '%';
lastWidth = (1 - 1 / childCount * (childCount - 1)) * 100 + '%';
return {
width: width,
lastWidth: lastWidth
};
}
}
};
exports['default'] = navUtil;
module.exports = exports['default'];
;