Skip to content

Commit

Permalink
refactor to remove variable with wider-than-needed scope, commented l…
Browse files Browse the repository at this point in the history
…ogic.
  • Loading branch information
jackmoore committed Jul 25, 2016
1 parent d778583 commit adf2973
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/autosize.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,11 @@ function assign(ta) {
if (!ta || !ta.nodeName || ta.nodeName !== 'TEXTAREA' || set.has(ta)) return;

let heightOffset = null;
let overflowY = null;
let clientWidth = ta.clientWidth;

function init() {
const 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 @@ -71,8 +68,6 @@ function assign(ta) {
ta.style.width = width;
}

overflowY = value;

ta.style.overflowY = value;

resize();
Expand Down Expand Up @@ -131,12 +126,15 @@ function assign(ta) {

const style = window.getComputedStyle(ta, null);

// The computed height not matching the height set via resize indicates that
// the max-height has been exceeded, in which case the overflow should be set to visible.
if (style.height !== ta.style.height) {
if (overflowY !== 'visible') {
if (style.overflowY !== 'visible') {
changeOverflow('visible');
}
} else {
if (overflowY !== 'hidden') {
// Normally keep overflow set to hidden, to avoid flash of scrollbar as the textarea expands.
if (style.overflowY !== 'hidden') {
changeOverflow('hidden');
}
}
Expand Down

0 comments on commit adf2973

Please sign in to comment.