From a7420ff2b5b2880bded6d13b548607028113397f Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Tue, 23 Sep 2014 16:53:27 +0100 Subject: [PATCH] Fix SYWEB-72 : Improve performance when typing. Swapped ng-keydown to a directive, which does the same thing (check if up/down arrow then call history.goUp/goDown). This has *dramatically* improved performance when typing in rooms which have lots (>100) of messages loaded. --- webclient/room/room-directive.js | 15 +++++++++++++++ webclient/room/room.html | 3 +-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/webclient/room/room-directive.js b/webclient/room/room-directive.js index 8db4cb5d9..d5108b5f1 100644 --- a/webclient/room/room-directive.js +++ b/webclient/room/room-directive.js @@ -135,6 +135,21 @@ angular.module('RoomController') }); }; }]) +.directive('commandHistory', [ function() { + return function (scope, element, attrs) { + element.bind("keydown keypress", function (event) { + var keycodePressed = event.which; + var UP_ARROW = 38; + var DOWN_ARROW = 40; + if (keycodePressed === UP_ARROW) { + scope.history.goUp(event); + } + else if (keycodePressed === DOWN_ARROW) { + scope.history.goDown(event); + } + }); + } +}]) // A directive to anchor the scroller position at the bottom when the browser is resizing. // When the screen resizes, the bottom of the element remains the same, not the top. diff --git a/webclient/room/room.html b/webclient/room/room.html index c807e2afe..278624623 100644 --- a/webclient/room/room.html +++ b/webclient/room/room.html @@ -163,8 +163,7 @@