Skip to content

Commit

Permalink
Merge pull request #2 from pnicolli/pnicolli_more_es6
Browse files Browse the repository at this point in the history
More es6
  • Loading branch information
Nicola Zambello authored Sep 8, 2017
2 parents a9385e7 + e23e6fa commit 82d5156
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 82d5156

Please sign in to comment.