fregante / fit-textarea

Automatically expand a <textarea> to fit its content, in a few bytes
https://npmjs.com/fit-textarea
MIT License
78 stars 2 forks source link

Try calculating height with Range #5

Closed fregante closed 5 years ago

fregante commented 5 years ago

Perhaps the height of the content can be found by selecting the text and measuring its BoundingBox, and the padding can be added.

If this works, it wouldn’t be necessary to reset the height of the textarea and thus we wouldn’t need to keep track of the scroll position.

Zalgo and lineHeight also needs to be tested

fregante commented 5 years ago

Sadly not possible: https://stackoverflow.com/questions/46516425/why-range-getboundingclientrect-returns-0-for-range-inside-textarea

And definitely not in Firefox https://bugzilla.mozilla.org/show_bug.cgi?id=85686