@@ -53,7 +53,7 @@ define(
53
53
//Set the initial state of the view based on current time conductor
54
54
this . initializeScope ( ) ;
55
55
56
- this . conductor . on ( 'bounds' , this . setFormFromBounds ) ;
56
+ this . conductor . on ( 'bounds' , this . changeBounds ) ;
57
57
this . conductor . on ( 'timeSystem' , this . changeTimeSystem ) ;
58
58
59
59
// If no mode selected, select fixed as the default
@@ -98,46 +98,58 @@ define(
98
98
99
99
// Watch scope for selection of mode or time system by user
100
100
this . $scope . $watch ( 'modeModel.selectedKey' , this . setMode ) ;
101
- this . conductorViewService . on ( 'pan' , this . pan ) ;
102
101
103
- this . conductorViewService . on ( 'pan-stop' , this . panStop ) ;
102
+ this . conductorViewService . on ( 'pan' , this . onPan ) ;
103
+ this . conductorViewService . on ( 'pan-stop' , this . onPanStop ) ;
104
104
105
105
this . $scope . $on ( '$destroy' , this . destroy ) ;
106
106
} ;
107
107
108
108
TimeConductorController . prototype . destroy = function ( ) {
109
109
this . conductor . off ( 'bounds' , this . setFormFromBounds ) ;
110
110
this . conductor . off ( 'timeSystem' , this . changeTimeSystem ) ;
111
+
112
+ this . conductorViewService . off ( 'pan' , this . onPan ) ;
113
+ this . conductorViewService . off ( 'pan-stop' , this . onPanStop ) ;
111
114
} ;
112
115
113
- TimeConductorController . prototype . pan = function ( bounds ) {
116
+ TimeConductorController . prototype . onPan = function ( bounds ) {
114
117
this . $scope . panning = true ;
115
- this . setFormFromBounds ( bounds ) ;
118
+ this . $scope . boundsModel . start = bounds . start ;
119
+ this . $scope . boundsModel . end = bounds . end ;
116
120
} ;
117
121
118
- TimeConductorController . prototype . panStop = function ( ) {
122
+ TimeConductorController . prototype . onPanStop = function ( ) {
119
123
this . $scope . panning = false ;
120
124
} ;
121
125
126
+ TimeConductorController . prototype . changeBounds = function ( bounds ) {
127
+ if ( ! this . $scope . zooming && ! this . $scope . panning ) {
128
+ this . setFormFromBounds ( bounds ) ;
129
+ }
130
+ } ;
131
+
122
132
/**
123
133
* Called when the bounds change in the time conductor. Synchronizes
124
134
* the bounds values in the time conductor with those in the form
125
135
*
126
136
* @private
127
137
*/
128
138
TimeConductorController . prototype . setFormFromBounds = function ( bounds ) {
129
- this . $scope . boundsModel . start = bounds . start ;
130
- this . $scope . boundsModel . end = bounds . end ;
131
-
132
- this . $scope . currentZoom = this . toSliderValue ( bounds . end - bounds . start ) ;
133
- this . toTimeUnits ( bounds . end - bounds . start ) ;
134
-
135
- if ( ! this . pendingUpdate ) {
136
- this . pendingUpdate = true ;
137
- this . $window . requestAnimationFrame ( function ( ) {
138
- this . pendingUpdate = false ;
139
- this . $scope . $digest ( ) ;
140
- } . bind ( this ) ) ;
139
+ if ( ! this . $scope . zooming && ! this . $scope . panning ) {
140
+ this . $scope . boundsModel . start = bounds . start ;
141
+ this . $scope . boundsModel . end = bounds . end ;
142
+
143
+ this . $scope . currentZoom = this . toSliderValue ( bounds . end - bounds . start ) ;
144
+ this . toTimeUnits ( bounds . end - bounds . start ) ;
145
+
146
+ if ( ! this . pendingUpdate ) {
147
+ this . pendingUpdate = true ;
148
+ this . $window . requestAnimationFrame ( function ( ) {
149
+ this . pendingUpdate = false ;
150
+ this . $scope . $digest ( ) ;
151
+ } . bind ( this ) ) ;
152
+ }
141
153
}
142
154
} ;
143
155
@@ -267,30 +279,37 @@ define(
267
279
}
268
280
} ;
269
281
270
- TimeConductorController . prototype . toTimeSpan = function ( sliderValue ) {
271
- var center = this . $scope . boundsModel . start +
272
- ( ( this . $scope . boundsModel . end - this . $scope . boundsModel . start ) / 2 ) ;
273
- var zoomDefaults = this . conductor . timeSystem ( ) . defaults ( ) . zoom ;
274
- var timeSpan = Math . pow ( ( 1 - sliderValue ) , 4 ) * ( zoomDefaults . min - zoomDefaults . max ) ;
275
- return { start : center - timeSpan / 2 , end : center + timeSpan / 2 } ;
276
- } ;
277
-
278
282
TimeConductorController . prototype . toTimeUnits = function ( timeSpan ) {
279
283
if ( this . conductor . timeSystem ( ) ) {
280
284
var timeFormat = this . formatService . getFormat ( this . conductor . timeSystem ( ) . formats ( ) [ 0 ] ) ;
281
285
this . $scope . timeUnits = timeFormat . timeUnits && timeFormat . timeUnits ( timeSpan ) ;
282
286
}
283
- }
287
+ } ;
288
+
289
+ TimeConductorController . prototype . zoomDrag = function ( sliderValue ) {
290
+ var zoomDefaults = this . conductor . timeSystem ( ) . defaults ( ) . zoom ;
291
+ var timeSpan = Math . pow ( ( 1 - sliderValue ) , 4 ) * ( zoomDefaults . min - zoomDefaults . max ) ;
284
292
285
- TimeConductorController . prototype . zoom = function ( sliderValue ) {
286
- var bounds = this . toTimeSpan ( sliderValue ) ;
287
- this . setFormFromBounds ( bounds ) ;
288
- this . conductorViewService . emit ( "zoom" , bounds ) ;
293
+
294
+ var zoom = this . conductorViewService . zoom ( timeSpan ) ;
295
+
296
+ this . $scope . boundsModel . start = zoom . bounds . start ;
297
+ this . $scope . boundsModel . end = zoom . bounds . end ;
298
+ this . toTimeUnits ( zoom . bounds . end - zoom . bounds . start ) ;
299
+
300
+ if ( zoom . deltas ) {
301
+ this . setFormFromDeltas ( zoom . deltas ) ;
302
+ }
303
+
304
+ this . $scope . zooming = true ;
289
305
} ;
290
306
291
- TimeConductorController . prototype . zoomStop = function ( sliderValue ) {
292
- var bounds = this . toTimeSpan ( sliderValue ) ;
293
- this . conductor . bounds ( bounds ) ;
307
+ TimeConductorController . prototype . zoomStop = function ( ) {
308
+ this . updateBoundsFromForm ( this . $scope . boundsModel ) ;
309
+ this . updateDeltasFromForm ( this . $scope . boundsModel ) ;
310
+
311
+ this . $scope . zooming = false ;
312
+ this . conductorViewService . emit ( 'zoom-stop' ) ;
294
313
} ;
295
314
296
315
return TimeConductorController ;
0 commit comments