@@ -114,44 +114,12 @@ function zoomCategoryScale(scale, zoom, center, zoomOptions) {
114114 }
115115}
116116
117- function zoomTimeScale ( scale , zoom , center , zoomOptions ) {
118- var options = scale . options ;
119-
120- var range ;
121- var minPercent ;
122- if ( scale . isHorizontal ( ) ) {
123- range = scale . right - scale . left ;
124- minPercent = ( center . x - scale . left ) / range ;
125- } else {
126- range = scale . bottom - scale . top ;
127- minPercent = ( center . y - scale . top ) / range ;
128- }
129-
130- var maxPercent = 1 - minPercent ;
131- var newDiff = range * ( zoom - 1 ) ;
132-
133- var minDelta = newDiff * minPercent ;
134- var maxDelta = newDiff * maxPercent ;
135-
136- var newMin = scale . getValueForPixel ( scale . getPixelForValue ( scale . min ) + minDelta ) ;
137- var newMax = scale . getValueForPixel ( scale . getPixelForValue ( scale . max ) - maxDelta ) ;
138-
139- var diffMinMax = newMax . diff ( newMin ) ;
140- var minLimitExceeded = rangeMinLimiter ( zoomOptions , diffMinMax ) !== diffMinMax ;
141- var maxLimitExceeded = rangeMaxLimiter ( zoomOptions , diffMinMax ) !== diffMinMax ;
142-
143- if ( ! minLimitExceeded && ! maxLimitExceeded ) {
144- options . time . min = newMin ;
145- options . time . max = newMax ;
146- }
147- }
148-
149117function zoomNumericalScale ( scale , zoom , center , zoomOptions ) {
150118 var range = scale . max - scale . min ;
151119 var newDiff = range * ( zoom - 1 ) ;
152120
153- var cursorPixel = scale . isHorizontal ( ) ? center . x : center . y ;
154- var minPercent = ( scale . getValueForPixel ( cursorPixel ) - scale . min ) / range ;
121+ var centerPoint = scale . isHorizontal ( ) ? center . x : center . y ;
122+ var minPercent = ( scale . getValueForPixel ( centerPoint ) - scale . min ) / range ;
155123 var maxPercent = 1 - minPercent ;
156124
157125 var minDelta = newDiff * minPercent ;
@@ -161,6 +129,13 @@ function zoomNumericalScale(scale, zoom, center, zoomOptions) {
161129 scale . options . ticks . max = rangeMaxLimiter ( zoomOptions , scale . max - maxDelta ) ;
162130}
163131
132+ function zoomTimeScale ( scale , zoom , center , zoomOptions ) {
133+ zoomNumericalScale ( scale , zoom , center , zoomOptions ) ;
134+
135+ scale . options . time . min = scale . options . ticks . min ;
136+ scale . options . time . max = scale . options . ticks . max ;
137+ }
138+
164139function zoomScale ( scale , zoom , center , zoomOptions ) {
165140 var fn = zoomFunctions [ scale . options . type ] ;
166141 if ( fn ) {
@@ -241,31 +216,27 @@ function panCategoryScale(scale, delta, panOptions) {
241216 scale . options . ticks . max = rangeMaxLimiter ( panOptions , labels [ maxIndex ] ) ;
242217}
243218
244- function panTimeScale ( scale , delta , panOptions ) {
245- var options = scale . options ;
246- var limitedMax = rangeMaxLimiter ( panOptions , scale . getValueForPixel ( scale . getPixelForValue ( scale . max ) - delta ) ) ;
247- var limitedMin = rangeMinLimiter ( panOptions , scale . getValueForPixel ( scale . getPixelForValue ( scale . min ) - delta ) ) ;
248-
249- var limitedTimeDelta = delta < 0 ? limitedMax - scale . max : limitedMin - scale . min ;
250-
251- options . time . max = scale . max + limitedTimeDelta ;
252- options . time . min = scale . min + limitedTimeDelta ;
253- }
254-
255219function panNumericalScale ( scale , delta , panOptions ) {
256220 var tickOpts = scale . options . ticks ;
257- var start = scale . start ;
258- var end = scale . end ;
221+ var start = scale . min ;
222+ var end = scale . max ;
223+
259224
260225 if ( tickOpts . reverse ) {
261- tickOpts . max = scale . getValueForPixel ( scale . getPixelForValue ( start ) - delta ) ;
262- tickOpts . min = scale . getValueForPixel ( scale . getPixelForValue ( end ) - delta ) ;
226+ tickOpts . min = rangeMinLimiter ( panOptions , scale . getValueForPixel ( scale . getPixelForValue ( end ) - delta ) ) ;
227+ tickOpts . max = rangeMaxLimiter ( panOptions , scale . getValueForPixel ( scale . getPixelForValue ( start ) - delta ) ) ;
263228 } else {
264- tickOpts . min = scale . getValueForPixel ( scale . getPixelForValue ( start ) - delta ) ;
265- tickOpts . max = scale . getValueForPixel ( scale . getPixelForValue ( end ) - delta ) ;
229+ tickOpts . min = rangeMinLimiter ( panOptions , scale . getValueForPixel ( scale . getPixelForValue ( start ) - delta ) ) ;
230+ tickOpts . max = rangeMaxLimiter ( panOptions , scale . getValueForPixel ( scale . getPixelForValue ( end ) - delta ) ) ;
266231 }
267- tickOpts . min = rangeMinLimiter ( panOptions , tickOpts . min ) ;
268- tickOpts . max = rangeMaxLimiter ( panOptions , tickOpts . max ) ;
232+ }
233+
234+ function panTimeScale ( scale , delta , panOptions ) {
235+ panNumericalScale ( scale , delta , panOptions ) ;
236+
237+ var options = scale . options ;
238+ options . time . min = options . ticks . min ;
239+ options . time . max = options . ticks . max ;
269240}
270241
271242function panScale ( scale , delta , panOptions ) {
0 commit comments