Skip to content

Commit 94f685f

Browse files
committed
888: fixed cartesian pan
1 parent d31244a commit 94f685f

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/plots/cartesian/dragbox.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
9090
var hasScatterGl, hasSplom, hasSVG;
9191
// collected changes to be made to the plot by relayout at the end
9292
var updates;
93+
// scaling factors from css transform
94+
var scaleX;
95+
var scaleY;
9396

9497
function recomputeAxisLists() {
9598
xa0 = plotinfo.xaxis;
@@ -161,6 +164,10 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
161164

162165
recomputeAxisLists();
163166

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+
164171
if(!allFixedRanges) {
165172
if(isMainDrag) {
166173
// main dragger handles all drag modes, and changes
@@ -331,11 +338,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
331338
x0 = transformedCoords[0];
332339
y0 = transformedCoords[1];
333340

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};
339342
lum = gd._hmpixcount ?
340343
(gd._hmlumcount / gd._hmpixcount) :
341344
tinycolor(gd._fullLayout.plot_bgcolor).getLuminance();
@@ -352,8 +355,8 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
352355
return false;
353356
}
354357

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));
357360
var dx = Math.abs(x1 - x0);
358361
var dy = Math.abs(y1 - y0);
359362

@@ -553,6 +556,8 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
553556

554557
// plotDrag: move the plot in response to a drag
555558
function plotDrag(dx, dy) {
559+
dx = dx * scaleX;
560+
dy = dy * scaleY;
556561
// If a transition is in progress, then disable any behavior:
557562
if(gd._transitioningWithDuration) {
558563
return;

0 commit comments

Comments
 (0)