Skip to content

Commit

Permalink
expose cursor.idx, remove all args but self from cursormove event
Browse files Browse the repository at this point in the history
  • Loading branch information
leeoniya committed Dec 8, 2019
1 parent ccef896 commit 5716304
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
4 changes: 3 additions & 1 deletion demos/tooltips.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@
},
events: {
cursormove: [
(u, left, top, idx) => {
u => {
const {left, top, idx} = u.cursor;

u.cursortt.style.left = left + "px";
u.cursortt.style.top = top + "px";
u.cursortt.textContent = "(" + u.valAt(left, "x").toFixed(2) + ", " + u.valAt(top, "y").toFixed(2) + ")";
Expand Down
5 changes: 4 additions & 1 deletion dist/uPlot.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,7 @@ function Line(opts, data) {
locked: false,
left: -10,
top: -10,
idx: null,
}, opts.cursor);

var focus = cursor.focus; // focus: {alpha, prox}
Expand Down Expand Up @@ -1721,7 +1722,9 @@ function Line(opts, data) {
}
}

fire("cursormove", cursorLeft, cursorTop, idx);
cursor.idx = idx;

fire("cursormove");

if (pub !== false) {
sync.pub(mousemove, self, cursorLeft, cursorTop, canCssWidth, canCssHeight, idx);
Expand Down
5 changes: 4 additions & 1 deletion dist/uPlot.iife.js
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,7 @@ var uPlot = (function (exports) {
locked: false,
left: -10,
top: -10,
idx: null,
}, opts.cursor);

var focus = cursor.focus; // focus: {alpha, prox}
Expand Down Expand Up @@ -1722,7 +1723,9 @@ var uPlot = (function (exports) {
}
}

fire("cursormove", cursorLeft, cursorTop, idx);
cursor.idx = idx;

fire("cursormove");

if (pub !== false) {
sync.pub(mousemove, self, cursorLeft, cursorTop, canCssWidth, canCssHeight, idx);
Expand Down
2 changes: 1 addition & 1 deletion dist/uPlot.iife.min.js

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/Line.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ export function Line(opts, data) {
locked: false,
left: -10,
top: -10,
idx: null,
}, opts.cursor);

const focus = cursor.focus; // focus: {alpha, prox}
Expand Down Expand Up @@ -1104,7 +1105,9 @@ export function Line(opts, data) {
}
}

fire("cursormove", cursorLeft, cursorTop, idx);
cursor.idx = idx;

fire("cursormove");

if (pub !== false) {
sync.pub(mousemove, self, cursorLeft, cursorTop, canCssWidth, canCssHeight, idx);
Expand Down

0 comments on commit 5716304

Please sign in to comment.