forked from MirrorHub/synapse
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.
This commit is contained in:
parent
e4e8ad6780
commit
a7420ff2b5
|
@ -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.
|
// 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.
|
// When the screen resizes, the bottom of the element remains the same, not the top.
|
||||||
|
|
|
@ -163,8 +163,7 @@
|
||||||
<td width="*">
|
<td width="*">
|
||||||
<textarea id="mainInput" rows="1" ng-enter="send()"
|
<textarea id="mainInput" rows="1" ng-enter="send()"
|
||||||
ng-disabled="state.permission_denied"
|
ng-disabled="state.permission_denied"
|
||||||
ng-keydown="(38 === $event.which) ? history.goUp($event) : ((40 === $event.which) ? history.goDown($event) : 0)"
|
ng-focus="true" autocomplete="off" tab-complete command-history/>
|
||||||
ng-focus="true" autocomplete="off" tab-complete/>
|
|
||||||
</td>
|
</td>
|
||||||
<td id="buttonsCell">
|
<td id="buttonsCell">
|
||||||
<button ng-click="send()" ng-disabled="state.permission_denied">Send</button>
|
<button ng-click="send()" ng-disabled="state.permission_denied">Send</button>
|
||||||
|
|
Loading…
Reference in a new issue