Skip to content

Commit

Permalink
jackmoore#207 Only update when clientWidth changes
Browse files Browse the repository at this point in the history
Issue jackmoore#207, fixes kinetic scrolling jerkiness on iOS.
  • Loading branch information
rmcauley committed Sep 26, 2015
1 parent 037f61b commit b3f23d9
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/autosize.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,17 @@ function assign(ta, {setOverflowX = true, setOverflowY = true} = {}) {
ta.dispatchEvent(evt);
}
}

var lastPageWidth = document.documentElement.clientWidth;
function pageResize() {
if (document.documentElement.clientWidth != lastPageWidth) {
lastPageWidth = document.documentElement.clientWidth;
update();
}
}

const destroy = style => {
window.removeEventListener('resize', update);
window.removeEventListener('resize', pageResize);
ta.removeEventListener('input', update);
ta.removeEventListener('keyup', update);
ta.removeEventListener('autosize:destroy', destroy);
Expand All @@ -138,7 +146,7 @@ function assign(ta, {setOverflowX = true, setOverflowY = true} = {}) {
ta.addEventListener('keyup', update);
}

window.addEventListener('resize', update);
window.addEventListener('resize', pageResize);
ta.addEventListener('input', update);
ta.addEventListener('autosize:update', update);
set.add(ta);
Expand Down

0 comments on commit b3f23d9

Please sign in to comment.