@@ -27,8 +27,13 @@ var setCursor = require('../../lib/setcursor');
2727var constants = require ( './constants' ) ;
2828
2929module . exports = function ( gd ) {
30- var fullLayout = gd . _fullLayout ,
31- rangeSliderData = makeRangeSliderData ( fullLayout ) ;
30+ var fullLayout = gd . _fullLayout ;
31+ var rangeSliderData = fullLayout . _rangeSliderData ;
32+ for ( var i = 0 ; i < rangeSliderData . length ; i ++ ) {
33+ var opts = rangeSliderData [ i ] [ constants . name ] ;
34+ // fullLayout._uid may not exist when we call makeData
35+ opts . _clipId = opts . _id + '-' + fullLayout . _uid ;
36+ }
3237
3338 /*
3439 * <g container />
@@ -55,10 +60,6 @@ module.exports = function(gd) {
5560 . selectAll ( 'g.' + constants . containerClassName )
5661 . data ( rangeSliderData , keyFunction ) ;
5762
58- rangeSliders . enter ( ) . append ( 'g' )
59- . classed ( constants . containerClassName , true )
60- . attr ( 'pointer-events' , 'all' ) ;
61-
6263 // remove exiting sliders and their corresponding clip paths
6364 rangeSliders . exit ( ) . each ( function ( axisOpts ) {
6465 var opts = axisOpts [ constants . name ] ;
@@ -68,12 +69,16 @@ module.exports = function(gd) {
6869 // return early if no range slider is visible
6970 if ( rangeSliderData . length === 0 ) return ;
7071
72+ rangeSliders . enter ( ) . append ( 'g' )
73+ . classed ( constants . containerClassName , true )
74+ . attr ( 'pointer-events' , 'all' ) ;
75+
7176 // for all present range sliders
7277 rangeSliders . each ( function ( axisOpts ) {
73- var rangeSlider = d3 . select ( this ) ,
74- opts = axisOpts [ constants . name ] ,
75- oppAxisOpts = fullLayout [ Axes . id2name ( axisOpts . anchor ) ] ,
76- oppAxisRangeOpts = opts [ Axes . id2name ( axisOpts . anchor ) ] ;
78+ var rangeSlider = d3 . select ( this ) ;
79+ var opts = axisOpts [ constants . name ] ;
80+ var oppAxisOpts = fullLayout [ Axes . id2name ( axisOpts . anchor ) ] ;
81+ var oppAxisRangeOpts = opts [ Axes . id2name ( axisOpts . anchor ) ] ;
7782
7883 // update range
7984 // Expand slider range to the axis range
@@ -104,12 +109,7 @@ module.exports = function(gd) {
104109 oppBottom = Math . min ( oppBottom , oppAxis . domain [ 0 ] ) ;
105110 }
106111
107- opts . _id = constants . name + axisOpts . _id ;
108- opts . _clipId = opts . _id + '-' + fullLayout . _uid ;
109-
110112 opts . _width = graphSize . w * ( domain [ 1 ] - domain [ 0 ] ) ;
111- opts . _height = ( fullLayout . height - margin . b - margin . t ) * opts . thickness ;
112- opts . _offsetShift = Math . floor ( opts . borderwidth / 2 ) ;
113113
114114 var x = Math . round ( margin . l + ( graphSize . w * domain [ 0 ] ) ) ;
115115
@@ -177,36 +177,9 @@ module.exports = function(gd) {
177177 }
178178 } ) ;
179179 }
180-
181- // update margins
182- Plots . autoMargin ( gd , opts . _id , {
183- x : domain [ 0 ] ,
184- y : oppBottom ,
185- l : 0 ,
186- r : 0 ,
187- t : 0 ,
188- b : opts . _height + margin . b + tickHeight ,
189- pad : constants . extraPad + opts . _offsetShift * 2
190- } ) ;
191180 } ) ;
192181} ;
193182
194- function makeRangeSliderData ( fullLayout ) {
195- var axes = Axes . list ( { _fullLayout : fullLayout } , 'x' , true ) ,
196- name = constants . name ,
197- out = [ ] ;
198-
199- if ( fullLayout . _has ( 'gl2d' ) ) return out ;
200-
201- for ( var i = 0 ; i < axes . length ; i ++ ) {
202- var ax = axes [ i ] ;
203-
204- if ( ax [ name ] && ax [ name ] . visible ) out . push ( ax ) ;
205- }
206-
207- return out ;
208- }
209-
210183function setupDragElement ( rangeSlider , gd , axisOpts , opts ) {
211184 var slideBox = rangeSlider . select ( 'rect.' + constants . slideBoxClassName ) . node ( ) ,
212185 grabAreaMin = rangeSlider . select ( 'rect.' + constants . grabAreaMinClassName ) . node ( ) ,
0 commit comments