Skip to content

Commit

Permalink
Adds alternative check to scrollTop
Browse files Browse the repository at this point in the history
  • Loading branch information
joaocunha committed Jun 29, 2015
1 parent 6fedb01 commit 176de8c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 42 deletions.
78 changes: 39 additions & 39 deletions readme.md
@@ -1,39 +1,39 @@
## Summary

Autosize is a small, stand-alone script to automatically adjust textarea height to fit text.

#### Demo

Full documentation and a demo can be found at [jacklmoore.com/autosize](http://jacklmoore.com/autosize)

#### Install via NPM
```bash
npm install autosize
```
#### Install via Bower
```bash
bower install autosize
```

#### Browser compatibility

Chrome | Firefox | IE | Safari | iOS Safari | Android | Opera Mini
------ | --------|----|--------|------------|---------|------------
yes | yes | 9 | yes | yes | 4 | ?

#### Usage

The autosize function accepts a single textarea element, or an array or array-like object (such as a NodeList or jQuery collection) of textarea elements.

```javascript
// from a NodeList
autosize(document.querySelectorAll('textarea'));

// from a single Node
autosize(document.querySelector('textarea'));

// from a jQuery collection
autosize($('textarea'));
```

Released under the [MIT License](http://www.opensource.org/licenses/mit-license.php)
## Summary

Autosize is a small, stand-alone script to automatically adjust textarea height to fit text.

#### Demo

Full documentation and a demo can be found at [jacklmoore.com/autosize](http://jacklmoore.com/autosize)

#### Install via NPM
```bash
npm install autosize
```
#### Install via Bower
```bash
bower install autosize
```

#### Browser compatibility

Chrome | Firefox | IE | Safari | iOS Safari | Android | Opera Mini | Windows Phone IE
------ | --------|----|--------|------------|---------|------------|------------------
yes | yes | 9 | yes | yes | 4 | ? | 8.1

#### Usage

The autosize function accepts a single textarea element, or an array or array-like object (such as a NodeList or jQuery collection) of textarea elements.

```javascript
// from a NodeList
autosize(document.querySelectorAll('textarea'));

// from a single Node
autosize(document.querySelector('textarea'));

// from a jQuery collection
autosize($('textarea'));
```

Released under the [MIT License](http://www.opensource.org/licenses/mit-license.php)
6 changes: 3 additions & 3 deletions src/autosize.js
Expand Up @@ -47,7 +47,7 @@ function assign(ta, {setOverflowX = true, setOverflowY = true} = {}) {

function update() {
const startHeight = ta.style.height;
const htmlTop = document.documentElement.scrollTop;
const htmlTop = window.pageYOffset || document.documentElement.scrollTop;
const bodyTop = document.body.scrollTop;
const originalHeight = ta.style.height;

Expand Down Expand Up @@ -119,7 +119,7 @@ function assign(ta, {setOverflowX = true, setOverflowY = true} = {}) {
ta.addEventListener('input', update);
ta.addEventListener('autosize:update', update);
ta.setAttribute('data-autosize-on', true);

if (setOverflowY) {
ta.style.overflowY = 'hidden';
}
Expand Down Expand Up @@ -173,4 +173,4 @@ if (typeof window === 'undefined' || typeof window.getComputedStyle !== 'functio
};
}

export default autosize;
export default autosize;

0 comments on commit 176de8c

Please sign in to comment.