-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compute function not being called #2
Comments
Hi @madprops! Thanks for checking this plugin out, it looks (based on you using the If you initialized it with |
<textarea id=input size=1 rows=1 placeholder="(7:39 PM) Hi mad, write something to Hue" style='--expand: "HEYYY";'></textarea>
<style>
#input {
font-size: 1rem;
color: white;
border: 0px solid black;
padding-right: 1rem;
margin-right: 1rem;
outline: none;
font-family: inherit;
flex-grow: 1;
background-color: transparent;
color: inherit;
resize: none;
overflow-y: auto;
overflow-x: hidden;
position: relative;
/* height: calc(100% - 0.6rem); */
overflow-wrap: break-word;
word-break: break-word;
min-height: 1em;
max-height: 50vh;
height: var(--expand);
}
</style>
<script type=module>
import computedVariables from 'https://unpkg.com/computed-variables/index.es.js'
computedVariables(
'--expand',
(value, event, tag) => {
console.log(value)
console.log(event)
console.log(tag)
tag.style.height = 'inherit'
const height = tag.scrollHeight
tag.style.height = ''
return height + 'px'
},
"#input",
['input', 'paste', 'blur', 'reprocess']
)
</script> ^ here's the demo code I was working with |
Btw I had to change the tag.style.height change from "inherit" to "auto" so it respected my 1 row setup. Seems to work nicely.
|
Yay! I'm glad you got it working :D I've got a collection on CodePen of demos that show a variety of things you can do with this: https://codepen.io/collection/DJNaar/ (some of them are really weird, I am trying to push the limits!) |
If I comment the tag style lines it doesn't happen .. but it calculates inaccurate results. hmm |
Ok I fixed it by changing "auto" to what I have set as min-height (it was happening with 'inherit' too btw):
|
Nevermind, it's not fixed. If I use backspace to remove lines it shrinks, but if I select all text and delete it doesn't calculate it correctly.. |
Ok fixed. CSS mod on #input
JS mod:
Basically what I did was set a fixed height to the footer so it didn't change when calculating the textarea's height. This should have gone in its own Issue, sorry about that. |
I have a textarea called #input
CSS:
After load I call:
I would expect the function where the console.logs are to be called on an input event. No resizing happens, no console.logs are triggered.
The text was updated successfully, but these errors were encountered: