Skip to content

Commit a85aa3a

Browse files
author
Gabriel Schulhof
committed
Textarea: Save and restore scrollTop during autogrow height update
Thanks go to Kangsik Kim <[email protected]> for the idea to set scrollTop Fixes jquery-archivegh-6898
1 parent a91747c commit a85aa3a

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

js/widgets/forms/autogrow.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ define( [
9393
},
9494

9595
_updateHeight: function() {
96-
96+
var paddingTop, paddingBottom, paddingHeight, scrollHeight, clientHeight,
97+
borderTop, borderBottom, borderHeight, height,
98+
scrollTop = this.window.scrollTop();
9799
this.keyupTimeout = 0;
98100

99101
// IE8 textareas have the onpage property - others do not
@@ -105,13 +107,12 @@ define( [
105107
});
106108
}
107109

108-
var paddingTop, paddingBottom, paddingHeight,
109-
scrollHeight = this.element[ 0 ].scrollHeight,
110-
clientHeight = this.element[ 0 ].clientHeight,
111-
borderTop = parseFloat( this.element.css( "border-top-width" ) ),
112-
borderBottom = parseFloat( this.element.css( "border-bottom-width" ) ),
113-
borderHeight = borderTop + borderBottom,
114-
height = scrollHeight + borderHeight + 15;
110+
scrollHeight = this.element[ 0 ].scrollHeight;
111+
clientHeight = this.element[ 0 ].clientHeight;
112+
borderTop = parseFloat( this.element.css( "border-top-width" ) );
113+
borderBottom = parseFloat( this.element.css( "border-bottom-width" ) );
114+
borderHeight = borderTop + borderBottom;
115+
height = scrollHeight + borderHeight + 15;
115116

116117
// Issue 6179: Padding is not included in scrollHeight and
117118
// clientHeight by Firefox if no scrollbar is visible. Because
@@ -132,6 +133,8 @@ define( [
132133
"min-height": "",
133134
"max-height": ""
134135
});
136+
137+
this.window.scrollTop( scrollTop );
135138
},
136139

137140
refresh: function() {

0 commit comments

Comments
 (0)