Console scrolls with log.

This commit is contained in:
Ben Vanik 2013-12-23 20:03:03 -08:00
parent 98efc7ddfa
commit e8d45d80e7
3 changed files with 17 additions and 6 deletions

View File

@ -1,6 +1,6 @@
<div class="console" ng-controller="ConsoleController">
<div class="console-part-log">
<div class="console-log-outer">
<div class="console-log-outer" ui-scroll-down-on="log.lines.length">
<ul>
<li ng-repeat="line in log.lines track by $index">{{line}}</li>
</ul>

View File

@ -14,7 +14,7 @@ var module = angular.module('xe.directives', []);
module.directive('uiEnter', function() {
return function($scope, element, attrs) {
element.bind("keydown keypress", function(e) {
element.bind('keydown keypress', function(e) {
if(e.which === 13) {
$scope.$apply(function(){
$scope.$eval(attrs.uiEnter);
@ -27,7 +27,7 @@ module.directive('uiEnter', function() {
module.directive('uiEscape', function() {
return function($scope, element, attrs) {
element.bind("keydown keypress", function(e) {
element.bind('keydown keypress', function(e) {
if(e.which === 27) {
$scope.$apply(function(){
$scope.$eval(attrs.uiEscape);
@ -38,3 +38,14 @@ module.directive('uiEscape', function() {
};
});
module.directive('uiScrollDownOn', function() {
return {
priority: 1,
link: function($scope, element, attrs) {
$scope.$watch(attrs.uiScrollDownOn, function() {
element[0].scrollTop = element[0].scrollHeight;
});
}
};
});

View File

@ -12,11 +12,11 @@
var module = angular.module('xe.filters', []);
module.filter("hex32", function() {
module.filter('hex32', function() {
return function(number) {
if (number !== null && number !== undefined) {
var str = "" + number.toString(16).toUpperCase();
while (str.length < 8) str = "0" + str;
var str = '' + number.toString(16).toUpperCase();
while (str.length < 8) str = '0' + str;
return str;
}
};