From 6fadaae6520baf49827eed956f916c53e34fe3bc Mon Sep 17 00:00:00 2001
From: Anthon Astrom
Date: Thu, 27 Jan 2022 07:15:39 +0100
Subject: [PATCH 1/3] Changed line height parsing method for subpixel
calculations
---
lib/index.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/index.js b/lib/index.js
index e126ed4..6fd9e05 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -541,7 +541,7 @@
throw Error('The ellipsis container ' + elementName(el) + ' must have line-height set using px unit, found: ' + lineHeightStr);
}
- var lineHeight = parseInt(lineHeightStr, 10);
+ var lineHeight = parseFloat(lineHeightStr);
if (lineHeight) {
return lineHeight;
}
From 13dbe30d1b11e6bce4f468fb06d91ef5bcfaa7df Mon Sep 17 00:00:00 2001
From: Anthon Astrom
Date: Sat, 23 Apr 2022 19:24:06 +0200
Subject: [PATCH 2/3] forced line-clamp
---
lib/index.js | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/lib/index.js b/lib/index.js
index 6fd9e05..7b8a5da 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -283,11 +283,11 @@
// Use webkit line clamp
// for webkit browsers.
- if (vendor.webkit) {
- child.el.style.webkitLineClamp = child.clampedLines;
- child.el.style.display = '-webkit-box';
- child.el.style.webkitBoxOrient = 'vertical';
- }
+ // if (vendor.webkit) { // Always apply! doesn't hurt
+ child.el.style.webkitLineClamp = child.clampedLines;
+ child.el.style.display = '-webkit-box';
+ child.el.style.webkitBoxOrient = 'vertical';
+ // }
if (this.shouldHideOverflow()) child.el.style.overflow = 'hidden';
From 5ed475d7f83f5530b6b25b24dbfc39bebf5c858b Mon Sep 17 00:00:00 2001
From: Anthon Astrom
Date: Wed, 4 May 2022 08:59:00 +0200
Subject: [PATCH 3/3] Tweaked lineCount handling
---
lib/index.js | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/index.js b/lib/index.js
index 7b8a5da..d35aa0b 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -177,6 +177,8 @@
child.clampedHeight += child.gutterSpan * self.deltaHeight;
}
+ // console.log('UNDERFLOW',overflow,underflow,child.clampedHeight,el)
+
return child;
}
});
@@ -202,6 +204,7 @@
*/
Ellipsis.prototype.getLineCount = function(el) {
+ // console.log('LINES',el.clientHeight,this.lineHeight,el.clientHeight/this.lineHeight,this.linesPerColumn,el)
return (el.offsetWidth > this.columnWidth)
? getLinesFromRects(el, this.lineHeight)
: lineCount(el.clientHeight, this.lineHeight);
@@ -467,7 +470,7 @@
*/
function lineCount(height, lineHeight) {
- return Math.floor(height / lineHeight);
+ return Math.round(height / lineHeight);
}
/**