Skip to content

Commit

Permalink
minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
jackmoore committed Mar 23, 2018
1 parent 5ee542d commit bd3bf8f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 24 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## Changelog

##### v.4.0.1 - 2018-03-23
* Minor refactor & updated build depedencies

##### v.4.0.0 - 2017-07-12
* Changed how Autosize determines the inital height. Fixes #336.

Expand Down
17 changes: 6 additions & 11 deletions dist/autosize.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
autosize 4.0.0
autosize 4.0.1
license: MIT
http://www.jacklmoore.com/autosize
*/
Expand Down Expand Up @@ -122,21 +122,16 @@
}

function resize() {
var originalHeight = ta.style.height;
var overflows = getParentOverflows(ta);
var docTop = document.documentElement && document.documentElement.scrollTop; // Needed for Mobile IE (ticket #240)

ta.style.height = '';

var endHeight = ta.scrollHeight + heightOffset;

if (ta.scrollHeight === 0) {
// If the scrollHeight is 0, then the element probably has display:none or is detached from the DOM.
ta.style.height = originalHeight;
return;
}

ta.style.height = endHeight + 'px';
var overflows = getParentOverflows(ta);
var docTop = document.documentElement && document.documentElement.scrollTop; // Needed for Mobile IE (ticket #240)

ta.style.height = '';
ta.style.height = ta.scrollHeight + heightOffset + 'px';

// used to check if an update is actually necessary on window.resize
clientWidth = ta.clientWidth;
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": "4.0.0",
"version": "4.0.1",
"keywords": [
"textarea",
"form",
Expand Down
15 changes: 5 additions & 10 deletions src/autosize.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,16 @@ function assign(ta) {
}

function resize() {
const originalHeight = ta.style.height;
const overflows = getParentOverflows(ta);
const docTop = document.documentElement && document.documentElement.scrollTop; // Needed for Mobile IE (ticket #240)

ta.style.height = '';

let endHeight = ta.scrollHeight+heightOffset;

if (ta.scrollHeight === 0) {
// If the scrollHeight is 0, then the element probably has display:none or is detached from the DOM.
ta.style.height = originalHeight;
return;
}

ta.style.height = endHeight+'px';
const overflows = getParentOverflows(ta);
const docTop = document.documentElement && document.documentElement.scrollTop; // Needed for Mobile IE (ticket #240)

ta.style.height = '';
ta.style.height = (ta.scrollHeight+heightOffset)+'px';

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

0 comments on commit bd3bf8f

Please sign in to comment.