Skip to content

Commit 0895041

Browse files
committed
fix y auto-scaling bug with adaptive-unidirectional zooming
1 parent 188e521 commit 0895041

File tree

5 files changed

+30
-17
lines changed

5 files changed

+30
-17
lines changed

dist/uPlot.cjs.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2085,6 +2085,8 @@ function uPlot(opts, data, then) {
20852085

20862086
var drag = cursor.drag;
20872087

2088+
var dragX = drag.x;
2089+
var dragY = drag.y;
20882090
if ( cursor.show) {
20892091
var c = "cursor-";
20902092

@@ -2355,8 +2357,9 @@ function uPlot(opts, data, then) {
23552357
if (mouseLeft1 >= 0 && select.show && dragging) {
23562358
// setSelect should not be triggered on move events
23572359

2358-
var dragX = drag.x;
2359-
var dragY = drag.y;
2360+
dragX = drag.x;
2361+
dragY = drag.y;
2362+
23602363
var uni = drag.uni;
23612364

23622365
if (uni != null) {
@@ -2511,14 +2514,14 @@ function uPlot(opts, data, then) {
25112514

25122515
if (drag.setScale) {
25132516
batch(function () {
2514-
if (drag.x) {
2517+
if (dragX) {
25152518
_setScale(xScaleKey,
25162519
scaleValueAtPos(select[LEFT], xScaleKey),
25172520
scaleValueAtPos(select[LEFT] + select[WIDTH], xScaleKey)
25182521
);
25192522
}
25202523

2521-
if (drag.y) {
2524+
if (dragY) {
25222525
for (var k in scales) {
25232526
var sc = scales[k];
25242527

dist/uPlot.esm.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2077,6 +2077,8 @@ function uPlot(opts, data, then) {
20772077

20782078
const drag = cursor.drag;
20792079

2080+
let dragX = drag.x;
2081+
let dragY = drag.y;
20802082
if ( cursor.show) {
20812083
let c = "cursor-";
20822084

@@ -2347,8 +2349,9 @@ function uPlot(opts, data, then) {
23472349
if (mouseLeft1 >= 0 && select.show && dragging) {
23482350
// setSelect should not be triggered on move events
23492351

2350-
let dragX = drag.x;
2351-
let dragY = drag.y;
2352+
dragX = drag.x;
2353+
dragY = drag.y;
2354+
23522355
let uni = drag.uni;
23532356

23542357
if (uni != null) {
@@ -2503,14 +2506,14 @@ function uPlot(opts, data, then) {
25032506

25042507
if (drag.setScale) {
25052508
batch(() => {
2506-
if (drag.x) {
2509+
if (dragX) {
25072510
_setScale(xScaleKey,
25082511
scaleValueAtPos(select[LEFT], xScaleKey),
25092512
scaleValueAtPos(select[LEFT] + select[WIDTH], xScaleKey),
25102513
);
25112514
}
25122515

2513-
if (drag.y) {
2516+
if (dragY) {
25142517
for (let k in scales) {
25152518
let sc = scales[k];
25162519

dist/uPlot.iife.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2086,6 +2086,8 @@ var uPlot = (function () {
20862086

20872087
var drag = cursor.drag;
20882088

2089+
var dragX = drag.x;
2090+
var dragY = drag.y;
20892091
if ( cursor.show) {
20902092
var c = "cursor-";
20912093

@@ -2356,8 +2358,9 @@ var uPlot = (function () {
23562358
if (mouseLeft1 >= 0 && select.show && dragging) {
23572359
// setSelect should not be triggered on move events
23582360

2359-
var dragX = drag.x;
2360-
var dragY = drag.y;
2361+
dragX = drag.x;
2362+
dragY = drag.y;
2363+
23612364
var uni = drag.uni;
23622365

23632366
if (uni != null) {
@@ -2512,14 +2515,14 @@ var uPlot = (function () {
25122515

25132516
if (drag.setScale) {
25142517
batch(function () {
2515-
if (drag.x) {
2518+
if (dragX) {
25162519
_setScale(xScaleKey,
25172520
scaleValueAtPos(select[LEFT], xScaleKey),
25182521
scaleValueAtPos(select[LEFT] + select[WIDTH], xScaleKey)
25192522
);
25202523
}
25212524

2522-
if (drag.y) {
2525+
if (dragY) {
25232526
for (var k in scales) {
25242527
var sc = scales[k];
25252528

0 commit comments

Comments
 (0)