@@ -151,29 +151,8 @@ function findDimensions(gd, sliderOpts) {
151
151
constants . gripHeight
152
152
) ;
153
153
154
- sliderOpts . currentValueMaxWidth = 0 ;
155
- sliderOpts . currentValueHeight = 0 ;
156
- sliderOpts . currentValueTotalHeight = 0 ;
157
- sliderOpts . currentValueMaxLines = 1 ;
158
-
159
- if ( sliderOpts . currentvalue . visible ) {
160
- // Get the dimensions of the current value label:
161
- var dummyGroup = Drawing . tester . append ( 'g' ) ;
162
-
163
- sliderLabels . each ( function ( stepOpts ) {
164
- var curValPrefix = drawCurrentValue ( dummyGroup , sliderOpts , stepOpts . label ) ;
165
- var curValSize = ( curValPrefix . node ( ) && Drawing . bBox ( curValPrefix . node ( ) ) ) || { width : 0 , height : 0 } ;
166
- var lines = svgTextUtils . lineCount ( curValPrefix ) ;
167
- sliderOpts . currentValueMaxWidth = Math . max ( sliderOpts . currentValueMaxWidth , Math . ceil ( curValSize . width ) ) ;
168
- sliderOpts . currentValueHeight = Math . max ( sliderOpts . currentValueHeight , Math . ceil ( curValSize . height ) ) ;
169
- sliderOpts . currentValueMaxLines = Math . max ( sliderOpts . currentValueMaxLines , lines ) ;
170
- } ) ;
171
-
172
- sliderOpts . currentValueTotalHeight = sliderOpts . currentValueHeight + sliderOpts . currentvalue . offset ;
173
-
174
- dummyGroup . remove ( ) ;
175
- }
176
-
154
+ // calculate some overall dimensions - some of these are needed for
155
+ // calculating the currentValue dimensions
177
156
var graphSize = gd . _fullLayout . _size ;
178
157
sliderOpts . lx = graphSize . l + graphSize . w * sliderOpts . x ;
179
158
sliderOpts . ly = graphSize . t + graphSize . h * ( 1 - sliderOpts . y ) ;
@@ -200,6 +179,31 @@ function findDimensions(gd, sliderOpts) {
200
179
sliderOpts . labelStride = Math . max ( 1 , Math . ceil ( computedSpacePerLabel / availableSpacePerLabel ) ) ;
201
180
sliderOpts . labelHeight = labelHeight ;
202
181
182
+ // loop over all possible values for currentValue to find the
183
+ // area we need for it
184
+ sliderOpts . currentValueMaxWidth = 0 ;
185
+ sliderOpts . currentValueHeight = 0 ;
186
+ sliderOpts . currentValueTotalHeight = 0 ;
187
+ sliderOpts . currentValueMaxLines = 1 ;
188
+
189
+ if ( sliderOpts . currentvalue . visible ) {
190
+ // Get the dimensions of the current value label:
191
+ var dummyGroup = Drawing . tester . append ( 'g' ) ;
192
+
193
+ sliderLabels . each ( function ( stepOpts ) {
194
+ var curValPrefix = drawCurrentValue ( dummyGroup , sliderOpts , stepOpts . label ) ;
195
+ var curValSize = ( curValPrefix . node ( ) && Drawing . bBox ( curValPrefix . node ( ) ) ) || { width : 0 , height : 0 } ;
196
+ var lines = svgTextUtils . lineCount ( curValPrefix ) ;
197
+ sliderOpts . currentValueMaxWidth = Math . max ( sliderOpts . currentValueMaxWidth , Math . ceil ( curValSize . width ) ) ;
198
+ sliderOpts . currentValueHeight = Math . max ( sliderOpts . currentValueHeight , Math . ceil ( curValSize . height ) ) ;
199
+ sliderOpts . currentValueMaxLines = Math . max ( sliderOpts . currentValueMaxLines , lines ) ;
200
+ } ) ;
201
+
202
+ sliderOpts . currentValueTotalHeight = sliderOpts . currentValueHeight + sliderOpts . currentvalue . offset ;
203
+
204
+ dummyGroup . remove ( ) ;
205
+ }
206
+
203
207
sliderOpts . height = sliderOpts . currentValueTotalHeight + constants . tickOffset + sliderOpts . ticklen + constants . labelOffset + sliderOpts . labelHeight + sliderOpts . pad . t + sliderOpts . pad . b ;
204
208
205
209
var xanchor = 'left' ;
0 commit comments