Skip to content

Commit

Permalink
Added workaround for a very edge-case iOS bug (Fixes jackmoore#58).
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack Moore committed Mar 20, 2013
1 parent 4d2f47c commit a1c0157
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion autosize.jquery.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"textarea",
"ui"
],
"version": "1.16.6",
"version": "1.16.7",
"author": {
"name": "Jack Moore",
"url": "http://www.jacklmoore.com",
Expand Down
2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jquery-autosize",
"version": "1.16.6",
"version": "1.16.7",
"main": "./jquery.autosize.js",
"dependencies": {
"jquery": ">=1.7"
Expand Down
8 changes: 4 additions & 4 deletions jquery.autosize-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 15 additions & 8 deletions jquery.autosize.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/*
jQuery Autosize v1.16.6
/*!
jQuery Autosize v1.16.7
(c) 2013 Jack Moore - jacklmoore.com
updated: 2013-03-12
updated: 2013-03-20
license: http://www.opensource.org/licenses/mit-license.php
*/



(function ($) {
var
defaults = {
Expand All @@ -17,6 +16,7 @@
hidden = 'hidden',
borderBox = 'border-box',
lineHeight = 'lineHeight',
supportsScrollHeight,

// border:0 is unnecessary, but avoids a bug in FireFox on OSX (http://www.jacklmoore.com/autosize#comment-851)
copy = '<textarea tabindex="-1" style="position:absolute; top:-999px; left:0; right:auto; bottom:auto; border:0; -moz-box-sizing:content-box; -webkit-box-sizing:content-box; box-sizing:content-box; word-wrap:break-word; height:0 !important; min-height:0 !important; overflow:hidden;"/>',
Expand Down Expand Up @@ -53,6 +53,10 @@

if (mirror.parentNode !== document.body) {
$(document.body).append(mirror);

mirror.value = "\n\n\n";
mirror.scrollTop = 9e4;
supportsScrollHeight = mirror.scrollHeight === mirror.scrollTop + mirror.clientHeight;
}

return this.each(function () {
Expand Down Expand Up @@ -120,10 +124,13 @@
// A floor of 0 is needed because IE8 returns a negative value for hidden textareas, raising an error.
mirror.style.width = Math.max($ta.width(), 0) + 'px';

// The following three lines can be replaced with `height = mirror.scrollHeight` when dropping IE7 support.
mirror.scrollTop = 0;
mirror.scrollTop = 9e4;
height = mirror.scrollTop;
if (supportsScrollHeight) {
height = mirror.scrollHeight;
} else { // IE6 & IE7
mirror.scrollTop = 0;
mirror.scrollTop = 9e4;
height = mirror.scrollTop;
}

var maxHeight = parseInt($ta.css('maxHeight'), 10);
// Opera returns '-1px' when max-height is set to 'none'.
Expand Down
3 changes: 3 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Small jQuery plugin to allow dynamic resizing of textarea height, so that it gro

## Changelog

### v1.16.7 - 2013/3/20
* Added workaround for a very edge-case iOS bug (Fixes #58).

### v1.16.6 - 2013/3/12
* Replaced jQuery shorthand methods with on() in anticipation of jQuery 2.0 conditional builds

Expand Down

0 comments on commit a1c0157

Please sign in to comment.