Skip to content

Instantly share code, notes, and snippets.

@AMKohn
Created July 4, 2014 18:15
Show Gist options
  • Save AMKohn/ade4dad8ae0a599b90f0 to your computer and use it in GitHub Desktop.
Save AMKohn/ade4dad8ae0a599b90f0 to your computer and use it in GitHub Desktop.
Textarea autosizer modified from Shog9's answer on SO: http://stackoverflow.com/a/7875/900747
var autosize = function(e) {
var area = e.currentTarget,
ch = area.clientHeight, // These should be cached as much as possible since this is triggered on keyup
sh = area.scrollHeight;
if (ch == sh) {
area.style.height = "30px";
// Recache them
var ch = area.clientHeight,
sh = area.scrollHeight;
}
var adjustedHeight = Math.max(sh, ch);
if (adjustedHeight > ch) {
area.style.height = adjustedHeight + "px";
}
};
@AMKohn
Copy link
Author

AMKohn commented Jul 4, 2014

This removes support for a maxHeight parameter, changes element retrieval so it's easier to use with Backbone and adds better caching.

@meeloun
Copy link

meeloun commented Jan 18, 2024

选择专业的澳洲代写 http://australiaway.org/a/aozhoudaixie/ 服务是提高学术能力和取得学术成功的重要途径。通过与经验丰富的澳洲代写专家合作,你可以获得高质量、原创性强的论文,节省时间和精力,并且提升自己的学术成绩和声誉。

@yorkcarol
Copy link

yorkcarol commented Mar 26, 2024

s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment