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
Wrong height when using box-sizing: border-box #28
Comments
Were you using a recent version of autosize? Border-box should be properly accounted for version 1.7 or higher. |
I'm using 1.13. |
I wasn't able to reproduce the problem using border-box by itself: http://jsfiddle.net/efzXr/ Everything seemed to work as expected. |
You're right, it does. Must be some other combination of styles that caused Den fredagen den 28:e september 2012 skrev Jack Moore:
|
Also this, which could explain my problem - the textarea I tested with was Den fredagen den 28:e september 2012 skrev Anders Fjeldstad:
|
I was using a newer version of jQuery (1.8.2) - this is the same fiddle but Seems like some things related to dimensions have changed in 1.8, for Den fredagen den 28:e september 2012 skrev Anders Fjeldstad:
|
Hm weird - I responded via e-mail and the order of the messages got mixed up. |
Hello, this also happened to me, I'm also using jQuery 1.8.2 :( EDIT: It should actually be the content-box width of the original textarea instead of $ta.css('width'); on line 98 Thanks |
The mirrored textarea element has the same border-sizing options as the original element, so what you are doing looks like it would break things for anyone not using content-box. |
Hello, I'm sorry, but I tested this for both a content-box and border-box textarea, and they both works correctly. Here's how I came up with that code, please correct me if I'm actually wrong :) Example of a content-box textarea's dimension with 960px width: Example of a border-box textarea's dimension with 960px width: The mirrored textarea is hard-coded as content-box, so setting the width of the mirror equal to jQuery.width() of the original textarea would set the mirror's width to 946px, instead of the 960px from .css('width') This would make the mirror's dimension like follows: It also wouldn't be a problem if the original textarea is a content-box, because that would set the mirror's width to 960px, thus equal to the original textarea. Thank you. |
Thank you both for the amount of research you put into this. Maimairel, your fix works great. I'm apologize for my lateness acknowledging that. I didn't realize at first because I was using jQuery 1.7, where .width() worked with border-box sizing. |
I tried using your plugin in an application using Twitter Bootrap, where textareas have
box-sizing: border-box
by default, and noticed that the textarea was not resizing properly (it lagged behind a bit).After fiddling around a bit, I saw this line in the
adjust()
function:Doesn't this need to be changed in order to take horizontal padding into account when using border-box? Like this:
This seems to solve my issue. Haven't tested it thoroughly with other box-sizing values though. Any thoughts on this?
The text was updated successfully, but these errors were encountered: