@@ -123,35 +123,39 @@ function _draw(gd, legendObj) {
123
123
Plots . previousPromises ,
124
124
function ( ) { return computeLegendDimensions ( gd , groups , traces , legendObj ) ; } ,
125
125
function ( ) {
126
- // IF expandMargin return a Promise (which is truthy),
127
- // we're under a doAutoMargin redraw, so we don't have to
128
- // draw the remaining pieces below
129
- if ( ! inHover && expandMargin ( gd ) ) return ;
130
-
131
126
var gs = fullLayout . _size ;
132
127
var bw = legendObj . borderwidth ;
133
128
134
- var lx = gs . l + gs . w * legendObj . x - FROM_TL [ getXanchor ( legendObj ) ] * legendObj . _width ;
135
- var ly = gs . t + gs . h * ( 1 - legendObj . y ) - FROM_TL [ getYanchor ( legendObj ) ] * legendObj . _effHeight ;
129
+ if ( ! inHover ) {
130
+ var expMargin = expandMargin ( gd ) ;
136
131
137
- if ( ! inHover && fullLayout . margin . autoexpand ) {
138
- var lx0 = lx ;
139
- var ly0 = ly ;
132
+ // IF expandMargin return a Promise (which is truthy),
133
+ // we're under a doAutoMargin redraw, so we don't have to
134
+ // draw the remaining pieces below
135
+ if ( expMargin ) return ;
140
136
141
- lx = Lib . constrain ( lx , 0 , fullLayout . width - legendObj . _width ) ;
142
- ly = Lib . constrain ( ly , 0 , fullLayout . height - legendObj . _effHeight ) ;
137
+ var lx = gs . l + gs . w * legendObj . x - FROM_TL [ getXanchor ( legendObj ) ] * legendObj . _width ;
138
+ var ly = gs . t + gs . h * ( 1 - legendObj . y ) - FROM_TL [ getYanchor ( legendObj ) ] * legendObj . _effHeight ;
143
139
144
- if ( lx !== lx0 ) {
145
- Lib . log ( 'Constrain legend.x to make legend fit inside graph' ) ;
146
- }
147
- if ( ly !== ly0 ) {
148
- Lib . log ( 'Constrain legend.y to make legend fit inside graph' ) ;
140
+ if ( fullLayout . margin . autoexpand ) {
141
+ var lx0 = lx ;
142
+ var ly0 = ly ;
143
+
144
+ lx = Lib . constrain ( lx , 0 , fullLayout . width - legendObj . _width ) ;
145
+ ly = Lib . constrain ( ly , 0 , fullLayout . height - legendObj . _effHeight ) ;
146
+
147
+ if ( lx !== lx0 ) {
148
+ Lib . log ( 'Constrain legend.x to make legend fit inside graph' ) ;
149
+ }
150
+ if ( ly !== ly0 ) {
151
+ Lib . log ( 'Constrain legend.y to make legend fit inside graph' ) ;
152
+ }
149
153
}
150
- }
151
154
152
- // Set size and position of all the elements that make up a legend:
153
- // legend, background and border, scroll box and scroll bar as well as title
154
- if ( ! inHover ) Drawing . setTranslate ( legend , lx , ly ) ;
155
+ // Set size and position of all the elements that make up a legend:
156
+ // legend, background and border, scroll box and scroll bar as well as title
157
+ Drawing . setTranslate ( legend , lx , ly ) ;
158
+ }
155
159
156
160
// to be safe, remove previous listeners
157
161
scrollBar . on ( '.drag' , null ) ;
0 commit comments