From b63cc1e098ace8e6d3dfb9c368e77940ba4fc5fb Mon Sep 17 00:00:00 2001
From: Ardis Lu
Note that overflow: hidden will only hide text that is outside the
- container element. So if you resize the paragraph to cut through the middle of a line, the ellipsis will appear in
+ container element. So if you resize the paragraph to cut through the middle of a line, the ellipsis will appear on
the line above it but the cut-off text will still be visible.
- If your paragraph's height is dynamic, it's useful to add some JavaScript to snap the paragraph's height to
- a multiple of its line-height whenever the paragraph is resized. To do so, update the event listener like so:
+ If your paragraph's height is dynamic, it's useful to add some JavaScript to snap the paragraph's height to a multiple of
+ its line-height whenever the paragraph is resized. To do so, update the event listener:
new ResizeObserver(_ => {
@@ -247,7 +247,7 @@ new ResizeObserver(_ => {
elem.style.setProperty('--lines', lines);
elem.style.setProperty('height', `${lines * lineHeight}px`);
}).observe(elem);
- Lastly, it's best to debounce the event listener for better performance and to prevent the event listener from fighting with +
It's also best to debounce the event listener for better performance and to prevent the event listener from fighting with the user for control over the element's height while the user is resizing it. Using this basic debounce function:
function debounce(fn, wait) {
--
2.47.3