Skip to content

Commit 49e600d

Browse files
committed
[Time Conductor] Fixed zoom slider behavior
1 parent f580661 commit 49e600d

File tree

3 files changed

+33
-18
lines changed

3 files changed

+33
-18
lines changed

platform/features/conductor-v2/conductor/res/templates/time-conductor.html

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!-- Parent holder for time conductor. follow-mode | fixed-mode -->
22
<div ng-controller="TimeConductorController as tcController"
33
class="holder grows flex-elem l-flex-row l-time-conductor {{modeModel.selectedKey}}-mode {{timeSystemModel.selected.metadata.key}}-time-system"
4-
ng-class="{'status-panning': panning}">
4+
ng-class="{'status-panning': tcController.panning}">
55

66
<div class="flex-elem holder time-conductor-icon">
77
<div class="hand-little"></div>
@@ -113,13 +113,15 @@
113113
}">
114114
</mct-control>
115115
<!-- Zoom control -->
116-
<div class="l-time-conductor-zoom-w grows flex-elem l-flex-row">
116+
<div ng-if="tcController.supportsZoom"
117+
class="l-time-conductor-zoom-w grows flex-elem l-flex-row">
118+
{{currentZoom}}
117119
<span
118120
class="time-conductor-zoom-current-range flex-elem flex-fixed holder">{{timeUnits}}</span>
119121
<input class="time-conductor-zoom flex-elem" type="range"
120-
ng-model="currentZoom"
121-
ng-mouseUp="tcController.zoomStop(currentZoom)"
122-
ng-change="tcController.zoomDrag(currentZoom)"
122+
ng-model="tcController.currentZoom"
123+
ng-mouseUp="tcController.zoomStop(tcController.currentZoom)"
124+
ng-change="tcController.zoomDrag(tcController.currentZoom)"
123125
min="0.01"
124126
step="0.01"
125127
max="0.99" />

platform/features/conductor-v2/conductor/src/ui/TimeConductorController.js

+19-13
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,10 @@ define(
7272
//If conductor has a time system selected already, populate the
7373
//form from it
7474
this.$scope.timeSystemModel = {};
75-
if (this.conductor.timeSystem()) {
76-
this.setFormFromTimeSystem(this.conductor.timeSystem());
75+
var timeSystem = this.conductor.timeSystem();
76+
if (timeSystem) {
77+
this.setFormFromTimeSystem(timeSystem);
78+
this.supportsZoom = timeSystem.defaults().zoom !== undefined;
7779
}
7880

7981
//Represents the various modes, and the currently selected mode
@@ -114,17 +116,17 @@ define(
114116
};
115117

116118
TimeConductorController.prototype.onPan = function (bounds) {
117-
this.$scope.panning = true;
119+
this.panning = true;
118120
this.$scope.boundsModel.start = bounds.start;
119121
this.$scope.boundsModel.end = bounds.end;
120122
};
121123

122124
TimeConductorController.prototype.onPanStop = function () {
123-
this.$scope.panning = false;
125+
this.panning = false;
124126
};
125127

126128
TimeConductorController.prototype.changeBounds = function (bounds) {
127-
if (!this.$scope.zooming && !this.$scope.panning) {
129+
if (!this.zooming && !this.panning) {
128130
this.setFormFromBounds(bounds);
129131
}
130132
};
@@ -136,12 +138,14 @@ define(
136138
* @private
137139
*/
138140
TimeConductorController.prototype.setFormFromBounds = function (bounds) {
139-
if (!this.$scope.zooming && ! this.$scope.panning) {
141+
if (!this.zooming && ! this.panning) {
140142
this.$scope.boundsModel.start = bounds.start;
141143
this.$scope.boundsModel.end = bounds.end;
142144

143-
this.$scope.currentZoom = this.toSliderValue(bounds.end - bounds.start);
144-
this.toTimeUnits(bounds.end - bounds.start);
145+
if (this.supportsZoom) {
146+
this.currentZoom = this.toSliderValue(bounds.end - bounds.start);
147+
this.toTimeUnits(bounds.end - bounds.start);
148+
}
145149

146150
if (!this.pendingUpdate) {
147151
this.pendingUpdate = true;
@@ -182,8 +186,10 @@ define(
182186
timeSystemModel.selected = timeSystem;
183187
timeSystemModel.format = timeSystem.formats()[0];
184188
timeSystemModel.deltaFormat = timeSystem.deltaFormat();
185-
timeSystemModel.minZoom = timeSystem.defaults().zoom.min;
186-
timeSystemModel.maxZoom = timeSystem.defaults().zoom.max;
189+
if (this.supportsZoom) {
190+
timeSystemModel.minZoom = timeSystem.defaults().zoom.min;
191+
timeSystemModel.maxZoom = timeSystem.defaults().zoom.max;
192+
}
187193
};
188194

189195

@@ -265,6 +271,8 @@ define(
265271

266272
this.setFormFromDeltas(deltas);
267273
this.setFormFromBounds(bounds);
274+
275+
this.supportsZoom = newTimeSystem.defaults().zoom !== undefined;
268276
}
269277
this.setFormFromTimeSystem(newTimeSystem);
270278
}
@@ -300,15 +308,13 @@ define(
300308
if (zoom.deltas) {
301309
this.setFormFromDeltas(zoom.deltas);
302310
}
303-
304-
this.$scope.zooming = true;
305311
};
306312

307313
TimeConductorController.prototype.zoomStop = function () {
308314
this.updateBoundsFromForm(this.$scope.boundsModel);
309315
this.updateDeltasFromForm(this.$scope.boundsModel);
316+
this.zooming = false;
310317

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

platform/features/table/src/controllers/MCTTableController.js

+7
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,10 @@ define(
597597
return rowsToFilter.filter(matchRow.bind(null, filters));
598598
};
599599

600+
/**
601+
* @param displayRowIndex {number} The index in the displayed rows
602+
* to scroll to.
603+
*/
600604
MCTTableController.prototype.scrollToRow = function (displayRowIndex) {
601605

602606
var visible = displayRowIndex > this.firstVisible() && displayRowIndex < this.lastVisible();
@@ -639,6 +643,9 @@ define(
639643
this.setTimeOfInterest(this.conductor.timeOfInterest());
640644
};
641645

646+
/**
647+
* @private
648+
*/
642649
MCTTableController.prototype.onRowClick = function (event, rowIndex) {
643650
if (this.$scope.timeColumns.indexOf(this.$scope.sortColumn) !== -1) {
644651
var selectedTime = this.$scope.displayRows[rowIndex][this.$scope.sortColumn].text;

0 commit comments

Comments
 (0)