From 22d2751a67bd1cda4b038fa56758348e38fa5f4f Mon Sep 17 00:00:00 2001 From: Maxime Poulin Date: Sat, 16 Jul 2016 02:54:22 -0400 Subject: [PATCH] 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? --- client/js/lounge.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/js/lounge.js b/client/js/lounge.js index b5de2860..34a732c7 100644 --- a/client/js/lounge.js +++ b/client/js/lounge.js @@ -632,6 +632,8 @@ $(function() { .history() .on("input keyup", function() { var style = window.getComputedStyle(this); + var origHeight = this.style.height; + this.style.height = "0px"; this.offsetHeight; // force reflow this.style.height = Math.min( @@ -641,7 +643,9 @@ $(function() { + Math.round(parseFloat(style.borderBottomWidth) || 0) ) + "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});