@@ -90,6 +90,9 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
90
90
var hasScatterGl , hasSplom , hasSVG ;
91
91
// collected changes to be made to the plot by relayout at the end
92
92
var updates ;
93
+ // scaling factors from css transform
94
+ var scaleX ;
95
+ var scaleY ;
93
96
94
97
function recomputeAxisLists ( ) {
95
98
xa0 = plotinfo . xaxis ;
@@ -161,6 +164,10 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
161
164
162
165
recomputeAxisLists ( ) ;
163
166
167
+ var m = gd . _fullLayout . _inverseTransform ;
168
+ scaleX = Math . sqrt ( m [ 0 ] [ 0 ] * m [ 0 ] [ 0 ] + m [ 0 ] [ 1 ] * m [ 0 ] [ 1 ] ) ;
169
+ scaleY = Math . sqrt ( m [ 1 ] [ 0 ] * m [ 1 ] [ 0 ] + m [ 1 ] [ 1 ] * m [ 1 ] [ 1 ] ) ;
170
+
164
171
if ( ! allFixedRanges ) {
165
172
if ( isMainDrag ) {
166
173
// main dragger handles all drag modes, and changes
@@ -331,11 +338,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
331
338
x0 = transformedCoords [ 0 ] ;
332
339
y0 = transformedCoords [ 1 ] ;
333
340
334
- var m = gd . _fullLayout . _inverseTransform ;
335
- var scaleX = Math . sqrt ( m [ 0 ] [ 0 ] * m [ 0 ] [ 0 ] + m [ 0 ] [ 1 ] * m [ 0 ] [ 1 ] + m [ 0 ] [ 2 ] * m [ 0 ] [ 2 ] ) ;
336
- var scaleY = Math . sqrt ( m [ 1 ] [ 0 ] * m [ 1 ] [ 0 ] + m [ 1 ] [ 1 ] * m [ 1 ] [ 1 ] + m [ 1 ] [ 2 ] * m [ 1 ] [ 2 ] ) ;
337
-
338
- box = { l : x0 , r : x0 , w : 0 , t : y0 , b : y0 , h : 0 , scaleX : scaleX , scaleY : scaleY } ;
341
+ box = { l : x0 , r : x0 , w : 0 , t : y0 , b : y0 , h : 0 } ;
339
342
lum = gd . _hmpixcount ?
340
343
( gd . _hmlumcount / gd . _hmpixcount ) :
341
344
tinycolor ( gd . _fullLayout . plot_bgcolor ) . getLuminance ( ) ;
@@ -352,8 +355,8 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
352
355
return false ;
353
356
}
354
357
355
- var x1 = Math . max ( 0 , Math . min ( pw , box . scaleX * dx0 + x0 ) ) ;
356
- var y1 = Math . max ( 0 , Math . min ( ph , box . scaleY * dy0 + y0 ) ) ;
358
+ var x1 = Math . max ( 0 , Math . min ( pw , scaleX * dx0 + x0 ) ) ;
359
+ var y1 = Math . max ( 0 , Math . min ( ph , scaleY * dy0 + y0 ) ) ;
357
360
var dx = Math . abs ( x1 - x0 ) ;
358
361
var dy = Math . abs ( y1 - y0 ) ;
359
362
@@ -553,6 +556,8 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
553
556
554
557
// plotDrag: move the plot in response to a drag
555
558
function plotDrag ( dx , dy ) {
559
+ dx = dx * scaleX ;
560
+ dy = dy * scaleY ;
556
561
// If a transition is in progress, then disable any behavior:
557
562
if ( gd . _transitioningWithDuration ) {
558
563
return ;
0 commit comments