@@ -601,32 +601,35 @@ module.exports = function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
601
601
subplots = Object . keys ( plotinfos ) ;
602
602
603
603
for ( var i = 0 ; i < subplots . length ; i ++ ) {
604
+
604
605
var subplot = plotinfos [ subplots [ i ] ] ,
606
+ clipId = 'clip' + fullLayout . _uid + subplots [ i ] + 'plot' ,
605
607
xa2 = subplot . x ( ) ,
606
608
ya2 = subplot . y ( ) ,
607
609
editX = ew && xa . indexOf ( xa2 ) !== - 1 && ! xa2 . fixedrange ,
608
610
editY = ns && ya . indexOf ( ya2 ) !== - 1 && ! ya2 . fixedrange ;
609
611
610
- if ( editX || editY ) {
611
612
612
- var xScaleFactor = xa2 . _length / viewBox [ 2 ] ,
613
- yScaleFactor = ya2 . _length / viewBox [ 3 ] ;
613
+ var xScaleFactor = editX ? xa2 . _length / viewBox [ 2 ] : 1 ,
614
+ yScaleFactor = editY ? ya2 . _length / viewBox [ 3 ] : 1 ;
614
615
615
- var clipDx = editX ? ( viewBox [ 0 ] / viewBox [ 2 ] * xa2 . _length ) : 0 ,
616
- clipDy = editY ? ( viewBox [ 1 ] / viewBox [ 3 ] * ya2 . _length ) : 0 ;
616
+ var clipDx = editX ? viewBox [ 0 ] : 0 ,
617
+ clipDy = editY ? viewBox [ 1 ] : 0 ;
617
618
618
- var plotDx = xa2 . _offset - clipDx ,
619
- plotDy = ya2 . _offset - clipDy ;
619
+ var fracDx = editX ? ( viewBox [ 0 ] / viewBox [ 2 ] * xa2 . _length ) : 0 ,
620
+ fracDy = editY ? ( viewBox [ 1 ] / viewBox [ 3 ] * ya2 . _length ) : 0 ;
620
621
621
- var clipId = 'clip' + fullLayout . _uid + subplots [ i ] + 'plot' ;
622
+ var plotDx = xa2 . _offset - fracDx ,
623
+ plotDy = ya2 . _offset - fracDy ;
622
624
623
- fullLayout . _defs . selectAll ( '#' + clipId )
624
- . call ( Lib . setTranslate , viewBox [ 0 ] , viewBox [ 1 ] )
625
- . call ( Lib . setScale , 1 / xScaleFactor , 1 / yScaleFactor ) ;
626
- subplot . plot
627
- . call ( Lib . setTranslate , plotDx , plotDy )
628
- . call ( Lib . setScale , xScaleFactor , yScaleFactor ) ;
629
- }
625
+
626
+ fullLayout . _defs . selectAll ( '#' + clipId )
627
+ . call ( Lib . setTranslate , clipDx , clipDy )
628
+ . call ( Lib . setScale , 1 / xScaleFactor , 1 / yScaleFactor ) ;
629
+
630
+ subplot . plot
631
+ . call ( Lib . setTranslate , plotDx , plotDy )
632
+ . call ( Lib . setScale , xScaleFactor , yScaleFactor ) ;
630
633
}
631
634
}
632
635
0 commit comments