Skip to content

Commit

Permalink
Fixed the autosize:resized event not being triggered when the overf…
Browse files Browse the repository at this point in the history
…low changes. Fixes jackmoore#244.
  • Loading branch information
jackmoore committed Jul 8, 2015
1 parent 8ec02cb commit 09db6a2
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 17 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## Changelog

##### v.3.0.8 - 2015-06-29
* Fixed the `autosize:resized` event not being triggered when the overflow changes. Fixes #244.

##### v.3.0.7 - 2015-06-29
* Fixed jumpy behavior in Windows 8.1 mobile. Fixes #239.

Expand Down
15 changes: 9 additions & 6 deletions dist/autosize.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
Autosize 3.0.7
Autosize 3.0.8
license: MIT
http://www.jacklmoore.com/autosize
*/
Expand Down Expand Up @@ -69,11 +69,10 @@
ta.style.overflowY = value;
}

update();
resize();
}

function update() {
var startHeight = ta.style.height;
function resize() {
var htmlTop = window.pageYOffset;
var bodyTop = document.body.scrollTop;
var originalHeight = ta.style.height;
Expand All @@ -93,18 +92,22 @@
// prevents scroll-position jumping
document.documentElement.scrollTop = htmlTop;
document.body.scrollTop = bodyTop;
}

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

resize();

var style = window.getComputedStyle(ta, null);

if (style.height !== ta.style.height) {
if (overflowY !== 'visible') {
changeOverflow('visible');
return;
}
} else {
if (overflowY !== 'hidden') {
changeOverflow('hidden');
return;
}
}

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.

5 changes: 1 addition & 4 deletions 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.7",
"version": "3.0.8",
"keywords": [
"textarea",
"form",
Expand Down Expand Up @@ -40,9 +40,6 @@
"filename": "autosize"
},
"scripts": {
"major-release": "npm version major && npm publish && git push --follow-tags",
"minor-release": "npm version minor && npm publish && git push --follow-tags",
"patch-release": "npm version patch && npm publish && git push --follow-tags",
"build": "node build"
}
}
13 changes: 8 additions & 5 deletions src/autosize.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,10 @@ function assign(ta, {setOverflowX = true, setOverflowY = true} = {}) {
ta.style.overflowY = value;
}

update();
resize();
}

function update() {
const startHeight = ta.style.height;
function resize() {
const htmlTop = window.pageYOffset;
const bodyTop = document.body.scrollTop;
const originalHeight = ta.style.height;
Expand All @@ -66,18 +65,22 @@ function assign(ta, {setOverflowX = true, setOverflowY = true} = {}) {
// prevents scroll-position jumping
document.documentElement.scrollTop = htmlTop;
document.body.scrollTop = bodyTop;
}

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

resize();

const style = window.getComputedStyle(ta, null);

if (style.height !== ta.style.height) {
if (overflowY !== 'visible') {
changeOverflow('visible');
return;
}
} else {
if (overflowY !== 'hidden') {
changeOverflow('hidden');
return;
}
}

Expand Down

0 comments on commit 09db6a2

Please sign in to comment.