Skip to content

Commit

Permalink
Tab: fix tabs-item's padding cause active-bar's width and transform …
Browse files Browse the repository at this point in the history
…err( … ElemeFE#15355) (ElemeFE#16520)

* Tab: Refactor tabs-item's padding with dynamic value
  • Loading branch information
victorting authored and lzq4047 committed May 22, 2020
1 parent 0b49dff commit a8c4265
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/tabs/src/tab-bar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,17 @@
return true;
} else {
tabSize = $el[`client${firstUpperCase(sizeName)}`];
const tabStyles = window.getComputedStyle($el);
if (sizeName === 'width' && this.tabs.length > 1) {
tabSize -= (index === 0 || index === this.tabs.length - 1) ? 20 : 40;
tabSize -= parseFloat(tabStyles.paddingLeft) + parseFloat(tabStyles.paddingRight);
}
if (sizeName === 'width') {
offset += parseFloat(tabStyles.paddingLeft);
}
return false;
}
});
if (sizeName === 'width' && offset !== 0) {
offset += 20;
}
const transform = `translate${firstUpperCase(sizeDir)}(${offset}px)`;
style[sizeName] = tabSize + 'px';
style.transform = transform;
Expand Down

0 comments on commit a8c4265

Please sign in to comment.