Skip to content

Commit

Permalink
3.0.17
Browse files Browse the repository at this point in the history
  • Loading branch information
jackmoore committed Jul 25, 2016
1 parent 5edede5 commit 3838f19
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 31 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Changelog

##### v.3.0.17 - 2016-7-25
* Fixed Chromium issue where getComputedStyle pixel value did not exactly match the style pixel value. Fixes #306.
* Removed undocumented argument, minor refactoring, more comments.

##### v.3.0.16 - 2016-7-13
* Fixed issue with overflowing parent elements. Fixes #298.

Expand Down
44 changes: 16 additions & 28 deletions dist/autosize.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
Autosize 3.0.16
Autosize 3.0.17
license: MIT
http://www.jacklmoore.com/autosize
*/
Expand Down Expand Up @@ -48,24 +48,15 @@
}

function assign(ta) {
var _ref = arguments[1] === undefined ? {} : arguments[1];

var _ref$setOverflowX = _ref.setOverflowX;
var setOverflowX = _ref$setOverflowX === undefined ? true : _ref$setOverflowX;
var _ref$setOverflowY = _ref.setOverflowY;
var setOverflowY = _ref$setOverflowY === undefined ? true : _ref$setOverflowY;

if (!ta || !ta.nodeName || ta.nodeName !== 'TEXTAREA' || set.has(ta)) return;

var heightOffset = null;
var overflowY = null;
var clientWidth = ta.clientWidth;
var cachedHeight = null;

function init() {
var 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 @@ -99,11 +90,7 @@
ta.style.width = width;
}

overflowY = value;

if (setOverflowY) {
ta.style.overflowY = value;
}
ta.style.overflowY = value;

resize();
}
Expand Down Expand Up @@ -154,23 +141,27 @@
}

function update() {
var startHeight = ta.style.height;

resize();

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

if (style.height !== ta.style.height) {
if (overflowY !== 'visible') {
// 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 (computedHeight !== styleHeight) {
if (computed.overflowY !== 'visible') {
changeOverflow('visible');
}
} else {
if (overflowY !== 'hidden') {
// Normally keep overflow set to hidden, to avoid flash of scrollbar as the textarea expands.
if (computed.overflowY !== 'hidden') {
changeOverflow('hidden');
}
}

if (startHeight !== ta.style.height) {
if (cachedHeight !== computedHeight) {
cachedHeight = computedHeight;
var evt = createEvent('autosize:resized');
ta.dispatchEvent(evt);
}
Expand Down Expand Up @@ -213,11 +204,8 @@
ta.addEventListener('input', update, false);
ta.addEventListener('autosize:update', update, false);
set.add(ta);

if (setOverflowX) {
ta.style.overflowX = 'hidden';
ta.style.wordWrap = 'break-word';
}
ta.style.overflowX = 'hidden';
ta.style.wordWrap = 'break-word';

init();
}
Expand Down
4 changes: 2 additions & 2 deletions dist/autosize.min.js

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "autosize",
"description": "Autosize is a small, stand-alone script to automatically adjust textarea height to fit text.",
"version": "3.0.16",
"version": "3.0.17",
"keywords": [
"textarea",
"form",
Expand Down

0 comments on commit 3838f19

Please sign in to comment.