@@ -139,7 +139,10 @@ module.exports = function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
139139
140140 dragElement . init ( dragOptions ) ;
141141
142- var x0 ,
142+ var zoomlayer = gd . _fullLayout . _zoomlayer ,
143+ xs = plotinfo . x ( ) . _offset ,
144+ ys = plotinfo . y ( ) . _offset ,
145+ x0 ,
143146 y0 ,
144147 box ,
145148 lum ,
@@ -161,22 +164,24 @@ module.exports = function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
161164 dimmed = false ;
162165 zoomMode = 'xy' ;
163166
164- zb = plotinfo . plot . append ( 'path' )
167+ zb = zoomlayer . append ( 'path' )
165168 . attr ( 'class' , 'zoombox' )
166169 . style ( {
167170 'fill' : lum > 0.2 ? 'rgba(0,0,0,0)' : 'rgba(255,255,255,0)' ,
168171 'stroke-width' : 0
169172 } )
173+ . attr ( 'transform' , 'translate(' + xs + ' ' + ys + ')' )
170174 . attr ( 'd' , path0 + 'Z' ) ;
171175
172- corners = plotinfo . plot . append ( 'path' )
176+ corners = zoomlayer . append ( 'path' )
173177 . attr ( 'class' , 'zoombox-corners' )
174178 . style ( {
175179 fill : Color . background ,
176180 stroke : Color . defaultLine ,
177181 'stroke-width' : 1 ,
178182 opacity : 0
179183 } )
184+ . attr ( 'transform' , 'translate(' + xs + ' ' + ys + ')' )
180185 . attr ( 'd' , 'M0,0Z' ) ;
181186
182187 clearSelect ( ) ;
@@ -187,7 +192,7 @@ module.exports = function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
187192 // until we get around to persistent selections, remove the outline
188193 // here. The selection itself will be removed when the plot redraws
189194 // at the end.
190- plotinfo . plot . selectAll ( '.select-outline' ) . remove ( ) ;
195+ zoomlayer . selectAll ( '.select-outline' ) . remove ( ) ;
191196 }
192197
193198 function zoomMove ( dx0 , dy0 ) {
0 commit comments