@@ -108,20 +108,24 @@ function drawOne(gd, index) {
108
108
. call ( Color . fill , options . fillcolor )
109
109
. call ( Drawing . dashLine , options . line . dash , options . line . width ) ;
110
110
111
- // note that for layer="below" the clipAxes can be different from the
112
- // subplot we're drawing this in. This could cause problems if the shape
113
- // spans two subplots. See https://github.com/plotly/plotly.js/issues/1452
114
- var clipAxes = ( options . xref + options . yref ) . replace ( / p a p e r / g, '' ) ;
115
-
116
- path . call ( Drawing . setClipUrl , clipAxes ?
117
- ( 'clip' + gd . _fullLayout . _uid + clipAxes ) :
118
- null
119
- ) ;
111
+ setClipPath ( path , gd , options ) ;
120
112
121
113
if ( gd . _context . edits . shapePosition ) setupDragElement ( gd , path , options , index , shapeLayer ) ;
122
114
}
123
115
}
124
116
117
+ function setClipPath ( shapePath , gd , shapeOptions ) {
118
+ // note that for layer="below" the clipAxes can be different from the
119
+ // subplot we're drawing this in. This could cause problems if the shape
120
+ // spans two subplots. See https://github.com/plotly/plotly.js/issues/1452
121
+ var clipAxes = ( shapeOptions . xref + shapeOptions . yref ) . replace ( / p a p e r / g, '' ) ;
122
+
123
+ shapePath . call ( Drawing . setClipUrl , clipAxes ?
124
+ ( 'clip' + gd . _fullLayout . _uid + clipAxes ) :
125
+ null
126
+ ) ;
127
+ }
128
+
125
129
function setupDragElement ( gd , shapePath , shapeOptions , index , shapeLayer ) {
126
130
var MINWIDTH = 10 ,
127
131
MINHEIGHT = 10 ;
@@ -291,11 +295,15 @@ function setupDragElement(gd, shapePath, shapeOptions, index, shapeLayer) {
291
295
292
296
// setup dragMode and the corresponding handler
293
297
updateDragMode ( evt ) ;
298
+ deactivateClipPathTemporarily ( shapePath , shapeOptions , gd ) ;
294
299
dragOptions . moveFn = ( dragMode === 'move' ) ? moveShape : resizeShape ;
295
300
}
296
301
297
302
function endDrag ( ) {
298
303
setCursor ( shapePath ) ;
304
+
305
+ // Don't rely on clipPath being activated during re-layout
306
+ setClipPath ( shapePath , gd , shapeOptions ) ;
299
307
Registry . call ( 'relayout' , gd , update ) ;
300
308
}
301
309
@@ -404,6 +412,22 @@ function setupDragElement(gd, shapePath, shapeOptions, index, shapeLayer) {
404
412
405
413
shapePath . attr ( 'd' , getPathString ( gd , shapeOptions ) ) ;
406
414
}
415
+
416
+ function deactivateClipPathTemporarily ( shapePath , shapeOptions , gd ) {
417
+ var xref = shapeOptions . xref ,
418
+ yref = shapeOptions . yref ,
419
+ xa = Axes . getFromId ( gd , xref ) ,
420
+ ya = Axes . getFromId ( gd , yref ) ;
421
+
422
+ var clipAxes = '' ;
423
+ if ( xref !== 'paper' && ! xa . autorange ) clipAxes += xref ;
424
+ if ( yref !== 'paper' && ! ya . autorange ) clipAxes += yref ;
425
+
426
+ shapePath . call ( Drawing . setClipUrl , clipAxes ?
427
+ 'clip' + gd . _fullLayout . _uid + clipAxes :
428
+ null
429
+ ) ;
430
+ }
407
431
}
408
432
409
433
function getPathString ( gd , options ) {
0 commit comments