Skip to content

Commit

Permalink
Potential fix for IE11 scrollbar issue. fixes jackmoore#327, fixes ja…
Browse files Browse the repository at this point in the history
  • Loading branch information
jackmoore committed Apr 26, 2017
1 parent 6c198a8 commit 29ca460
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
8 changes: 5 additions & 3 deletions dist/autosize.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,22 +156,24 @@

var styleHeight = Math.round(parseFloat(ta.style.height));
var computed = window.getComputedStyle(ta, null);
var actualHeight = Math.round(parseFloat(computed.height));

// Using offsetHeight as a replacement for computed.height in IE, because IE does not account use of border-box
var actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(computed.height)) : ta.offsetHeight;

// The actual height not matching the style height (set via the resize method) indicates that
// the max-height has been exceeded, in which case the overflow should be set to visible.
if (actualHeight !== styleHeight) {
if (computed.overflowY !== 'visible') {
changeOverflow('visible');
resize();
actualHeight = Math.round(parseFloat(window.getComputedStyle(ta, null).height));
actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(window.getComputedStyle(ta, null).height)) : ta.offsetHeight;
}
} else {
// Normally keep overflow set to hidden, to avoid flash of scrollbar as the textarea expands.
if (computed.overflowY !== 'hidden') {
changeOverflow('hidden');
resize();
actualHeight = Math.round(parseFloat(window.getComputedStyle(ta, null).height));
actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(window.getComputedStyle(ta, null).height)) : ta.offsetHeight;
}
}

Expand Down
2 changes: 1 addition & 1 deletion dist/autosize.min.js

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

8 changes: 5 additions & 3 deletions src/autosize.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,22 +134,24 @@ function assign(ta) {

const styleHeight = Math.round(parseFloat(ta.style.height));
const computed = window.getComputedStyle(ta, null);
var actualHeight = Math.round(parseFloat(computed.height));

// Using offsetHeight as a replacement for computed.height in IE, because IE does not account use of border-box
var actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(computed.height)) : ta.offsetHeight;

// The actual height not matching the style height (set via the resize method) indicates that
// the max-height has been exceeded, in which case the overflow should be set to visible.
if (actualHeight !== styleHeight) {
if (computed.overflowY !== 'visible') {
changeOverflow('visible');
resize();
actualHeight = Math.round(parseFloat(window.getComputedStyle(ta, null).height));
actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(window.getComputedStyle(ta, null).height)) : ta.offsetHeight;
}
} else {
// Normally keep overflow set to hidden, to avoid flash of scrollbar as the textarea expands.
if (computed.overflowY !== 'hidden') {
changeOverflow('hidden');
resize();
actualHeight = Math.round(parseFloat(window.getComputedStyle(ta, null).height));
actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(window.getComputedStyle(ta, null).height)) : ta.offsetHeight;
}
}

Expand Down

0 comments on commit 29ca460

Please sign in to comment.