taskvur.blogg.se

Autosize js
Autosize js








autosize js

However, in contrast to the example above, both of these options move the act of enabling any given with this resizing behavior from imperative JavaScript to declarative HTML.

autosize js

I sat with the idea and came up with two perspectives on implementation, both of which require JavaScript to work in terms of the auto resizing. Wouldn’t it be nice if I could just specify in the HTML which elements I wanted to automatically resize? What would that look like? How could you design and implement such a solution? Some of my elements were being dynamically added and removed from the DOM at different points in time, so just passing in a couple elements when my script initialized wasn’t enough. Part of my problem was that I needed to be able to easily specify both which elements I wanted to resize and when I wanted them to resize. Simple-and a simple JS implementation these days is, well, kind of refreshing. from a single Node autosize( document.

autosize js

From the docs: // from a NodeList autosize( document. The implementation was simple: include the script on your page, query select the (s) on the page you want to automatically resize, and pass it to the autosize function. I was recently working on a side project and found myself wanting to automatically resize a (vertically) as content was input by the user.Īs I began looking into how to achieve this functionality, I found a great stand-alone script called autosize that’ll do this for you automatically with minimal fuss.










Autosize js