Skip to content

Commit 22540ee

Browse files
committed
Deal with subpixel precision when calculating targetWidth
Issue #68
1 parent c83e48d commit 22540ee

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Truncate.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,10 @@ export default class Truncate extends Component {
132132
return;
133133
}
134134

135-
const targetWidth = target.parentNode.getBoundingClientRect().width;
135+
// Floor the result to deal with browser subpixel precision
136+
const targetWidth = Math.floor(
137+
target.parentNode.getBoundingClientRect().width
138+
);
136139

137140
// Delay calculation until parent node is inserted to the document
138141
// Mounting order in React is ChildComponent, ParentComponent

0 commit comments

Comments
 (0)