Skip to content

Commit

Permalink
[Time Conductor] Fixed zoom slider behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
akhenry committed Oct 22, 2016
1 parent f580661 commit 49e600d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- Parent holder for time conductor. follow-mode | fixed-mode -->
<div ng-controller="TimeConductorController as tcController"
class="holder grows flex-elem l-flex-row l-time-conductor {{modeModel.selectedKey}}-mode {{timeSystemModel.selected.metadata.key}}-time-system"
ng-class="{'status-panning': panning}">
ng-class="{'status-panning': tcController.panning}">

<div class="flex-elem holder time-conductor-icon">
<div class="hand-little"></div>
Expand Down Expand Up @@ -113,13 +113,15 @@
}">
</mct-control>
<!-- Zoom control -->
<div class="l-time-conductor-zoom-w grows flex-elem l-flex-row">
<div ng-if="tcController.supportsZoom"
class="l-time-conductor-zoom-w grows flex-elem l-flex-row">
{{currentZoom}}
<span
class="time-conductor-zoom-current-range flex-elem flex-fixed holder">{{timeUnits}}</span>
<input class="time-conductor-zoom flex-elem" type="range"
ng-model="currentZoom"
ng-mouseUp="tcController.zoomStop(currentZoom)"
ng-change="tcController.zoomDrag(currentZoom)"
ng-model="tcController.currentZoom"
ng-mouseUp="tcController.zoomStop(tcController.currentZoom)"
ng-change="tcController.zoomDrag(tcController.currentZoom)"
min="0.01"
step="0.01"
max="0.99" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ define(
//If conductor has a time system selected already, populate the
//form from it
this.$scope.timeSystemModel = {};
if (this.conductor.timeSystem()) {
this.setFormFromTimeSystem(this.conductor.timeSystem());
var timeSystem = this.conductor.timeSystem();
if (timeSystem) {
this.setFormFromTimeSystem(timeSystem);
this.supportsZoom = timeSystem.defaults().zoom !== undefined;
}

//Represents the various modes, and the currently selected mode
Expand Down Expand Up @@ -114,17 +116,17 @@ define(
};

TimeConductorController.prototype.onPan = function (bounds) {
this.$scope.panning = true;
this.panning = true;
this.$scope.boundsModel.start = bounds.start;
this.$scope.boundsModel.end = bounds.end;
};

TimeConductorController.prototype.onPanStop = function () {
this.$scope.panning = false;
this.panning = false;
};

TimeConductorController.prototype.changeBounds = function (bounds) {
if (!this.$scope.zooming && !this.$scope.panning) {
if (!this.zooming && !this.panning) {
this.setFormFromBounds(bounds);
}
};
Expand All @@ -136,12 +138,14 @@ define(
* @private
*/
TimeConductorController.prototype.setFormFromBounds = function (bounds) {
if (!this.$scope.zooming && ! this.$scope.panning) {
if (!this.zooming && ! this.panning) {
this.$scope.boundsModel.start = bounds.start;
this.$scope.boundsModel.end = bounds.end;

this.$scope.currentZoom = this.toSliderValue(bounds.end - bounds.start);
this.toTimeUnits(bounds.end - bounds.start);
if (this.supportsZoom) {
this.currentZoom = this.toSliderValue(bounds.end - bounds.start);
this.toTimeUnits(bounds.end - bounds.start);
}

if (!this.pendingUpdate) {
this.pendingUpdate = true;
Expand Down Expand Up @@ -182,8 +186,10 @@ define(
timeSystemModel.selected = timeSystem;
timeSystemModel.format = timeSystem.formats()[0];
timeSystemModel.deltaFormat = timeSystem.deltaFormat();
timeSystemModel.minZoom = timeSystem.defaults().zoom.min;
timeSystemModel.maxZoom = timeSystem.defaults().zoom.max;
if (this.supportsZoom) {
timeSystemModel.minZoom = timeSystem.defaults().zoom.min;
timeSystemModel.maxZoom = timeSystem.defaults().zoom.max;
}
};


Expand Down Expand Up @@ -265,6 +271,8 @@ define(

this.setFormFromDeltas(deltas);
this.setFormFromBounds(bounds);

this.supportsZoom = newTimeSystem.defaults().zoom !== undefined;
}
this.setFormFromTimeSystem(newTimeSystem);
}
Expand Down Expand Up @@ -300,15 +308,13 @@ define(
if (zoom.deltas) {
this.setFormFromDeltas(zoom.deltas);
}

this.$scope.zooming = true;
};

TimeConductorController.prototype.zoomStop = function () {
this.updateBoundsFromForm(this.$scope.boundsModel);
this.updateDeltasFromForm(this.$scope.boundsModel);
this.zooming = false;

this.$scope.zooming = false;
this.conductorViewService.emit('zoom-stop');
};

Expand Down
7 changes: 7 additions & 0 deletions platform/features/table/src/controllers/MCTTableController.js
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,10 @@ define(
return rowsToFilter.filter(matchRow.bind(null, filters));
};

/**
* @param displayRowIndex {number} The index in the displayed rows
* to scroll to.
*/
MCTTableController.prototype.scrollToRow = function (displayRowIndex) {

var visible = displayRowIndex > this.firstVisible() && displayRowIndex < this.lastVisible();
Expand Down Expand Up @@ -639,6 +643,9 @@ define(
this.setTimeOfInterest(this.conductor.timeOfInterest());
};

/**
* @private
*/
MCTTableController.prototype.onRowClick = function (event, rowIndex) {
if (this.$scope.timeColumns.indexOf(this.$scope.sortColumn) !== -1) {
var selectedTime = this.$scope.displayRows[rowIndex][this.$scope.sortColumn].text;
Expand Down

0 comments on commit 49e600d

Please sign in to comment.