@@ -347,7 +347,7 @@ module.exports = function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
347
347
var scrollViewBox = [ 0 , 0 , pw , ph ] ,
348
348
// wait a little after scrolling before redrawing
349
349
redrawTimer = null ,
350
- REDRAWDELAY = 300 ,
350
+ REDRAWDELAY = 50 ,
351
351
mainplot = plotinfo . mainplot ?
352
352
fullLayout . _plots [ plotinfo . mainplot ] : plotinfo ;
353
353
@@ -608,19 +608,24 @@ module.exports = function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
608
608
editY = ns && ya . indexOf ( ya2 ) !== - 1 && ! ya2 . fixedrange ;
609
609
610
610
if ( editX || editY ) {
611
- // plot requires offset position and
612
- // clip moves with opposite sign
613
- var clipDx = editX ? viewBox [ 0 ] : 0 ,
614
- clipDy = editY ? viewBox [ 1 ] : 0 ,
615
- plotDx = xa2 . _offset - clipDx ,
611
+
612
+ var xScaleFactor = xa2 . _length / viewBox [ 2 ] ,
613
+ yScaleFactor = ya2 . _length / viewBox [ 3 ] ;
614
+
615
+ var clipDx = editX ? ( viewBox [ 0 ] / viewBox [ 2 ] * xa2 . _length ) : 0 ,
616
+ clipDy = editY ? ( viewBox [ 1 ] / viewBox [ 3 ] * ya2 . _length ) : 0 ;
617
+
618
+ var plotDx = xa2 . _offset - clipDx ,
616
619
plotDy = ya2 . _offset - clipDy ;
617
620
618
621
var clipId = 'clip' + fullLayout . _uid + subplots [ i ] + 'plot' ;
619
622
620
623
fullLayout . _defs . selectAll ( '#' + clipId )
621
- . attr ( 'transform' , 'translate(' + clipDx + ', ' + clipDy + ')' ) ;
624
+ . call ( Lib . setTranslate , viewBox [ 0 ] , viewBox [ 1 ] )
625
+ . call ( Lib . setScale , 1 / xScaleFactor , 1 / yScaleFactor ) ;
622
626
subplot . plot
623
- . attr ( 'transform' , 'translate(' + plotDx + ', ' + plotDy + ')' ) ;
627
+ . call ( Lib . setTranslate , plotDx , plotDy )
628
+ . call ( Lib . setScale , xScaleFactor , yScaleFactor ) ;
624
629
}
625
630
}
626
631
}
0 commit comments