Slight optimization in the textarea code

Not that it matters (7.9ms->3.8ms), but I figured since I took the time to profile it as a joke I might as well make it a PR. Mobile might have a slight reduction in typing lag from it?
This commit is contained in:
Maxime Poulin 2016-07-16 02:54:22 -04:00 committed by Maxime Poulin
parent ebab910e00
commit 22d2751a67
No known key found for this signature in database
GPG Key ID: CB63C36252F40D4B

View File

@ -632,6 +632,8 @@ $(function() {
.history() .history()
.on("input keyup", function() { .on("input keyup", function() {
var style = window.getComputedStyle(this); var style = window.getComputedStyle(this);
var origHeight = this.style.height;
this.style.height = "0px"; this.style.height = "0px";
this.offsetHeight; // force reflow this.offsetHeight; // force reflow
this.style.height = Math.min( this.style.height = Math.min(
@ -641,7 +643,9 @@ $(function() {
+ Math.round(parseFloat(style.borderBottomWidth) || 0) + Math.round(parseFloat(style.borderBottomWidth) || 0)
) + "px"; ) + "px";
$("#chat .chan.active .chat").trigger("msg.sticky"); // fix growing if (this.style.height !== origHeight) {
$("#chat .chan.active .chat").trigger("msg.sticky"); // fix growing
}
}) })
.tab(complete, {hint: false}); .tab(complete, {hint: false});