diff options
author | Jack Moore <hello@jacklmoore.com> | 2014-11-11 11:04:02 -0500 |
---|---|---|
committer | Jack Moore <hello@jacklmoore.com> | 2014-11-11 11:04:02 -0500 |
commit | 4920408a4a4ab4bdc6b76bc2168a7f431d90173d (patch) | |
tree | e0c9bb13834f8e2e2d7f586707c7a27432c1795d | |
parent | 6abe75643c2304c393bd3f4b37a5cf3bac3436c9 (diff) | |
parent | bff4a29310e93852ca1619dba9e26eefe11b0fb7 (diff) | |
download | autosize-4920408a4a4ab4bdc6b76bc2168a7f431d90173d.zip autosize-4920408a4a4ab4bdc6b76bc2168a7f431d90173d.tar.gz autosize-4920408a4a4ab4bdc6b76bc2168a7f431d90173d.tar.bz2 |
Merge pull request #185 from njam/parse-float
Use "parseFloat" instead of "parseInt" for when sub-pixel css values are used
-rw-r--r-- | jquery.autosize.js | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/jquery.autosize.js b/jquery.autosize.js index 969b3df..07fde0b 100644 --- a/jquery.autosize.js +++ b/jquery.autosize.js @@ -84,7 +84,7 @@ } // IE8 and lower return 'auto', which parses to NaN, if no min-height is set. - minHeight = Math.max(parseInt($ta.css('minHeight'), 10) - boxOffset || 0, $ta.height()); + minHeight = Math.max(parseFloat($ta.css('minHeight')) - boxOffset || 0, $ta.height()); $ta.css({ overflow: 'hidden', @@ -103,17 +103,17 @@ function setWidth() { var width; var style = window.getComputedStyle ? window.getComputedStyle(ta, null) : false; - + if (style) { width = ta.getBoundingClientRect().width; if (width === 0 || typeof width !== 'number') { - width = parseInt(style.width,10); + width = parseFloat(style.width); } $.each(['paddingLeft', 'paddingRight', 'borderLeftWidth', 'borderRightWidth'], function(i,val){ - width -= parseInt(style[val],10); + width -= parseFloat(style[val]); }); } else { width = $ta.width(); @@ -128,7 +128,7 @@ mirrored = ta; mirror.className = options.className; mirror.id = options.id; - maxHeight = parseInt($ta.css('maxHeight'), 10); + maxHeight = parseFloat($ta.css('maxHeight')); // mirror is a duplicate textarea located off-screen that // is automatically updated to contain the same text as the @@ -138,7 +138,7 @@ $.each(typographyStyles, function(i,val){ styles[val] = $ta.css(val); }); - + $(mirror).css(styles).attr('wrap', $ta.attr('wrap')); setWidth(); @@ -166,8 +166,8 @@ } if (!ta.value && options.placeholder) { - // If the textarea is empty, copy the placeholder text into - // the mirror control and use that for sizing so that we + // If the textarea is empty, copy the placeholder text into + // the mirror control and use that for sizing so that we // don't end up with placeholder getting trimmed. mirror.value = ($ta.attr("placeholder") || ''); } else { @@ -176,7 +176,7 @@ mirror.value += options.append || ''; mirror.style.overflowY = ta.style.overflowY; - original = parseInt(ta.style.height,10); + original = parseFloat(ta.style.height); // Setting scrollTop to zero is needed in IE8 and lower for the next step to be accurately applied mirror.scrollTop = 0; |