jackmoore / autosize

Autosize is a small, stand-alone script to automatically adjust textarea height to fit text.
http://www.jacklmoore.com/autosize/
MIT License
5.1k stars 702 forks source link

How to know that it was initialized #371

Closed aloky closed 1 year ago

aloky commented 5 years ago

autosize(el).isInit // true

jackmoore commented 5 years ago

I don't have a way of detecting that from outside of the autosize function. However, assigning autosize is synchronous, so you'll know it has initialized as soon as you assign it. For example:

autosize(el);
var isInit = true;

It's fine to re-assign autosize, it will do nothing if it detects that autosize is already applied.

autosize(el);
autosize(el); // this is fine

Same thing with calling destroy:

var el1 = document.querySelector('textarea')[0];
var el2 = document.querySelector('textarea')[1];
autosize(e1);
autosize.destroy(el1);
autosize.destroy(el1); // fine
autosize.destroy(el2); // also fine

Sorry, I know this isn't what you are looking for, it's just all I have at the moment.