Skip to content

Commit

Permalink
fix(module:avatar): fix text style
Browse files Browse the repository at this point in the history
  • Loading branch information
hsuanxyz committed Nov 26, 2018
1 parent f6361b6 commit cc75c9a
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions components/avatar/nz-avatar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,13 @@ export class NzAvatarComponent implements OnChanges {
const childrenWidth = this.textEl.nativeElement.offsetWidth;
const avatarWidth = this.el.getBoundingClientRect().width;
const scale = avatarWidth - 8 < childrenWidth ? (avatarWidth - 8) / childrenWidth : 1;
if (scale === 1) {
this.textStyles = {};
} else {
this.textStyles = {
transform: `scale(${scale})`,
position : 'absolute',
display : 'inline-block',
left : `calc(50% - ${Math.round(childrenWidth / 2)}px)`
};
this.textStyles = {
transform: `scale(${scale}) translateX(-50%)`
};
if (typeof this.nzSize === 'number') {
Object.assign(this.textStyles, {
lineHeight: `${this.nzSize}px`
});
}
this.cd.detectChanges();
}
Expand Down

0 comments on commit cc75c9a

Please sign in to comment.