Skip to content

Commit

Permalink
Fixed scroll-bar jumpiness in iOS. Merged jackmoore#261, fixes jackmo…
Browse files Browse the repository at this point in the history
…ore#207.

Fixed reflowing of initial text in Chrome and Safari.
  • Loading branch information
jackmoore committed Sep 26, 2015
1 parent 8729783 commit 9ed036f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Changelog

##### v.3.0.13 - 2015-09-26
* Fixed scroll-bar jumpiness in iOS. Merged #261, fixes #207.
* Fixed reflowing of initial text in Chrome and Safari.

##### v.3.0.12 - 2015-09-14
* Merged changes were discarded when building new dist files. Merged #255, Fixes #257 for real this time.

Expand Down
23 changes: 16 additions & 7 deletions dist/autosize.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
Autosize 3.0.12
Autosize 3.0.13
license: MIT
http://www.jacklmoore.com/autosize
*/
Expand Down Expand Up @@ -44,11 +44,14 @@
if (!ta || !ta.nodeName || ta.nodeName !== 'TEXTAREA' || set.has(ta)) return;

var heightOffset = null;
var overflowY = 'hidden';
var overflowY = null;
var clientWidth = ta.clientWidth;

function init() {
var style = window.getComputedStyle(ta, null);

overflowY = style.overflowY;

if (style.resize === 'vertical') {
ta.style.resize = 'none';
} else if (style.resize === 'both') {
Expand Down Expand Up @@ -108,6 +111,9 @@

ta.style.height = endHeight + 'px';

// used to check if an update is actually necessary on window.resize
clientWidth = ta.clientWidth;

// prevents scroll-position jumping
document.documentElement.scrollTop = htmlTop;
document.body.scrollTop = bodyTop;
Expand Down Expand Up @@ -137,8 +143,14 @@
}
}

var pageResize = function pageResize() {
if (ta.clientWidth !== clientWidth) {
update();
}
};

var destroy = (function (style) {
window.removeEventListener('resize', update);
window.removeEventListener('resize', pageResize);
ta.removeEventListener('input', update);
ta.removeEventListener('keyup', update);
ta.removeEventListener('autosize:destroy', destroy);
Expand All @@ -163,14 +175,11 @@
ta.addEventListener('keyup', update);
}

window.addEventListener('resize', update);
window.addEventListener('resize', pageResize);
ta.addEventListener('input', update);
ta.addEventListener('autosize:update', update);
set.add(ta);

if (setOverflowY) {
ta.style.overflowY = 'hidden';
}
if (setOverflowX) {
ta.style.overflowX = 'hidden';
ta.style.wordWrap = 'break-word';
Expand Down
4 changes: 2 additions & 2 deletions dist/autosize.min.js

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "autosize",
"description": "Autosize is a small, stand-alone script to automatically adjust textarea height to fit text.",
"version": "3.0.12",
"version": "3.0.13",
"keywords": [
"textarea",
"form",
Expand Down

0 comments on commit 9ed036f

Please sign in to comment.