[Events] Changed directive variables

Changed scrollDirection to ascendingScroll, which acts like
a boolean. Now there is proper communication between the
html and the directive itself. #18.
This commit is contained in:
Sarah Hale 2015-06-23 12:40:50 -07:00
parent 3337777fea
commit fdab799e5b
3 changed files with 7 additions and 21 deletions

View File

@ -23,7 +23,7 @@
"directives": [
{
"key": "mctDataTable",
"implementation": "MCTDataTable.js",
"implementation": "directives/MCTDataTable.js",
"depends": [ "$anchorScroll" ]
}
]

View File

@ -22,23 +22,7 @@
<div class="w1" ng-controller="TelemetryController as telemetry">
<div class="w2"
ng-controller="EventListController">
<mct-data-table scroll-direction="descending" headers="headers" rows="rows"></mct-data-table>
<!-- <table class="tabular">
<thead>
<tr>
<th ng-repeat="header in headers">
{{header}}
</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="row in rows">
<td ng-repeat="cell in row">
{{cell}}
</td>
</tr>
</tbody>
</table> -->
<mct-data-table headers="headers" rows="rows" ascending-scroll="true"></mct-data-table>
</div>
</div>

View File

@ -40,18 +40,18 @@ define(
scope: {
headers: "=",
rows: "=",
scrollDirection: "="
ascendingScroll: "="
},
link: function ($scope, $element) {
var currentHeight,
previousHeight;
// If the chosen scoll ascending is descending, we want to
// If the scroll is set to ascending, we want to
// check when elements are added to the table, and move the scroll
// bar accordingly.
// (When viewing at the bottom of the page, the scroll bar will
// stay at the bottom despite additions to the table)
if ($scope.scrollDirection === "ascending") {
if ($scope.ascendingScroll) {
$scope.$watch("rows", function () {
// Wait until the page as been repainted (otherwise the
// height will always be zero)
@ -60,6 +60,8 @@ define(
// The offsetHeight of the table body
currentHeight =
$element[0].firstElementChild.firstElementChild.nextElementSibling.offsetHeight;
console.log("current height ", currentHeight);
});
// TODO: Find a more eloquent way to determine repaint completion