diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/autosize.js | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/autosize.js b/src/autosize.js index fbe9568..e659e31 100644 --- a/src/autosize.js +++ b/src/autosize.js @@ -81,8 +81,6 @@ function assign(ta) { } ta.style.overflowY = value; - - resize(); } function getParentOverflows(el) { @@ -134,25 +132,29 @@ function assign(ta) { function update() { resize(); - const computed = window.getComputedStyle(ta, null); - const computedHeight = Math.round(parseFloat(computed.height)); const styleHeight = Math.round(parseFloat(ta.style.height)); + const computed = window.getComputedStyle(ta, null); + var actualHeight = Math.round(parseFloat(computed.height)); - // The computed height not matching the height set via resize indicates that + // 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 (computedHeight !== styleHeight) { + if (actualHeight !== styleHeight) { if (computed.overflowY !== 'visible') { changeOverflow('visible'); + resize(); + actualHeight = Math.round(parseFloat(window.getComputedStyle(ta, null).height)); } } 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)); } } - if (cachedHeight !== computedHeight) { - cachedHeight = computedHeight; + if (cachedHeight !== actualHeight) { + cachedHeight = actualHeight; const evt = createEvent('autosize:resized'); try { ta.dispatchEvent(evt); |