Skip to content

Commit

Permalink
More es6
Browse files Browse the repository at this point in the history
  • Loading branch information
pnicolli committed Sep 7, 2017
1 parent a9385e7 commit e23e6fa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions lib/ellipsed.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,23 @@ function ellipsed() {
var token = _step2.value;

if (el.textContent.length) {
el.textContent = el.textContent.concat(' ').concat(token).concat('...');
el.textContent = el.textContent + ' ' + token + '...';
} else {
el.textContent = el.textContent.concat(token).concat('...');
el.textContent = '' + el.textContent + token + '...';
}

if (parseFloat(window.getComputedStyle(el).height) > parseFloat(elHeight)) {
elHeight = window.getComputedStyle(el).height;
rowsWrapped++;

if (rowsWrapped === rows + 1) {
el.innerHTML = textBeforeWrap[textBeforeWrap.length - 1] === '.' ? textBeforeWrap.concat('..') : textBeforeWrap.concat('...');
el.innerHTML = textBeforeWrap[textBeforeWrap.length - 1] === '.' ? textBeforeWrap + '..' : textBeforeWrap + '...';

break;
}
}

textBeforeWrap = textBeforeWrap.length ? textBeforeWrap.concat(' ').concat(token) : textBeforeWrap.concat(token);
textBeforeWrap = textBeforeWrap.length ? textBeforeWrap + ' ' + token : '' + textBeforeWrap + token;
el.textContent = textBeforeWrap;
}
} catch (err) {
Expand Down
12 changes: 6 additions & 6 deletions src/ellipsed.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ function ellipsed(selector = '', rows = 1) {

for (const token of splittedText) {
if (el.textContent.length) {
el.textContent = el.textContent.concat(' ').concat(token).concat('...');
el.textContent = `${el.textContent} ${token}...`;
} else {
el.textContent = el.textContent.concat(token).concat('...');
el.textContent = `${el.textContent}${token}...`;
}

if (parseFloat(window.getComputedStyle(el).height) > parseFloat(elHeight)) {
Expand All @@ -41,16 +41,16 @@ function ellipsed(selector = '', rows = 1) {

if (rowsWrapped === rows + 1) {
el.innerHTML = textBeforeWrap[textBeforeWrap.length - 1] === '.'
? textBeforeWrap.concat('..')
: textBeforeWrap.concat('...');
? `${textBeforeWrap}..`
: `${textBeforeWrap}...`;

break;
}
}

textBeforeWrap = textBeforeWrap.length
? textBeforeWrap.concat(' ').concat(token)
: textBeforeWrap.concat(token);
? `${textBeforeWrap} ${token}`
: `${textBeforeWrap}${token}`;
el.textContent = textBeforeWrap;
}
}
Expand Down

0 comments on commit e23e6fa

Please sign in to comment.