Javascript and webdev (38)

28 Name: Anonymous Techie : 2022-09-21 20:36 ID:Heaven

Autosage is very nice.
I like the autoexpand feature, but it is a bit odd that it expands per character input and also expands when you're doing backspaces. I think adding a counter to see if it got bigger or smaller on each input so it can shrink when removing characters too.

Of course it's your userscript so it's up to you how it ends up and I prefer to see your vision on the features and design, but I am also trying things and sharing thoughts.
What I tried was a bit different, doing a check for newlines. Maybe need to adjust number 15 for different computers and styles, but I wrote this for me to try out.

You might have tried this too and discovered it doesn't work very well for paragraphs when the textarea is not so wide, there are many newlines that aren't in the input value... It works okay for ascii art, but it brings many annoyances. If you try to expand the textarea and start typing the box will reset size... Annoying!

Continuing what you did I decided to add a check on if the size got bigger or smaller. I let it continue to grow like you made it, it has the least annoyances out of the different methods I tried, but I also made it so it doesn't expand when you remove characters like spamming backspace. I also tried making it shrink on removed characters, but it was easily very annoying.

Here is my end result, your previous code and also my failed attempts are left commented:

I really wanted to post directly in thread, but got caught by spamfilter unfortunately. Some mirrors.
https://pst.moe/paste/xognrr?format=raw
https://controlc.com/4bc74d41
https://files.catbox.moe/3tk5mp.txt
https://rentry.co/cmfi4
https://zerobin.net/?3eee43459b9b23f7#mNqUBc+QcFrW8zTPvNThJQ8KUTplK7SvwwstKB7aut4=

Doesn't add more height when you remove characters. It also removes a very tiny amount when backspacing, but not as much as is added. When removing a lot of text it also checks how many was removed and does the difference. If you clear the field to zero characters the size resets. Still not perfect, works different if you make the textarea wider or slimmer. Maybe the ideal function would also check how wide the textfield is to find a formula based on the width of the textarea for the shrink value I used to add/remove when typing, but I am happy it does not expand when I backspace so everything else I tried may just be bloat.

Wouldn't think such a simple feature would be so complicated!

Name: Link:
Leave these fields empty (spam trap):
More options...
Verification: