Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions dist/uPlot.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3621,6 +3621,8 @@ function uPlot(opts, data, then) {

const mouseListeners = new Map();

let globalMouseMove = false;

function onMouse(ev, targ, fn, onlyTarg = true) {
const targListeners = mouseListeners.get(targ) || {};
const listener = cursor.bind[ev](self, targ, fn, onlyTarg);
Expand Down Expand Up @@ -6163,6 +6165,14 @@ function uPlot(opts, data, then) {
}

function mouseUp(e, src, _l, _t, _w, _h, _i) {
if (globalMouseMove) {
off(mousemove, doc, mouseMove);
globalMouseMove = false;
// console.log('off global mousemove');

// TODO: hide cursor here
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs to happen

}

dragging = drag._x = drag._y = false;

cacheMouse(e, src, _l, _t, _w, _h, _i, false, true);
Expand Down Expand Up @@ -6239,6 +6249,12 @@ function uPlot(opts, data, then) {
let _dragging = dragging;

if (dragging) {
if (dragX && dragY) {
on(mousemove, doc, mouseMove);
globalMouseMove = true;
// console.log('on global mousemove');
}

// handle case when mousemove aren't fired all the way to edges by browser
let snapH = true;
let snapV = true;
Expand Down Expand Up @@ -6321,6 +6337,12 @@ function uPlot(opts, data, then) {
onMouse(mousedown, over, mouseDown);
onMouse(mousemove, over, mouseMove);
onMouse(mouseenter, over, e => {
if (globalMouseMove) {
off(mousemove, doc, mouseMove);
globalMouseMove = false;
// console.log('off global mousemove');
}

setCursorEvent(e);
syncRect(false);
});
Expand Down Expand Up @@ -6395,6 +6417,13 @@ function uPlot(opts, data, then) {
cursorPlots.delete(self);
mouseListeners.clear();
off(dppxchange, win, onDppxChange);

if (globalMouseMove) {
off(mousemove, doc, mouseMove);
globalMouseMove = false;
// console.log('off global mousemove');
}

root.remove();
legendTable?.remove(); // in case mounted outside of root
fire("destroy");
Expand Down
29 changes: 29 additions & 0 deletions dist/uPlot.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -3619,6 +3619,8 @@ function uPlot(opts, data, then) {

const mouseListeners = new Map();

let globalMouseMove = false;

function onMouse(ev, targ, fn, onlyTarg = true) {
const targListeners = mouseListeners.get(targ) || {};
const listener = cursor.bind[ev](self, targ, fn, onlyTarg);
Expand Down Expand Up @@ -6161,6 +6163,14 @@ function uPlot(opts, data, then) {
}

function mouseUp(e, src, _l, _t, _w, _h, _i) {
if (globalMouseMove) {
off(mousemove, doc, mouseMove);
globalMouseMove = false;
// console.log('off global mousemove');

// TODO: hide cursor here
}

dragging = drag._x = drag._y = false;

cacheMouse(e, src, _l, _t, _w, _h, _i, false, true);
Expand Down Expand Up @@ -6237,6 +6247,12 @@ function uPlot(opts, data, then) {
let _dragging = dragging;

if (dragging) {
if (dragX && dragY) {
on(mousemove, doc, mouseMove);
globalMouseMove = true;
// console.log('on global mousemove');
}

// handle case when mousemove aren't fired all the way to edges by browser
let snapH = true;
let snapV = true;
Expand Down Expand Up @@ -6319,6 +6335,12 @@ function uPlot(opts, data, then) {
onMouse(mousedown, over, mouseDown);
onMouse(mousemove, over, mouseMove);
onMouse(mouseenter, over, e => {
if (globalMouseMove) {
off(mousemove, doc, mouseMove);
globalMouseMove = false;
// console.log('off global mousemove');
}

setCursorEvent(e);
syncRect(false);
});
Expand Down Expand Up @@ -6393,6 +6415,13 @@ function uPlot(opts, data, then) {
cursorPlots.delete(self);
mouseListeners.clear();
off(dppxchange, win, onDppxChange);

if (globalMouseMove) {
off(mousemove, doc, mouseMove);
globalMouseMove = false;
// console.log('off global mousemove');
}

root.remove();
legendTable?.remove(); // in case mounted outside of root
fire("destroy");
Expand Down
29 changes: 29 additions & 0 deletions dist/uPlot.iife.js
Original file line number Diff line number Diff line change
Expand Up @@ -3622,6 +3622,8 @@ var uPlot = (function () {

const mouseListeners = new Map();

let globalMouseMove = false;

function onMouse(ev, targ, fn, onlyTarg = true) {
const targListeners = mouseListeners.get(targ) || {};
const listener = cursor.bind[ev](self, targ, fn, onlyTarg);
Expand Down Expand Up @@ -6164,6 +6166,14 @@ var uPlot = (function () {
}

function mouseUp(e, src, _l, _t, _w, _h, _i) {
if (globalMouseMove) {
off(mousemove, doc, mouseMove);
globalMouseMove = false;
// console.log('off global mousemove');

// TODO: hide cursor here
}

dragging = drag._x = drag._y = false;

cacheMouse(e, src, _l, _t, _w, _h, _i, false, true);
Expand Down Expand Up @@ -6240,6 +6250,12 @@ var uPlot = (function () {
let _dragging = dragging;

if (dragging) {
if (dragX && dragY) {
on(mousemove, doc, mouseMove);
globalMouseMove = true;
// console.log('on global mousemove');
}

// handle case when mousemove aren't fired all the way to edges by browser
let snapH = true;
let snapV = true;
Expand Down Expand Up @@ -6322,6 +6338,12 @@ var uPlot = (function () {
onMouse(mousedown, over, mouseDown);
onMouse(mousemove, over, mouseMove);
onMouse(mouseenter, over, e => {
if (globalMouseMove) {
off(mousemove, doc, mouseMove);
globalMouseMove = false;
// console.log('off global mousemove');
}

setCursorEvent(e);
syncRect(false);
});
Expand Down Expand Up @@ -6396,6 +6418,13 @@ var uPlot = (function () {
cursorPlots.delete(self);
mouseListeners.clear();
off(dppxchange, win, onDppxChange);

if (globalMouseMove) {
off(mousemove, doc, mouseMove);
globalMouseMove = false;
// console.log('off global mousemove');
}

root.remove();
legendTable?.remove(); // in case mounted outside of root
fire("destroy");
Expand Down
2 changes: 1 addition & 1 deletion dist/uPlot.iife.min.js

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions src/uPlot.js
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,8 @@ export default function uPlot(opts, data, then) {

const mouseListeners = new Map();

let globalMouseMove = false;

function onMouse(ev, targ, fn, onlyTarg = true) {
const targListeners = mouseListeners.get(targ) || {};
const listener = cursor.bind[ev](self, targ, fn, onlyTarg);
Expand Down Expand Up @@ -3240,6 +3242,14 @@ export default function uPlot(opts, data, then) {
}

function mouseUp(e, src, _l, _t, _w, _h, _i) {
if (globalMouseMove) {
off(mousemove, doc, mouseMove);
globalMouseMove = false;
// console.log('off global mousemove');

// TODO: hide cursor here
}

dragging = drag._x = drag._y = false;

cacheMouse(e, src, _l, _t, _w, _h, _i, false, true);
Expand Down Expand Up @@ -3316,6 +3326,12 @@ export default function uPlot(opts, data, then) {
let _dragging = dragging;

if (dragging) {
if (dragX && dragY) {
on(mousemove, doc, mouseMove);
globalMouseMove = true;
// console.log('on global mousemove');
}

// handle case when mousemove aren't fired all the way to edges by browser
let snapH = true;
let snapV = true;
Expand Down Expand Up @@ -3398,6 +3414,12 @@ export default function uPlot(opts, data, then) {
onMouse(mousedown, over, mouseDown);
onMouse(mousemove, over, mouseMove);
onMouse(mouseenter, over, e => {
if (globalMouseMove) {
off(mousemove, doc, mouseMove);
globalMouseMove = false;
// console.log('off global mousemove');
}

setCursorEvent(e);
syncRect(false);
});
Expand Down Expand Up @@ -3472,6 +3494,13 @@ export default function uPlot(opts, data, then) {
cursorPlots.delete(self);
mouseListeners.clear();
off(dppxchange, win, onDppxChange);

if (globalMouseMove) {
off(mousemove, doc, mouseMove);
globalMouseMove = false;
// console.log('off global mousemove');
}

root.remove();
FEAT_LEGEND && legendTable?.remove(); // in case mounted outside of root
fire("destroy");
Expand Down