Skip to content
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

Prevents horizontal scroll #65

Merged
merged 2 commits into from May 7, 2013
Merged

Prevents horizontal scroll #65

merged 2 commits into from May 7, 2013

Conversation

firedev
Copy link
Contributor

@firedev firedev commented May 7, 2013

I have replaced elastic plugin with this one and then found horizontal scroll on the site caused by a hidden <textarea>, fixed by moving it further to the left.

@jackmoore
Copy link
Owner

Thanks for the pull request, but you'll have to demonstrate the problem for me to be able to merge this. If this is really causing an issue then a different solution will have to be found because your commit causes exactly the problem you describe for sites that use direction:rtl.

@jackmoore
Copy link
Owner

Maybe your textarea element is wider than the document.

@firedev
Copy link
Contributor Author

firedev commented May 7, 2013

Good point let me check.

@firedev
Copy link
Contributor Author

firedev commented May 7, 2013

What about this then?

jackmoore pushed a commit that referenced this pull request May 7, 2013
Prevents horizontal scroll
@jackmoore jackmoore merged commit 25e65e2 into jackmoore:master May 7, 2013
@jackmoore
Copy link
Owner

Thanks

@jackmoore
Copy link
Owner

Sorry, had to revert the change made here because it break things under IE8 (didn't test other IEs).

@jackmoore
Copy link
Owner

You can still implement your direction:rtl change locally by attaching it to the mirrored elements class selector:

.autosizejs { direction: rtl; }

@firedev
Copy link
Contributor Author

firedev commented May 20, 2013

Sorry, beaks how exactly? I have checked in IE and everything is fine. Also I am not changing direction, I just had invisible textarea wider than the document (probably because of box-sizing)

@jackmoore
Copy link
Owner

#69

I also tested it in IE8 native on XP. Autosize was just off. Starts off the wrong size, enlarges at the wrong time, shrinks randomly. Just a mess in IE8, non-emulated. My mistake about the ltr text, I misremembered that being your original fix instead of moving it left. You could still set the width in the CSS, or change the left position:

.autosize { left:-999px !important; /* or width:0; */}

!important has a higher specificity than the inline style.

@firedev
Copy link
Contributor Author

firedev commented May 20, 2013

Ok fair enough. However width: 0 is exactly what I have added. Plus there is no class on the <textarea>. And it gets even worse when I try to target it in CSS.

@onokazu
Copy link

onokazu commented Aug 12, 2013

I had the exact same issue and the only way to prevent this is to manually add width:0 to the javascript source file.
The autosize method is called like below in my app:

$('textarea', context).autosize();

The problem is that an empty textarea element is always appended to the body tag even when there is no textarea present in the page. And there is no way to fix this via css as you said since there is no class in that textarea element. Should we call the autosize() method only when there is a textarea element in the current page? Or can you fix your code so that the textarea element is appended to the body tag only when there is at least one textarea in the page, something like below:

if (!this.length) return;

@onokazu
Copy link

onokazu commented Sep 6, 2013

Anything on this issue?

@jackmoore
Copy link
Owner

Setting the width to zero may no longer be necessary. Another user pointed out that they were using a size of 100% on textareas, but padding caused it to be greater than 100%. A recent commit set padding is explicitly to 0 for the mirror element (that may resolve your horizontal scroll issue). However, I will add your line for quicker failure.

@jackmoore
Copy link
Owner

Done:

if (!this.length) {

philfreo pushed a commit to closeio/autosize that referenced this pull request Nov 8, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants