react-textarea-autosize
Advanced tools
Comparing version 2.2.3 to 2.3.0
@@ -34,3 +34,3 @@ 'use strict'; | ||
var sizingStyle = _calculateNodeStyling.sizingStyle; | ||
var sumVerticalPaddings = _calculateNodeStyling.sumVerticalPaddings; | ||
var heightAdjustment = _calculateNodeStyling.heightAdjustment; | ||
@@ -43,3 +43,3 @@ // Need to have the overflow attribute to hide the scrollbar otherwise | ||
hiddenTextarea.value = uiTextNode.value; | ||
var height = hiddenTextarea.scrollHeight - sumVerticalPaddings; | ||
var height = hiddenTextarea.scrollHeight + heightAdjustment; | ||
var minHeight = -Infinity; | ||
@@ -51,3 +51,3 @@ var maxHeight = Infinity; | ||
hiddenTextarea.value = 'x'; | ||
var singleRowHeight = hiddenTextarea.scrollHeight - sumVerticalPaddings; | ||
var singleRowHeight = hiddenTextarea.scrollHeight + heightAdjustment; | ||
if (minRows !== null) { | ||
@@ -76,8 +76,13 @@ minHeight = singleRowHeight * minRows; | ||
var sumPaddings = 0; | ||
// scrollHeight = content + padding; depending on what box-sizing is | ||
// set to, we'll need an adjustment when we set the new height | ||
var heightAdjustment = 0; | ||
// If the textarea is set to border-box, it's not necessary to | ||
// subtract the padding. | ||
if (compStyle.getPropertyValue('box-sizing') !== 'border-box' && compStyle.getPropertyValue('-moz-box-sizing') !== 'border-box' && compStyle.getPropertyValue('-webkit-box-sizing') !== 'border-box') { | ||
sumPaddings = parseFloat(compStyle.getPropertyValue('padding-bottom')) + parseFloat(compStyle.getPropertyValue('padding-top')); | ||
var boxSizing = compStyle.getPropertyValue('box-sizing') || compStyle.getPropertyValue('-moz-box-sizing') || compStyle.getPropertyValue('-webkit-box-sizing'); | ||
// border-box: add border, since height = content + padding + border | ||
if (boxSizing === 'border-box') { | ||
heightAdjustment = parseFloat(compStyle.getPropertyValue('border-bottom')) + parseFloat(compStyle.getPropertyValue('border-top')); | ||
} else if (boxSizing === 'content-box') { | ||
// remove padding, since height = content | ||
heightAdjustment = -(parseFloat(compStyle.getPropertyValue('padding-bottom')) + parseFloat(compStyle.getPropertyValue('padding-top'))); | ||
} | ||
@@ -89,3 +94,3 @@ | ||
}).join(';'), | ||
sumVerticalPaddings: sumPaddings | ||
heightAdjustment: heightAdjustment | ||
}; | ||
@@ -92,0 +97,0 @@ |
{ | ||
"name": "react-textarea-autosize", | ||
"description": "textarea component for React which grows with content", | ||
"version": "2.2.3", | ||
"version": "2.3.0", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Andrey Popp", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27650
247